This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gridsearch to find best regularization parameter | |
C_vect = np.logspace(-8, 5, 50) | |
# set the X and Y values. | |
X_tr = train_x[:1000,:] | |
Y_tr = train_y[:1000] | |
X_val = val_x[:1000,:] | |
Y_val = val_y[:1000] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# L1 regularization for C = 0.003 | |
X = train_x[1:1000,:] | |
Y = train_y[1:1000] | |
# Specify the classifier. L1 penalty. | |
logreg_l1 = linear_model.LogisticRegression(penalty='l1', C=.003) | |
# train the classifier | |
logreg_l1.fit(X, Y) | |
# get the coefficients |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gridsearch to find best regularization parameter | |
C_vect = np.logspace(-8, 5, 50) | |
# set the X and Y values. | |
X_tr = train_x[:1000,:] | |
Y_tr = train_y[:1000] | |
X_val = val_x[:1000,:] | |
Y_val = val_y[:1000] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Classification report for classifier LogisticRegression(C=100000.0, class_weight=None, dual=False, | |
fit_intercept=True, intercept_scaling=1, max_iter=100, | |
multi_class='ovr', penalty='l2', random_state=None, | |
solver='liblinear', tol=0.0001, verbose=0): | |
precision recall f1-score support | |
0 0.93 0.97 0.95 634 | |
1 0.94 0.95 0.94 701 | |
2 0.92 0.86 0.89 628 | |
3 0.89 0.87 0.88 675 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Predict digits for the validation set | |
predicted = logreg.predict(val_x) | |
conf_matrix = metrics.confusion_matrix(val_y , predicted) | |
print("Classification report for classifier %s:\n%s\n" | |
% (logreg, metrics.classification_report(val_y, predicted))) | |
print("Confusion matrix:\n%s" % conf_matrix) | |
# Let's plot the confusion matrix, but get rid of the diagonal to better show where the problems are. | |
off_diag = conf_matrix*(1 - np.identity(10)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for the classifier, set the X and Y values. | |
X = train_x | |
Y = train_y | |
# Set regularization parameter (C) | |
reg_param = 1e5 | |
# Define the classifier | |
logreg = linear_model.LogisticRegression(C=reg_param) | |
# train the classifier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code adapted from http://scikit-learn.org/stable/auto_examples/linear_model/plot_iris_logistic.html | |
# originally due to Gaël Varoquaux | |
# Modified by Brad Deutsch | |
# License: BSD 3 clause | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib.cm as cm | |
import matplotlib.image as mpimg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Holy Nova | |
Blackwing Technician | |
Dark Cultist | |
Blackwing Corruptor | |
The Coin | |
. | |
. | |
. | |
Power Word: Shield | |
Blackwing Corruptor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name | |
Entity ID | |
1 NaN | |
2 NaN | |
3 NaN | |
4 Anduin Wrynn | |
5 Lesser Heal | |
6 Twilight Guardian | |
. | |
. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name | |
Entity ID | |
1 NaN | |
2 NaN | |
3 NaN | |
4 Anduin Wrynn | |
5 Lesser Heal | |
6 Twilight Guardian | |
7 NaN | |
8 NaN |
NewerOlder