from sklearn.ensemble import RandomForestClassifier
import pandas as pd
import numpy as np
np.random.seed(0)
df = pd.read_csv("data.csv")
df['is_train'] = np.random.uniform(0,1,len(df)) <= 0.75
train, test = df[df['is_train'] == True], df[df['is_train'] == False]
features = df.columns[:10]
y = pd.factorize(train['Selector'])[0]
clf = RandomForestClassifier(n_jobs = 2, random_state = 0)
clf.fit(train[features],y)
ValueError Traceback (most recent call last) in () ----> 1 clf.fit(train[features],y)
C:\Users\abhir\Anaconda2\lib\site-packages\sklearn\ensemble\forest.pyc in fit(self, X, y, sample_weight) 244 """ 245 # Validate or convert input data --> 246 X = check_array(X, accept_sparse="csc", dtype=DTYPE) 247 y = check_array(y, accept_sparse='csc', ensure_2d=False, dtype=None) 248 if sample_weight is not None:
C:\Users\abhir\Anaconda2\lib\site-packages\sklearn\utils\validation.pyc in check_array(array, accept_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator) 400 force_all_finite) 401 else: --> 402 array = np.array(array, dtype=dtype, order=order, copy=copy) 403 404 if ensure_2d:
ValueError: could not convert string to float: Male
Any help on why is this happening and how to resolve this? link to dataset