如何修复"TypeError: fit() missing 1 required positional argument: 'X'"错误



我正在尝试使用LinearRegression拟合模型

from sklearn.model_selection import cross_val_score
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
X_train, X_test, y_train, y_test = train_test_split(x, y)
mod = make_pipeline(PolynomialFeatures(degree=1), 
LinearRegression(normalize=True))
mod.fit(x=X_train, y=y_train)

并收到错误消息

fit() missing 1 required positional argument: 'X'

请问我该如何解决它?

Pipeline.fit 的文档说大写字母 X,请尝试:

mod.fit(X=X_train, y=y_train)

相关内容

  • 没有找到相关文章

最新更新