簡體   English   中英

將預測寫回數據框 pandas

[英]Writing predictions back to dataframe pandas

我正在研究 Jupyter notebook 中的一些分類模型。 我現在已經嘗試了許多不同的算法,並確定了哪一個是最佳選擇。

我需要將預測寫回原始數據幀(訓練/測試數據)嗎? 是否有任何說明來說明這是如何完成的?

假設您使用的是 sklearn。

# model is the trained model. df is the features you are using for prediction
y = model.predict(df)
# just create a new column in the dataframe you predicted and assign it to the prediction
df['prediction'] = y

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM