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
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.