I've this code to print the importance of each variable on my model:
importances = trained_model.feature_importances_
std = np.std([trained_model.feature_importances_ for trained_model in trained_model.estimators_], axis=0)
indices = np.argsort(importances)[::-1]
# Print the feature ranking
print("Feature ranking:")
for f in range(training_features.shape[1]):
print("%d. feature %d (%f)" % (f + 1, indices[f], importances[indices[f]]))
I print a lot of variables with feature ranking as 0.0. Should I remove that variables? I can I do it using Python?
Like this:
df = df.drop('Col_A', 1) WHERE importances[indices[f]] = 0
Thanks!