我有一个Pandas.DataFrame对象dfTrain,它存储所有训练数据点
此数据框中有多种数据类型,例如,名为"IP"的列存储字符串值(如"168.0.0.1"),而另一列名为"SIZE"的列包含整数值 .
现在,我正在使用sklearn.ensemble.GradientBoostingRegressor来训练模型:
# prepare data set
x_train = dfTrainningSet.values
y_train = dfTrainningSetLabels['LABEL1'].values
# setup regressor
params = {'n_estimators':500, 'max_depth':10, 'min_samples_split':50, 'min_samples_leaf':50, 'learning_rate':0.05, 'loss':'lad', 'subsample':1.0, 'max_features':0.9}
gbr = GradientBoostingRegressor(**params)
# fit
print('start to train model ...')
gbr.fit(x_train, y_train)
print('finish training model, \n start to predict...')
....
但是,引发了一个 valueError 异常:
/anaconda/lib/python2.7/site-packages/numpy/core/numeric.pyc in ascontiguousarray(a,dtype)546 547“”“ - > 548返回数组(a,dtype,copy = False,order = 'C',ndmin = 1)549 550 def asfortranarray(a,dtype = None):ValueError:float()的无效文字:124.160.177.72
我想知道如何在sklearn中处理这种多数据类型的数据集?有没有办法解决这个错误?
任何建议将不胜感激 .