sklearn random forest Machine learning

70 views Asked by At

I want to output the prediction values of the random forest results from my test data into Excel and generate a map, but I need to know which line this result is for and use its coordinates, that is, how can I see the index of that test data along with the prediction?(with sklearn)

y_pred=regr.predict(X_test) print(mean_squared_error(y_test,y_pred)) np.savetxt("y_pred.csv",y_pred)

1

There are 1 answers

2
Kilian On

I would use pandas to create a dataframe containing X_test and y_pred and save that.

import pandas as pd
test=pd.DataFrame(np.c_[X_test,y_pred])
test.to_csv('test.csv')