繁体   English   中英

在机器学习(线性回归)中,在训练/测试过程中我得到了这个类型错误。 有人可以帮我吗?

[英]In machine learning(Linear Regression), in the training/test process I got this Type Error. Can someone help me with that?

from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder = LabelEncoder()
X[:, 3] = labelencoder.fit_transform(X[:, 3])

onehotencoder = OneHotEncoder(categorical_features = [3])
X = onehotencoder.fit_transform(X).toarray()
print(X)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-33-723c0ae23eaf> in <module>
      3 X[:, 3] = labelencoder.fit_transform(X[:, 3])
      4 
----> 5 onehotencoder = OneHotEncoder(categorical_features = [3])
      6 X = onehotencoder.fit_transform(X).toarray()
      7 print(X)

~\anaconda3\lib\site-packages\sklearn\utils\validation.py in inner_f(*args, **kwargs)
     70                           FutureWarning)
     71         kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 72         return f(**kwargs)
     73     return inner_f
     74 

TypeError: __init__() got an unexpected keyword argument 'categorical_features'

参数应该是根据sklearn docscategories

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM