Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

bagging model can not run with this data set

i am trying to built bagging model for my data set ..all value coded to number the following error appear.

return array(a, dtype, copy=False, order=order) ValueError: could not convert string to float: 'age'

two instance of my data set

2,1,4,4,1,0,1,1,0,0,0,0,0,0,1,0,0,0,0,1,6

7,1,5,7,0,1,1,0,0,0,0,0,1,1,0,1,1,0,1,0,5

how can i fixed that..thank you

  # Voting Ensemble for Classification
import pandas
from sklearn import model_selection
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
from sklearn.ensemble import VotingClassifier,GradientBoostingClassifier,AdaBoostClassifier,RandomForestClassifier
url = "h:/tourism info1_Latest.csv"
names = ['age','sex','nat','work','rest','travel for work','environment','advanture','relgious','culture','cost','qos','security','tourism guide','independent tour','have disease','mountaian fair','water fair','residential apartments', 'stay in hotels','GROUP ID']
dataframe = pandas.read_csv(url, names=names)
array = dataframe.values
X = array[:,0:20]
Y = array[:,20]
seed = 7
kfold = model_selection.KFold(n_splits=10, random_state=seed)
# create the sub models
estimators = []
model1 =AdaBoostClassifier()
estimators.append(('AdaBoost', model1))
model2 =GradientBoostingClassifier()
estimators.append(('GradientBoosting', model2))
model3 =RandomForestClassifier()
estimators.append(('RandomForest', model3))
# create the ensemble model
ensemble = VotingClassifier(estimators)
results = model_selection.cross_val_score(ensemble, X, Y, cv=kfold)
print(results.mean())

Comments