In [1]:
import numpy as np
from os.path import join, splitext
from lab1 import load_data, n_per_class_split, load_scene_categories, split_into_X_y
# load dataset
dataset = load_scene_categories('scene_categories')
train_set, test_set = n_per_class_split(dataset, n=100)
# setup training data
X_train, y_train = split_into_X_y(train_set)
In [2]:
from utils import cross_validation
image_data = cross_validation(X_train, y_train)
print(image_data)
In [4]:
"""
from bokeh.plotting import figure, output_notebook, show
output_notebook()
p = figure(title="simple line example", x_axis_label='accuracy', y_axis_label='C')
Cs = list(data.keys())
for C, values in data.items():
print("hola", Cs, values)
p.circle(Cs, values, legend="Temp.", line_width=2)
# show the results
show(p)
"""
%matplotlib inline
import matplotlib.pyplot as plt
Cs = []
c_matrix = []
for C, values in image_data.items():
print(C, values)
Cs.append(C)
c_matrix.append(values)
c_matrix = np.array(c_matrix)
for i, c in enumerate(Cs):
#print(i, c, c_matrix[:, i])
plt.plot(Cs, c_matrix[:, i], 'ro')
plt.xscale('log')
plt.axis([0.01, 100, 0, 1])
plt.show()
In [5]:
from utils import calculate_accuracy
# load dataset
dataset = load_scene_categories('scene_categories')
ACC = []
for loop in range(5):
train_set, test_set = n_per_class_split(dataset, n=100)
# setup training data
X_train, y_train = split_into_X_y(train_set)
X_test, y_test = split_into_X_y(test_set)
ACC.append(calculate_accuracy(X_train, X_test, y_train, y_test, C=10))
print(ACC)
In [7]:
acc_np = np.array(ACC)
print("Mean:", acc_np.mean())
print("Std:", acc_np.std())
In [ ]: