Esempio n. 1
0
	print("RMSE: ", score)
	if score < max_error:
		max_error = score
		best_f = k
	scores2.append(score)

matplotlib.pyplot.plot(space, scores2, 'k^:')
matplotlib.pyplot.xlabel('Number of Features')
matplotlib.pyplot.ylabel('Cross Validation Error')
matplotlib.pyplot.title('Singular Value Decomposition')
matplotlib.pyplot.savefig('../plots/singular_value_decomposition2.png')
matplotlib.pyplot.gcf().clear()

space = (numpy.linspace(0.01, 1, 10))
model.set_f(best_f)
model.set_bias(True)

for k in space:
	print("Epoch: %i", k)
	model.set_k_u(k)
	model.set_k_b(k)
	model.set_k_m(k)
	score = model.train(X, Y, X_val, Y_val)
	score = model.RMSE(X_test, Y_test)
	print("RMSE: ", score)
	scores3.append(score)

matplotlib.pyplot.plot(space, scores3, 'rx-')
matplotlib.pyplot.xlabel('Bias')
matplotlib.pyplot.ylabel('RMSE')
matplotlib.pyplot.title('Singular Value Decomposition')