Hi I would like to create a .csv with 2 columns: the feature importance of a random forest model and the name of that feature. And to be sure that the match between numeric value and variable name is correct
Here it's an example but I cannot export to .csv correclty
test_features = test[["area","product", etc.]].values
# Create the target
target = test["churn"].values
pred_forest = my_forest.predict(test_features)
# Print the score of the fitted random forest
print(my_forest.score(test_features, target))
importance = my_forest.feature_importances_
pd.DataFrame({"IMP": importance, "features":test_features }).to_csv('forest_0407.csv',index=False)