Commit f3787e25 authored by Ignacio Crespo's avatar Ignacio Crespo

Remove matplotlib

parent 6576c085
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
# along with this program. If not, see <>. # along with this program. If not, see <>.
# #
import logging import logging
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np import numpy as np
import itertools import itertools
from sklearn.metrics import accuracy_score from sklearn.metrics import accuracy_score
...@@ -37,64 +35,4 @@ def predict(classifier, X_test): ...@@ -37,64 +35,4 @@ def predict(classifier, X_test):
def accuracyScore(y_test, predictions): def accuracyScore(y_test, predictions):
return accuracy_score(y_test, predictions) return accuracy_score(y_test, predictions)
def learning_curves(X, y):
title = "Learning Curves (SGD)"
# Cross validation with 100 iterations to get smoother mean test and train
# score curves, each time with 20% data randomly selected as a validation set.
cv = ShuffleSplit(n_splits=100, test_size=0.2, random_state=0)
estimator = QuadraticDiscriminantAnalysis()
train_sizes=np.linspace(.1, 1.0, 5)
ylim=(0.7, 1.01)
plt.xlabel("Training examples")
train_sizes, train_scores, test_scores = learning_curve(
estimator, X, y, cv=cv, n_jobs=n_jobs, train_sizes=train_sizes)
train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
test_scores_mean = np.mean(test_scores, axis=1)
test_scores_std = np.std(test_scores, axis=1)
plt.fill_between(train_sizes, train_scores_mean - train_scores_std,
train_scores_mean + train_scores_std, alpha=0.1,
plt.fill_between(train_sizes, test_scores_mean - test_scores_std,
test_scores_mean + test_scores_std, alpha=0.1, color="g")
plt.plot(train_sizes, train_scores_mean, 'o-', color="r",
label="Training score")
plt.plot(train_sizes, test_scores_mean, 'o-', color="g",
label="Cross-validation score")
def classificationReport(predictions, Y_test):
print("Classification report:\n\n%s \n" % classification_report(Y_test, predictions, digits=6))
def confusionMatrix (predictions, Y_test, classes, normalize=False, title='Confusion matrix',
font = {'family' : 'normal',
'weight' : 'normal',
'size' : 24}
# calculate confusion matrix
print("Confusion Matrix:\n")
cm = confusion_matrix(Y_test, predictions)
def gridSearch(model, X, y, parameters):
#parameters: list of parameters in the configuration file
estimator = model
clf = GridSearchCV(estimator, parameters, cv=5)
print(clf.get_params()), y)
self.classifier = clf
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment