split() 缺少一个必需的位置参数: ‘y’

我正在尝试预测塑料流体的粘度,我使用了随机森林回归器和K折交叉验证来训练我的数据。

RFR = RandomForestRegressor(n_estimators = 2000,max_depth = 20, n_jobs=-1, random_state = 0)scores = []Kfold = StratifiedKFold(n_splits=10, random_state = 0, shuffle=True)for i in range(10):    result = next(Kfold.split(X_train), None)    input_train = df.iloc[result[0]]    input_test = df.iloc[result[1]]    output_train = y.iloc[result[0]]    output_test = y.iloc[result[1]]    model = RFR.fit(input_train,output_train)    predictions = RFR.predict(input_test)    scores.append(model.score(input_test,output_test))print('Scores from each Iteration: ', scores)print('Average K-Fold Score :' , np.mean(scores))

我想对我的模型进行10折交叉验证的训练,但得到了以下错误信息:

TypeError: split() 缺少一个必需的位置参数: 'y'

回答:

正如错误提示所示,StratifiedKFoldsplit方法期望从训练数据中同时获得Xy,以便生成验证和测试集:

split(self, X, y, groups=None)

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注