text_plain_output_1.png image_output_1.png
from sklearn.ensemble import RandomForestClassifier

import pandas as pd

df = pd.read_csv('../input/kasco-dataset-russian/Задача 1/Прогнозирование пролонгации/Данные для задачи.txt', sep=';')

rf_clf = RandomForestClassifier(bootstrap=False)
result_clf = rf_clf.fit(X_train, Y_train)
yrf_predicted = rf_clf.predict(X_test)

imp = pd.DataFrame(rf_clf.feature_importances_, index=X_test.columns, columns=['POLICY_PRICE_CHANGE'])
imp.sort_values('POLICY_PRICE_CHANGE').plot(kind='barh', figsize=(12, 8))

imp = pd.DataFrame(rf.feature_importances_, index=x_train.columns, columns=['importance'])
imp.sort_values('importance').plot(kind='barh', figsize=(12, 8))