def SGD_regression_test_error(X, y, X_test, y_test, delta, SGD_epochs):
# center training targets
y_mean = np.mean(y)
y_train = y - y_mean
# solve primal problem
clf = linear_model.SGDRegressor(alpha=delta, fit_intercept=False, n_iter=SGD_epochs)
clf.fit(X, y_train)
y_hat_test = y_mean + X_test.dot(clf.coef_)
return 100.0 * np.linalg.norm(y_hat_test - y_test) / np.linalg.norm(y_test)
# BINARY SEARCH KERNEL WIDTH
评论列表
文章目录