我想对预测模型使用交叉验证。我想保留 20% 的数据作为测试集,并使用我的其余数据通过交叉验证来拟合我的模型。
它希望如下:
作为机器学习模型,我想使用随机森林和 LightGBM。
from sklearn.ensemble import RandomForestRegressor
random_forest = RandomForestRegressor (n_estimators=1400, max_depth=80, max_features='sqrt',
min_samples_leaf=1, min_samples_split=5,
random_state=1, verbose=1, n_jobs=-1)
from sklearn.model_selection import cross_val_score
scores = cross_val_score(random_forest, X_train, y_train, cv=5, scoring = 'r2')
它给出了结果,但我想预测 X_test 数据的 y 值。你能帮我吗?之后,我还将为 LightGBM 创建一个模型。
