Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhao062 committed Aug 4, 2019
1 parent 557cb0c commit c0314c0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
Binary file modified examples/compare_selected_classifiers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions examples/compare_selected_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

from combo.models.classifier_comb import SimpleClassifierAggregator
from combo.models.classifier_stacking import Stacking
from combo.models.classifier_dcs import DCS_LA
from combo.models.classifier_des import DES_LA

# Define the number of class 0 and class 1
n_samples = 300
Expand Down Expand Up @@ -73,7 +75,9 @@
'Stacking': Stacking(base_estimators=classifiers, shuffle_data=True),
'Stacking_RF': Stacking(base_estimators=classifiers, shuffle_data=True,
meta_clf=RandomForestClassifier(
random_state=random_state))
random_state=random_state)),
'DCS_LA': DCS_LA(base_estimators=classifiers),
'DEC_LA': DES_LA(base_estimators=classifiers)
}

# Show all classifiers
Expand All @@ -92,9 +96,8 @@
X = np.r_[X, np.random.uniform(low=-6, high=6, size=(n_class1, 2))]

# Fit the model
plt.figure(figsize=(15, 8))
plt.figure(figsize=(15, 12))
for i, (clf_name, clf) in enumerate(classifiers.items()):
print()
print(i + 1, 'fitting', clf_name)
# fit the data and tag class 1

Expand All @@ -107,7 +110,7 @@
# plot the levels lines and the points
Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1] * -1
Z = Z.reshape(xx.shape)
subplot = plt.subplot(2, 4, i + 1)
subplot = plt.subplot(3, 4, i + 1)
subplot.contourf(xx, yy, Z, levels=np.linspace(Z.min(), threshold, 7),
cmap=plt.cm.Blues_r)
a = subplot.contour(xx, yy, Z, levels=[threshold],
Expand Down
5 changes: 3 additions & 2 deletions examples/temp_do_not_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from sklearn.datasets import load_breast_cancer
from sklearn.utils.multiclass import check_classification_targets

from combo.models.classifier_dcs import DCS_LA
from combo.models.classifier_des import DES_LA
from combo.utils.data import evaluate_print

import warnings
Expand Down Expand Up @@ -87,8 +87,9 @@
evaluate_print('Random Forest |', y_test, clf.predict(X_test))

print()
clf = DCS_LA(classifiers)
clf = DES_LA(classifiers, use_weights=True)
clf.fit(X_train, y_train)
y_test_predicted = clf.predict(X_test)
y_test_proba_predicted = clf.predict_proba(X_test)
evaluate_print('DCS_LA |', y_test, y_test_predicted)
print(roc_auc_score(y_test, y_test_proba_predicted[:, 1]))
29 changes: 14 additions & 15 deletions notebooks/compare_selected_classifiers.ipynb

Large diffs are not rendered by default.

0 comments on commit c0314c0

Please sign in to comment.