In [1]:
import numpy as np
import matplotlib as mpl
%matplotlib inline
import time
import pandas as pd
import seaborn as sns
from mnist import MNIST # public package for making arrays out of MINST data.
In [2]:
import sys
sys.path.append('../code/')
In [3]:
from ridge_regression import RidgeMulti
from hyperparameter_explorer import HyperparameterExplorer
In [4]:
from mnist_helpers import mnist_training, mnist_testing
In [5]:
import matplotlib.pyplot as plt
from pylab import rcParams
rcParams['figure.figsize'] = 4, 3
In [6]:
train_X, train_y = mnist_training()
test_X, test_y = mnist_testing()
In [7]:
R = np.random.normal(size=(train_X.shape[1], 10000))
In [8]:
XR = train_X.dot(R).clip(min=0)
In [9]:
XR = train_X.dot(R)
In [10]:
hyper_explorer = HyperparameterExplorer(X=XR, y=train_y,
model=RidgeMulti,
validation_split=58./60, score_name = 'training RMSE',
use_prev_best_weights=False,
test_X=test_X.dot(R), test_y=test_y)
In [11]:
hyper_explorer.train_model(lam=100, kernelized=True, verbose=True)
In [12]:
# Boo. We can't run vanilla ridge regression for a N=300 data set w/o the Kernel.
# The inversion would be 10,000 by 10,000, causing a memory error.
#hyper_explorer.train_model(lam=100, kernelized=False, verbose=True)
In [13]:
hyper_explorer.final_model = hyper_explorer.models[1].copy()
In [14]:
hyper_explorer.evaluate_test_data()
In [ ]: