Search code examples
pythonpandasscikit-learnsklearn-pandas

mapping back any sklearn result to the original dataframe


I'd like to analyze the predicted values of my random forest results in excel with the original test data as a reference.

The predicted result comes in an array as i use this:

predict = rf.predict(test[columns])

how do I map back the predicted results to the original dataset using pandas?

Regards, galeej


Solution

  • EdChum's answered the question.

    (Edit) His answer:

    You should be able to just add this back as a new column: test['prediction'] = rf.predict(test[columns])

    My apologies for the delay.

    Regards, Sunil