1.输出XGBoost特征的重要性 from matplotlib import pyplot pyplot.bar(range(len(model_XGB.feature_importances_)), model_XGB.feature_importances_) pyplot.show() XGBoost 特征重要性绘图 也可以使用XGBoost内置的特征重要性绘图函数 # plot feature importance using built-in function from xgboo
import pandas as pd import xgboost as xgb import operator from matplotlib import pylab as plt def ceate_feature_map(features): outfile = open('xgb.fmap', 'w') i = 0 for feat in features: outfile.write('{0}\t{1}\tq\n'.format(i, feat)) i = i + 1 outfil
一.Importing all the libraries import pandas as pdimport numpy as npfrom matplotlib import pyplot as plt from sklearn.model_selection import cross_val_scorefrom sklearn import metricsfrom sklearn.metrics import accuracy_score二.Reading the file 还是蘑菇数据集