Python GridSearchCV错误:预期类似数组(数组或非字符串序列),已获取
我目前正在使用H20建模,但我正在使用Scikit学习管道Python GridSearchCV错误:预期类似数组(数组或非字符串序列),已获取,python,scikit-learn,h2o,Python,Scikit Learn,H2o,我目前正在使用H20建模,但我正在使用Scikit学习管道 首先,我使用以下代码创建了基线模型: 现在,我想通过运行gridsearch对模型进行超调谐,如下所示: 但是我得到了以下明确的错误消息(它不是不完整的,它的结尾是这样的): 如果您想知道列车数据是什么样子的,这是数据帧结构: trin[x] = {'nartd_share': 'real', 'nanrtd_share': 'real', 'hot_beverages_share': 'real', 'alcoholic_bev
trin[x] = {'nartd_share': 'real',
'nanrtd_share': 'real',
'hot_beverages_share': 'real',
'alcoholic_beverages_share': 'real',
'all_beverages_share': 'int',
'pfand_share': 'int',
'if_top7_cities': 'enum',
'opening_days': 'real',
'opening_hours': 'real',
'closing_hours': 'real',
'open_at_b_of': 'real',
'close_at_e_of': 'real',
'busiest_at': 'real',
'most_revenue_at': 'real',
'opening_at_cosine': 'real',
'closing_at_cosine': 'real',
'busiest_at_cosine': 'real',
'most_revenue_at_cosine': 'real',
'weekend_opening_hours': 'real',
'weekday_opening_hours': 'real',
'avg_overnight_hours': 'real',
'if_overnight': 'enum',
'if_sunday': 'enum',
'monthly_revenue': 'real',
'monthly_quantity': 'real',
'monthly_alcohol_revenue': 'real',
'monthly_7vat_share': 'real',
'weekly_revenue': 'real',
'weekly_quantity': 'real',
'weekly_alcohol_revenue': 'real',
'weekly_7vat_share': 'real',
'daily_revenue': 'real',
'daily_quantity': 'real',
'daily_alcohol_revenue': 'real',
'daily_7vat_share': 'real',
'avg_alcohol_price': 'real',
'avg_nartd_price': 'real',
'max_alcohol_price': 'real',
'max_nartd_price': 'real',
'top1_product': 'enum',
'top2_product': 'enum',
'top3_product': 'enum'}
train[y] = {'segment': 'enum'}
得到什么?一定有什么东西(在错误消息中)。。。什么是
x
和y
?“如果我将其与列车数据相匹配,则工作正常”-请包括相关的code@desertnaut也许现在更清楚了,明白了吗?一定有什么东西(在错误消息中)。。。什么是x
和y
?“如果我将其与列车数据相匹配,则工作正常”-请包括相关的code@desertnaut也许现在更清楚一点。
parameters = {'ntree': [24, 50, 100], 'max_depth': [5,10], 'learn_rate':[0.25, 0.5, 0.65]}
gs_clf = GridSearchCV(clf_pipe, param_grid=params)
clf = gs_clf.fit(train[x], train[y])
/usr/local/lib/python3.7/site-packages/sklearn/utils/multiclass.py in type_of_target(y)
239 if not valid:
240 raise ValueError('Expected array-like (array or non-string sequence), '
--> 241 'got %r' % y)
242
243 sparse_pandas = (y.__class__.__name__ in ['SparseSeries', 'SparseArray'])
ValueError: Expected array-like (array or non-string sequence), got
trin[x] = {'nartd_share': 'real',
'nanrtd_share': 'real',
'hot_beverages_share': 'real',
'alcoholic_beverages_share': 'real',
'all_beverages_share': 'int',
'pfand_share': 'int',
'if_top7_cities': 'enum',
'opening_days': 'real',
'opening_hours': 'real',
'closing_hours': 'real',
'open_at_b_of': 'real',
'close_at_e_of': 'real',
'busiest_at': 'real',
'most_revenue_at': 'real',
'opening_at_cosine': 'real',
'closing_at_cosine': 'real',
'busiest_at_cosine': 'real',
'most_revenue_at_cosine': 'real',
'weekend_opening_hours': 'real',
'weekday_opening_hours': 'real',
'avg_overnight_hours': 'real',
'if_overnight': 'enum',
'if_sunday': 'enum',
'monthly_revenue': 'real',
'monthly_quantity': 'real',
'monthly_alcohol_revenue': 'real',
'monthly_7vat_share': 'real',
'weekly_revenue': 'real',
'weekly_quantity': 'real',
'weekly_alcohol_revenue': 'real',
'weekly_7vat_share': 'real',
'daily_revenue': 'real',
'daily_quantity': 'real',
'daily_alcohol_revenue': 'real',
'daily_7vat_share': 'real',
'avg_alcohol_price': 'real',
'avg_nartd_price': 'real',
'max_alcohol_price': 'real',
'max_nartd_price': 'real',
'top1_product': 'enum',
'top2_product': 'enum',
'top3_product': 'enum'}
train[y] = {'segment': 'enum'}