AttributeError:“ numpy.ndarray”对象没有属性“ target”

时间:2019-03-03 23:38:18

标签: python-3.x numpy scikit-learn grid-search

执行grid.fit()命令时,出现错误“ AttributeError:'numpy.ndarray'对象没有属性'target'” 。我不确定这意味着什么以及如何解决。有人可以建议吗?

#Grid Search Parameter Tuning
import numpy as np
from sklearn import datasets
from sklearn.linear_model import Ridge
from sklearn.model_selection import GridSearchCV

# datasets
dataset = np.random.rand(1000,2)

#Ridge regression 
alphas = np.array([1,0.1,0.01,0.001,0.0001,0])
model = Ridge()
grid = GridSearchCV(estimator=model, param_grid=dict(alpha=alphas))
grid.fit(dataset.data, dataset.target)

0 个答案:

没有答案