最近也在做这个,核心代码给你,如下:
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import (RandomTreesEmbedding, RandomForestClassifier, GradientBoostingClassifier)
from sklearn.preprocessing import OneHotEncoder
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_curve,auc
from sklearn.externals import joblib
from sklearn.externals.six import StringIO
from sklearn import tree
import pydotplus
n_estimator = 4 # the number of base trees
X, y = make_classification(n_samples=100,n_features=4)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3,random_state=0)
X_train, X_train_lr, y_train, y_train_lr = train_