add random forest predictions as column into test file

后端 未结 1 1564
心在旅途
心在旅途 2021-01-13 15:52

I am working in python pandas (in a Jupyter notebook), where I created a Random Forest model for the Titanic data set. https://www.kaggle.com/c/ti

相关标签:
1条回答
  • 2021-01-13 16:04

    Since

    rfc_model_3 = RandomForestClassifier(n_estimators=200)
    rfc_model_3.predict(X_test)
    

    returns y : array of shape = [n_samples] (see docs), you should be able to add the model output directly to X_test without creating an intermediate DataFrame:

    X_test['survived'] = rfc_model_3.predict(X_test)
    

    If you want the intermediate result anyway, @EdChum's suggestion in the comments would work fine.

    0 讨论(0)
提交回复
热议问题