utils.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:mondrian-kernel 作者: matejbalog 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号