本文整理汇总了Python中sklearn.linear_model.coordinate_descent.ElasticNetCV.predict方法的典型用法代码示例。如果您正苦于以下问题:Python ElasticNetCV.predict方法的具体用法?Python ElasticNetCV.predict怎么用?Python ElasticNetCV.predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.linear_model.coordinate_descent.ElasticNetCV
的用法示例。
在下文中一共展示了ElasticNetCV.predict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runPrintResults
# 需要导入模块: from sklearn.linear_model.coordinate_descent import ElasticNetCV [as 别名]
# 或者: from sklearn.linear_model.coordinate_descent.ElasticNetCV import predict [as 别名]
def runPrintResults(X, y, alpha, name):
print(name+":\n=========")
if (alpha is not None):
X_new = np.divide(X, alpha)
else:
X_new = X
enetCV = ElasticNetCV(l1_ratio=0.8, fit_intercept=False) # cv=nCV, max_iter=5000
# enetCV = LassoCV(fit_intercept=False) # cv=nCV, max_iter=5000
enetCV.fit(X_new, y)
y_pred_enet = enetCV.predict(X_new)
r2_score_enet = r2_score(y, y_pred_enet)
print("R2= ", r2_score_enet)
if (alpha is not None):
enetCV_coef = np.divide(enetCV.coef_, alpha)
else:
enetCV_coef = enetCV.coef_
print("Best Alpha: {}".format(enetCV.alpha_))
# print("coefs_: {}".format(enetCV.coef_))
print("coefs_/alpha: {}".format(enetCV_coef))
return enetCV.alpha_, enetCV_coef