【发布时间】:2018-04-17 10:43:21
【问题描述】:
我是使用 python 和 pandas 数据框进行机器学习的新手。 我正在训练我的模型并对 x_test(dataframe) 进行预测。 我想对 x_test 中的每一行(样本)进行预测,如果预测值小于某个值(0.4),我想将该行附加到一个新的数据帧(new_train)。我已经提供了我的想法的主体。你能帮帮我吗?
c = XGBRegressor()
dt = c.fit(x_train, y_train)
new_train = pd.DataFrame()
for rows in x_test:
y_pred = c.predict(x_test[rows])
if y_pred < 0.4:
new_train.append(x_test[rows])
【问题讨论】:
标签: python pandas dataframe machine-learning xgboost