Exemple #1
0
    display(Image(data=graph.pipe(format='png')))
    return estimator
# %%
plt.rcParams['figure.figsize'] = (12,8)
plt.style.use("ggplot")
rf = RandomForestClassifier(bootstrap='True',class_weight=None,criterion='gini',max_depth=3
                            ,max_features='auto',max_leaf_nodes=None,min_impurity_decrease=1
                            ,min_samples_split=2,min_weight_fraction_leaf=0.0,n_estimators=100
                            ,n_jobs=1,oob_score=False,random_state=1,verbose=False,warm_start=False)
viz = FeatureImportances(rf)
viz.fit(X_train,y_train)
viz.show()
# %%
visualizer = ROCAUC(rf,classes=['stayed','quit'])
visualizer.fit(X_train,y_train)
visualizer.score(X_test,y_test)
visualizer.poof()
# %%
dt = DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=2,
            max_features=None, max_leaf_nodes=None,
            min_impurity_decrease=0.0, min_impurity_split=None,
            min_samples_leaf=1, min_samples_split=2,
            min_weight_fraction_leaf=0.0, presort=False, random_state=0,
            splitter='best')

visualizer = ROCAUC(dt, classes=["stayed", "quit"])

visualizer.fit(X_train, y_train)        # Fit the training data to the visualizer
visualizer.score(X_test, y_test)        # Evaluate the model on the test data
visualizer.poof();
# %%
                            min_weight_fraction_leaf=0.0,
                            n_estimators=100,
                            n_jobs=-1,
                            oob_score=False,
                            random_state=1,
                            verbose=False,
                            warm_start=False)
viz = FeatureImportances(rf)
viz.fit(X_train, y_train)
viz.show()
dt = DecisionTreeClassifier(class_weight=None,
                            criterion='gini',
                            max_depth=2,
                            max_features=None,
                            max_leaf_nodes=None,
                            min_impurity_decrease=0.0,
                            min_impurity_split=None,
                            min_samples_leaf=1,
                            min_samples_split=2,
                            min_weight_fraction_leaf=0.0,
                            presort=False,
                            random_state=0,
                            splitter='best')
viz = FeatureImportances(dt)
viz.fit(X_train, y_train)
viz.show()
from yellowbrick.classifier import ROCAUC
visualizer = ROCUAC(rf, classes=['stayed', 'quit'])
visualizer.fit(X_train, y_train)
visualizer.score(X_test, y_test)