#clf.fit(X_total_train,y_total_train, sample_weight=w_total_train) mse = mean_squared_error(y_total_test, clf.predict(X_total_test)) print("MSE: %.4f" % mse) #clf.evals_result() print clf.score(X_total_train,y_total_train) #print clf.best_params_ joblib.dump(clf, os.path.expanduser('/eos/user/i/ivovtin/HHggbb/HHbbgg_ETH_devel/Training/plots/optimization/simlple_Test_binary_st.pkl'), compress=9) import matplotlib.pyplot as plt from xgboost import plot_tree from sklearn.metrics import accuracy_score #plotting.plot_input_variables(X_sig,X_bkg,branch_names) #plt.show() plotting.plot_classifier_output(clf,X_total_train,X_total_test,y_total_train,y_total_test,outString="xbrg_test_st_values_notcut") #plt.show() #fpr,tpr = plotting.plot_roc_curve(X_total_train,y_total_train,clf) #plotting.print_roc_report(fpr,tpr) #plt.savefig(utils.IO.plotFolder+"ROC_train.eps") #plt.show() #fpr,tpr = plotting.plot_roc_curve(X_total_test,y_total_test,clf) #plotting.print_roc_report(fpr,tpr) #plt.show() plt.bar(range(len(clf.feature_importances_)), clf.feature_importances_) plt.savefig(utils.IO.plotFolder+"importance1.eps") #plt.show() # xgb.plot_importance(clf)
import matplotlib.pyplot as plt reload(plt) #outTag = '2018/dev_legecy_runII_Mjj_woMjjcut_v2/' outTag = '2018/dev_legecy_runII_ext_rho_rew_v3/' joblib.dump(clf, os.path.expanduser(utils.IO.plotFolder + outTag + 'simlple_Test_binary_st.pkl'), compress=9) #plotting.plot_input_variables(X_sig,X_bkg,branch_names) #plt.show() plotting.plot_classifier_output(clf, X_total_train, X_total_test, y_total_train, y_total_test, outString=utils.IO.plotFolder + outTag + "classifierOutputPlot_xbrg_test_st_values") #plt.show() #fpr,tpr = plotting.plot_roc_curve(X_total_train,y_total_train,clf) #plotting.print_roc_report(fpr,tpr) #plt.savefig(utils.IO.plotFolder+"ROC_train.eps") #plt.show() #fpr,tpr = plotting.plot_roc_curve(X_total_test,y_total_test,clf) #plotting.print_roc_report(fpr,tpr) #plt.show() #plt.bar(range(len(clf.feature_importances_)), clf.feature_importances_) #plt.savefig(utils.IO.plotFolder+outTag+"importance1.eps")
outTag = mass_range + 'mass' folder = str(pklfolder) + '_' + str(sig) + '_' + outTag + '_' + str(year) if not os.path.exists(folder): os.mkdir(folder) joblib.dump( clf, os.path.expanduser(str(folder) + '/' + outTag + '_XGB_training_file.pkl'), compress=9) #plotting.plot_input_variables(X_sig,X_bkg,branch_names) #plt.show() plotting.plot_classifier_output(clf, X_total_train, X_total_test, y_total_train, y_total_test, outString=str(folder) + '/' + outTag + "_classifierOutputPlot_xbrg_test_st_values") plt.clf() #plt.show() #fpr,tpr = plotting.plot_roc_curve(X_total_train,y_total_train,clf) #plotting.print_roc_report(fpr,tpr) #plt.savefig(utils.IO.plotFolder+"ROC_train.eps") #plt.show() #fpr,tpr = plotting.plot_roc_curve(X_total_test,y_total_test,clf) #plotting.print_roc_report(fpr,tpr) #plt.show() #plt.bar(range(len(clf.feature_importances_)), clf.feature_importances_)