![](/img/trans.png)
[英]'RandomOverSampler' object has no attribute '_validate_data'
[英]Logistic regression error Object has no attribute '_validate_data'
我正在训练逻辑分类器,调用分类器后,我似乎无法拟合训练数据。 这就是我得到的。
# calling the classifier
from sklearn.linear_model import LogisticRegression
# instantiated the classifier
log model = LogisticRegression()
# when I try to fit the model with
logmodel.fit(X_train,y_train)
我收到这个错误
------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-143-0b508b2e1562> in <module>
----> 1 logmodel.fit(X_train,y_train)
/opt/anaconda3/lib/python3.7/site-packages/sklearn/linear_model/_logistic.py in fit(self, X, y, sample_weight)
1340 _dtype = [np.float64, np.float32]
1341
-> 1342 X, y = self._validate_data(X, y, accept_sparse='csr', dtype=_dtype,
1343 order="C",
1344 accept_large_sparse=solver != 'liblinear')
AttributeError: 'LogisticRegression' object has no attribute '_validate_data'
有人可以帮忙吗?
改变:
from sklearn.linear_model import LogisticRegression
到
import sklearn.linear_model as lm
并使用实例化分类器
log_model = lm.LogisticRegression()
应该解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.