SHARE
TWEET

Untitled

a guest Jun 26th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. import numpy as np
  3. from sklearn.preprocessing import LabelEncoder
  4. import random
  5. from sklearn.ensemble import RandomForestClassifier
  6. from sklearn.ensemble import GradientBoostingClassifier
  7. from sklearn.cross_validation import train_test_split
  8. from sklearn.tree import DecisionTreeClassifier
  9. from sklearn.metrics import accuracy_score
  10. from sklearn import tree
  11. import matplotlib.pyplot as plt
  12. %matplotlib inline
  13.  
  14. df = pd.read_csv('Documents/Poaching_Final.csv')
  15.  
  16. df
  17.  
  18. id_report   date_report description longitude   latitude
  19. 0   3   1/1/2005    Poaching incident   -7.049359   34.841440
  20. 1   0   1/20/2005   Poaching incident   -7.650840   34.480010
  21. 2   0   1/20/2005   Poaching incident   -7.843202   34.005704
  22. 3   5   1/20/2005   Poaching incident   -7.745846   33.948526
  23. 4   2   1/20/2005   Poaching incident   -7.876673   33.690167
  24. 5   1   1/20/2005   Poaching incident   -7.466248   34.066729
  25. 6   1   1/20/2005   Poaching incident   -7.946153   34.220592
  26. 7   2   1/27/2005   Poaching incident   -7.925990   34.857120
  27. dataset = df.values
  28.  
  29. dataset
  30.  
  31. array([[3, '1/1/2005', 'Poaching incident', -7.049359,
  32.     34.841440000000006],
  33.    [0, '1/20/2005', 'Poaching incident', -7.65084, 34.48001],
  34.    [0, '1/20/2005', 'Poaching incident', -7.8432018029999995,
  35.     34.00570378],
  36.    ...,
  37.    [3, '9/29/2015', 'White Rhino', 31.89865, -28.253253000000004],
  38.    [3, '10/1/2015', 'African Savannah Elephant', 28.589312,
  39.     -16.884113],
  40.    [2, '3/7/2015', 'White Rhino', 30.934913, -24.301232000000002]],
  41.   dtype=object)
  42. X = fullData.values[:, 3:4]
  43. Y = fullData.values[:, 0]
  44.  
  45. poaching_incident = df['description']
  46. poaching_incident_encoding = poaching_incident.factorize()
  47. poaching_incident_encoding[:10]
  48.  
  49. incidnt_date = df['date_report']
  50. incidnt_date_encoding = incidnt_date.factorize()
  51. incidnt_date_encoding[:10]
  52.      
  53. from sklearn import preprocessing
  54. min_max_scaler = preprocessing.MinMaxScaler()
  55. X_scale = min_max_scaler.fit_transform(X)
  56.  
  57. ---------------------------------------------------------------------------
  58. ValueError                                Traceback (most recent call last)
  59. <ipython-input-172-350511f008c8> in <module>()
  60.   1 from sklearn import preprocessing
  61.   2 min_max_scaler = preprocessing.MinMaxScaler()
  62. ----> 3 X_scale = min_max_scaler.fit_transform(X)
  63.  
  64. ValueError: Input contains NaN, infinity or a value too large for
  65. dtype('float64').
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top