【问题标题】:How to give input to my trained machine learning model to predict the output?如何为我训练有素的机器学习模型提供输入以预测输出?
【发布时间】:2021-06-06 01:23:37
【问题描述】:

我已经训练了一个机器学习模型来使用过去 5 年的数据来预测番茄的价格。现在我想提供一些信息作为输入来获得预测的输出,但我不知道该怎么做。这些是我用来训练模型 District Name、Market Name、Variety、Grade、Modal_Price_(Rs./Quintal)_log、year、month 和 day 的特征。

#XGBoost
xgbm = XGBRegressor()
xgbm.fit(x_train,y_train)
preds = xgbm.predict(x_test)

rmse = np.sqrt(mean_squared_error(y_test, preds))
print("RMSE: %f" % (rmse))

RMSE:0.285714

【问题讨论】:

    标签: python python-3.x machine-learning data-science xgboost


    【解决方案1】:

    如果您已经阅读了所有的 csv 文件,请确保同名文件存在于同一目录中。如果您使用 pandas 来创建数据框,那么。

    import pandas as pd
    df = pd.read_csv('filename.csv')
    

    如果您想提供原始输入,请参考官方docs

    【讨论】:

    • 我已经使用数据训练了我的模型,现在我想提供一些原始数据作为输入,以便我训练的模型可以为我提供番茄的预测价格
    • 让我回复你
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-21
    • 2019-11-30
    • 2015-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多