当前位置: 首页 > news >正文

wordpress代码高亮杭州seo 云优化科技

wordpress代码高亮,杭州seo 云优化科技,杭州企业网站建设 哪里好,用阿里巴巴做公司网站怎么样弹性网络 代码原文 下面代码参考scikit-learn中文社区,链接在上面。 但是由于scikit-learn中文社区上的代码有些地方跑不通,故对此代码做了修改,输出结果与社区中显示的结果相同。 对弹性网络进行简单的介绍: ElasticNet是一个训…

弹性网络

代码原文
下面代码参考scikit-learn中文社区,链接在上面。
但是由于scikit-learn中文社区上的代码有些地方跑不通,故对此代码做了修改,输出结果与社区中显示的结果相同。

对弹性网络进行简单的介绍:
ElasticNet是一个训练时同时用ℓ1和ℓ2范数进行正则化的线性回归模型,lasso是使用ℓ1范数进行正则化的线性回归模型。
弹性网络简弹性网络简介弹性网络简

from itertools import cycle
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import lasso_path, enet_path
from sklearn import datasetsX, y = datasets.load_diabetes(return_X_y=True)X /= X.std(axis=0)  # Standardize data (easier to set the l1_ratio parameter)
print("------------------------------------")
print(X)
print("------------------------------------")
print(y)
# Compute pathseps = 5e-3  # the smaller it is the longer is the pathprint("Computing regularization path using the lasso...")
# alphas_lasso, coefs_lasso, _ = lasso_path(X, y, eps=eps, fit_intercept=False)
alphas_lasso, coefs_lasso, _ = lasso_path(X, y)print("Computing regularization path using the positive lasso...")
# alphas_positive_lasso, coefs_positive_lasso, _ = lasso_path(
#     X, y, eps=eps, positive=True, fit_intercept=False)
alphas_positive_lasso, coefs_positive_lasso, _ = lasso_path(X, y, eps=eps, positive=True)print("Computing regularization path using the elastic net...")
# alphas_enet, coefs_enet, _ = enet_path(
#     X, y, eps=eps, l1_ratio=0.8, fit_intercept=False)
alphas_enet, coefs_enet, _ = enet_path(X, y, eps=eps, l1_ratio=0.8)print("Computing regularization path using the positive elastic net...")
# alphas_positive_enet, coefs_positive_enet, _ = enet_path(
#     X, y, eps=eps, l1_ratio=0.8, positive=True, fit_intercept=False)
alphas_positive_enet, coefs_positive_enet, _ = enet_path(X, y, eps=eps, l1_ratio=0.8, positive=True)
print("------------------------------------")
print(alphas_positive_enet)
print("------------------------------------")
print(coefs_positive_enet)
# Display resultsplt.figure(1)
colors = cycle(['b', 'r', 'g', 'c', 'k'])
neg_log_alphas_lasso = -np.log10(alphas_lasso)
neg_log_alphas_enet = -np.log10(alphas_enet)
for coef_l, coef_e, c in zip(coefs_lasso, coefs_enet, colors):l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)l2 = plt.plot(neg_log_alphas_enet, coef_e, linestyle='--', c=c)plt.xlabel('-Log(alpha)')
plt.ylabel('coefficients')
plt.title('Lasso and Elastic-Net Paths')
plt.legend((l1[-1], l2[-1]), ('Lasso', 'Elastic-Net'), loc='lower left')
plt.axis('tight')plt.figure(2)
neg_log_alphas_positive_lasso = -np.log10(alphas_positive_lasso)
for coef_l, coef_pl, c in zip(coefs_lasso, coefs_positive_lasso, colors):l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)l2 = plt.plot(neg_log_alphas_positive_lasso, coef_pl, linestyle='--', c=c)plt.xlabel('-Log(alpha)')
plt.ylabel('coefficients')
plt.title('Lasso and positive Lasso')
plt.legend((l1[-1], l2[-1]), ('Lasso', 'positive Lasso'), loc='lower left')
plt.axis('tight')plt.figure(3)
neg_log_alphas_positive_enet = -np.log10(alphas_positive_enet)
for (coef_e, coef_pe, c) in zip(coefs_enet, coefs_positive_enet, colors):l1 = plt.plot(neg_log_alphas_enet, coef_e, c=c)l2 = plt.plot(neg_log_alphas_positive_enet, coef_pe, linestyle='--', c=c)plt.xlabel('-Log(alpha)')
plt.ylabel('coefficients')
plt.title('Elastic-Net and positive Elastic-Net')
plt.legend((l1[-1], l2[-1]), ('Elastic-Net', 'positive Elastic-Net'),loc='lower left')
plt.axis('tight')
plt.show()
http://www.zhongyajixie.com/news/9115.html

相关文章:

  • 上海高端网站开发福建百度推广
  • 上海哪些做网站外贸如何做网站推广
  • 网站ar怎么做web前端培训费用大概多少
  • 口碑好的宜昌网站建设百度账号出售平台
  • 顺德网站建设公司市场调研怎么写
  • 怎样做不用备案的网站百度关键词怎么做
  • 网站做跳转免费自助建站哪个最好
  • 长沙网站设计优刻长春网站优化方案
  • 西昌市做网站的公司平台连接
  • 枣庄网站建设公司网页推广怎么做
  • 建设一个收入支出持平的网站短视频营销案例
  • 国内做家具外贸的网站有哪些做网站建设公司
  • 湘潭网站开发上海网站快速排名优化
  • 微信网站需要一个域名要怎么做今日足球比赛预测推荐分析
  • 做网站一般用什么 语言搜索引擎优化排名培训
  • 网wordpress站底部图片悬浮百度推广后台管理
  • 独立b2c网站能打开任何网站浏览器
  • 无锡做网站服务我要登录百度
  • 中堂镇仿做网站专业拓客团队怎么收费
  • 响应式网站如何做公众号推广接单平台
  • 网站怎么响应式布局抖音优化排名
  • 动漫网站策划书百度电商平台app
  • 杭州哪家做网站好海外营销推广
  • 做澳洲ets上什么网站百度识图搜索网页版
  • 河北省住房与建设厅网站首页台州关键词优化报价
  • 调用百度地图做全景的网站自己如何制作一个网页
  • 青岛网站建设效果重庆百度推广电话
  • 网站全套建设沈阳全网推广公司哪家好
  • 个人网站备案备注怎么写全网关键词云查询
  • 南昌地宝网二手车沈阳seo排名公司