Beispiel #1
0
    'score_function': None,
    'leaf_estimation_backtracking': None,
    'ctr_history_unit': None,
    'monotone_constraints': None
}

catboost = GBM(package='catboost',
               X=X[y < 200000],
               y=y[y < 200000],
               feature_names=data['features'],
               cv=5,
               grid_search=False,
               eval_metric='rmse',
               parameters=parameters)

catboost.run_model()
print(catboost.__dict__)
np.save('catboost_res.npy', catboost.__dict__)
catboost.parity_plot(data='train', quantity='CT_RT',
                     scheme=1).savefig('parity_CT_RT_train.png')
catboost.parity_plot(data='test', quantity='CT_RT',
                     scheme=1).savefig('parity_CT_RT_test.png')
plt.clf()
explainer = shap.TreeExplainer(catboost.model[-1])
shap_values = explainer.shap_values(data['X'])

XX = scale.inverse_transform(data['X'])
X = pd.DataFrame(XX, columns=data['features'])
# summarize the effects of all the features
shap.summary_plot(shap_values, X, plot_type="bar", show=False)
plt.savefig('feature_importance.png', dpi=150, bbox_inches='tight')
Beispiel #2
0
C = np.array([25 for i in ID])

xgboost = GBM(package='xgboost',
          X=data['X'],
          y=data['y'],
          feature_names=data['features'],
          cv=5,
          grid_search=False,
          eval_metric='rmse',
          parameters=parameters,
          CT_Temp=CT_Temp,
          CT_RT=CT_RT,
          C=C)


xgboost.run_model()
print(xgboost.__dict__)
xgboost.parity_plot(data='train', quantity='LMP').savefig('parity_LMP_train.png')
xgboost.parity_plot(data='test', quantity='LMP').savefig('parity_LMP_test.png')
xgboost.parity_plot(data='train', quantity='CT_RT').savefig('parity_CT_RT_train.png')
xgboost.parity_plot(data='test', quantity='CT_RT').savefig('parity_CT_RT_test.png')
np.save('xgb_dict.npy', xgboost.__dict__)
plt.clf()
explainer = shap.TreeExplainer(xgboost.model[-1])
shap_values = explainer.shap_values(data['X'])

XX = scale.inverse_transform(data['X'])
X = pd.DataFrame(XX, columns=data['features'])
# summarize the effects of all the features
shap.summary_plot(shap_values, X, plot_type="bar", show=False)
plt.savefig('feature_importance.png', dpi=150, bbox_inches='tight')
Beispiel #3
0
    'random_state': 42,
    'n_jobs': -1,
    'silent': True,
    'importance_type': 'split',
    'num_boost_round': 500,
    'tree_learner': 'feature'
}

lgb = GBM(package='lightgbm',
          X=data['X'],
          y=data['y'],
          feature_names=data['features'],
          cv=5,
          grid_search=False,
          eval_metric='rmse',
          parameters=parameters)

lgb.run_model()
print(lgb.__dict__)
'''
print(data['features'])
plot_importance(lgb.model)
plt.show()
plt.clf()
plot_metric(lgb.model, metric='rmse')
plt.show()
plt.clf()
plot_tree(lgb.model)
plt.show()
'''
Beispiel #4
0
ID = [i[0] for i in data['y2']]
C = np.array([C_data[i] for i in ID])

xgb = GBM(package='xgboost',
          X=data['X'],
          y=data['y'],
          model_scheme='LMP',
          cv=5,
          grid_search=False,
          eval_metric='rmse',
          parameters=parameters,
          CT_Temp=CT_Temp,
          CT_RT=CT_RT,
          C=C)

xgb.run_model()
print(xgb.__dict__)
xgb.parity_plot(data='train', quantity='LMP').savefig('parity_LMP_train.png')
xgb.parity_plot(data='test', quantity='LMP').savefig('parity_LMP_test.png')
xgb.parity_plot(data='train',
                quantity='CT_RT').savefig('parity_CT_RT_train.png')
xgb.parity_plot(data='test', quantity='CT_RT').savefig('parity_CT_RT_test.png')
np.save('xgb_dict.npy', xgb.__dict__)
plt.clf()
explainer = shap.TreeExplainer(xgb.model[-1])
shap_values = explainer.shap_values(data['X'])

XX = scale.inverse_transform(data['X'])
X = pd.DataFrame(XX, columns=data['features'])
# summarize the effects of all the features
shap.summary_plot(shap_values, X, plot_type="bar", show=False)