文章目录
- 集成学习,xgboost.plot_importance 特征重要性
-
集成学习,xgboost.plot_importance 特征重要性
源代码
代码语言:javascript
复制# -*- coding:utf-8 -*-
# /usr/bin/python
'''
@Author : Errol
@Describe:
@Evn :
@Date : -
'''
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from xgboost import XGBClassifier
from xgboost import plot_importance
### load datasets
digits = datasets.load_digits()
### data analysis
print(digits.data.shape)
print(digits.target.shape)
### data split
x_train, x_test, y_train, y_test = train_test_split(digits.data,
digits.