Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- from sklearn.preprocessing import LabelEncoder
- import random
- from sklearn.ensemble import RandomForestClassifier
- from sklearn.ensemble import GradientBoostingClassifier
- from sklearn.cross_validation import train_test_split
- from sklearn.tree import DecisionTreeClassifier
- from sklearn.metrics import accuracy_score
- from sklearn import tree
- import matplotlib.pyplot as plt
- %matplotlib inline
- df = pd.read_csv('Documents/Poaching_Final.csv')
- df
- id_report date_report description longitude latitude
- 0 3 1/1/2005 Poaching incident -7.049359 34.841440
- 1 0 1/20/2005 Poaching incident -7.650840 34.480010
- 2 0 1/20/2005 Poaching incident -7.843202 34.005704
- 3 5 1/20/2005 Poaching incident -7.745846 33.948526
- 4 2 1/20/2005 Poaching incident -7.876673 33.690167
- 5 1 1/20/2005 Poaching incident -7.466248 34.066729
- 6 1 1/20/2005 Poaching incident -7.946153 34.220592
- 7 2 1/27/2005 Poaching incident -7.925990 34.857120
- dataset = df.values
- dataset
- array([[3, '1/1/2005', 'Poaching incident', -7.049359,
- 34.841440000000006],
- [0, '1/20/2005', 'Poaching incident', -7.65084, 34.48001],
- [0, '1/20/2005', 'Poaching incident', -7.8432018029999995,
- 34.00570378],
- ...,
- [3, '9/29/2015', 'White Rhino', 31.89865, -28.253253000000004],
- [3, '10/1/2015', 'African Savannah Elephant', 28.589312,
- -16.884113],
- [2, '3/7/2015', 'White Rhino', 30.934913, -24.301232000000002]],
- dtype=object)
- X = fullData.values[:, 3:4]
- Y = fullData.values[:, 0]
- poaching_incident = df['description']
- poaching_incident_encoding = poaching_incident.factorize()
- poaching_incident_encoding[:10]
- incidnt_date = df['date_report']
- incidnt_date_encoding = incidnt_date.factorize()
- incidnt_date_encoding[:10]
- from sklearn import preprocessing
- min_max_scaler = preprocessing.MinMaxScaler()
- X_scale = min_max_scaler.fit_transform(X)
- ---------------------------------------------------------------------------
- ValueError Traceback (most recent call last)
- <ipython-input-172-350511f008c8> in <module>()
- 1 from sklearn import preprocessing
- 2 min_max_scaler = preprocessing.MinMaxScaler()
- ----> 3 X_scale = min_max_scaler.fit_transform(X)
- ValueError: Input contains NaN, infinity or a value too large for
- dtype('float64').
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement