From 717da7a7e173cd971baddd9f8edb6de668b1e815 Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Sun, 10 Mar 2019 18:30:33 +0000 Subject: Add plot probas function --- lenet.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lenet.py b/lenet.py index 9b4bb2e..881cfd7 100644 --- a/lenet.py +++ b/lenet.py @@ -17,6 +17,7 @@ from sklearn.decomposition import PCA from classifier_metrics_impl import classifier_score_from_logits from sklearn.utils import shuffle from sklearn.manifold import TSNE +import scikitplot as skplt def import_mnist(): from tensorflow.examples.tutorials.mnist import input_data @@ -142,6 +143,13 @@ def train_classifier(x_train, y_train, x_val, y_val, batch_size=128, epochs=100, model.save_weights('./weights.h5') return model +def plot_probas(model, x_test, y_true): + probas = model.predict(x_test) + skplt.metrics.plot_roc(y_true, probas) + plt.show() + skplt.metrics.plot_precision_recall_curve(y_true, probas) + plt.show() + def test_classifier(model, x_test, y_true, conf_mat=False, pca=False, tsne=False): x_test = np.pad(x_test, ((0,0),(2,2),(2,2),(0,0)), 'constant') logits = model.predict(x_test) -- cgit v1.2.3-54-g00ecf