ML之LiR&Lasso:基于datasets糖尿病数据集利用LiR和Lasso算法进行(9→1)回归预测(三维图散点图可视化)


银耳汤过时
银耳汤过时 2022-09-19 11:54:59 51525
分类专栏: 资讯

ML之LiR&Lasso:基于datasets糖尿病数据集利用LiR和Lasso算法进行(9→1)回归预测(三维图散点图可视化)

目录

基于datasets糖尿病数据集利用LiR和Lasso算法进行(9→1)回归预测(三维图散点图可视化)

设计思路

输出结果

Lasso核心代码


相关文章
ML之LiR&Lasso:基于datasets糖尿病数据集利用LiR和Lasso算法进行(9→1)回归预测(三维图散点图可视化)
ML之LiR&Lasso:基于datasets糖尿病数据集利用LiR和Lasso算法进行(9→1)回归预测(三维图散点图可视化)实现

基于datasets糖尿病数据集利用LiR和Lasso算法进行(9→1)回归预测(三维图散点图可视化)

设计思路

输出结果

Lasso核心代码

  1. class Lasso Found at: sklearn.linear_model._coordinate_descent
  2. class Lasso(-title class_ inherited__">ElasticNet):
  3. """Linear Model trained with L1 prior as regularizer (aka the Lasso)
  4. The optimization objective for Lasso is::
  5. (1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1
  6. Technically the Lasso model is optimizing the same objective function as
  7. the Elastic Net with ``l1_ratio=1.0`` (no L2 penalty).
  8. Read more in the :ref:`User Guide <lasso>`.
  9. Parameters
  10. ----------
  11. alpha : float, default=1.0
  12. Constant that multiplies the L1 term. Defaults to 1.0.
  13. ``alpha = 0`` is equivalent to an ordinary least square, solved
  14. by the :class:`LinearRegression` object. For numerical
  15. reasons, using ``alpha = 0`` with the ``Lasso`` object is not advised.
  16. Given this, you should use the :class:`LinearRegression` object.
  17. fit_intercept : bool, default=True
  18. Whether to calculate the intercept for this model. If set
  19. to False, no intercept will be used in calculations
  20. (i.e. data is expected to be centered).
  21. normalize : bool, default=False
  22. This parameter is ignored when ``fit_intercept`` is set to False.
  23. If True, the regressors X will be normalized before regression by
  24. subtracting the mean and dividing by the l2-norm.
  25. If you wish to standardize, please use
  26. :class:`sklearn.preprocessing.StandardScaler` before calling ``fit``
  27. on an estimator with ``normalize=False``.
  28. precompute : 'auto', bool or array-like of shape (n_features, n_features),\
  29. default=False
  30. Whether to use a precomputed Gram matrix to speed up
  31. calculations. If set to ``'auto'`` let us decide. The Gram
  32. matrix can also be passed as argument. For sparse input
  33. this option is always ``True`` to preserve sparsity.
  34. copy_X : bool, default=True
  35. If ``True``, X will be copied; else, it may be overwritten.
  36. max_iter : int, default=1000
  37. The maximum number of iterations
  38. tol : float, default=1e-4
  39. The tolerance for the optimization: if the updates are
  40. smaller than ``tol``, the optimization code checks the
  41. dual gap for optimality and continues until it is smaller
  42. than ``tol``.
  43. warm_start : bool, default=False
  44. When set to True, reuse the solution of the previous call to fit as
  45. initialization, otherwise, just erase the previous solution.
  46. See :term:`the Glossary <warm_start>`.
  47. positive : bool, default=False
  48. When set to ``True``, forces the coefficients to be positive.
  49. random_state : int, RandomState instance, default=None
  50. The seed of the pseudo random number generator that selects a
  51. random
  52. feature to update. Used when ``selection`` == 'random'.
  53. Pass an int for reproducible output across multiple function calls.
  54. See :term:`Glossary <random_state>`.
  55. selection : {'cyclic', 'random'}, default='cyclic'
  56. If set to 'random', a random coefficient is updated every iteration
  57. rather than looping over features sequentially by default. This
  58. (setting to 'random') often leads to significantly faster convergence
  59. especially when tol is higher than 1e-4.
  60. Attributes
  61. ----------
  62. coef_ : ndarray of shape (n_features,) or (n_targets, n_features)
  63. parameter vector (w in the cost function formula)
  64. sparse_coef_ : sparse matrix of shape (n_features, 1) or \
  65. (n_targets, n_features)
  66. ``sparse_coef_`` is a readonly property derived from ``coef_``
  67. intercept_ : float or ndarray of shape (n_targets,)
  68. independent term in decision function.
  69. n_iter_ : int or list of int
  70. number of iterations run by the coordinate descent solver to reach
  71. the specified tolerance.
  72. Examples
  73. --------
  74. >>> from sklearn import linear_model
  75. >>> clf = linear_model.Lasso(alpha=0.1)
  76. >>> clf.fit([[0,0], [1, 1], [2, 2]], [0, 1, 2])
  77. Lasso(alpha=0.1)
  78. >>> print(clf.coef_)
  79. [0.85 0. ]
  80. >>> print(clf.intercept_)
  81. 0.15...
  82. See also
  83. --------
  84. lars_path
  85. lasso_path
  86. LassoLars
  87. LassoCV
  88. LassoLarsCV
  89. sklearn.decomposition.sparse_encode
  90. Notes
  91. -----
  92. The algorithm used to fit the model is coordinate descent.
  93. To avoid unnecessary memory duplication the X argument of the fit
  94. method
  95. should be directly passed as a Fortran-contiguous numpy array.
  96. """
  97. path = staticmethod(enet_path)
  98. -meta"> @_deprecate_positional_args
  99. def __init__(self, alpha=1.0, *, fit_intercept=True, normalize=False,
  100. precompute=False, copy_X=True, max_iter=1000,
  101. tol=1e-4, warm_start=False, positive=False,
  102. random_state=None, selection='cyclic'):
  103. super().__init__(alpha=alpha, l1_ratio=1.0, fit_intercept=fit_intercept,
  104. normalize=normalize, precompute=precompute, copy_X=copy_X,
  105. max_iter=max_iter, tol=tol, warm_start=warm_start, positive=positive,
  106. random_state=random_state, selection=selection)
  107. Functions for CV with paths functions

网站声明:如果转载,请联系本站管理员。否则一切后果自行承担。

本文链接:https://www.xckfsq.com/news/show.html?id=2192
赞同 0
评论 0 条
银耳汤过时L0
粉丝 0 发表 6 + 关注 私信
上周热门
如何使用 StarRocks 管理和优化数据湖中的数据?  2956
【软件正版化】软件正版化工作要点  2875
统信UOS试玩黑神话:悟空  2839
信刻光盘安全隔离与信息交换系统  2733
镜舟科技与中启乘数科技达成战略合作,共筑数据服务新生态  1267
grub引导程序无法找到指定设备和分区  1231
华为全联接大会2024丨软通动力分论坛精彩议程抢先看!  165
2024海洋能源产业融合发展论坛暨博览会同期活动-海洋能源与数字化智能化论坛成功举办  163
点击报名 | 京东2025校招进校行程预告  163
华为纯血鸿蒙正式版9月底见!但Mate 70的内情还得接着挖...  159
本周热议
我的信创开放社区兼职赚钱历程 40
今天你签到了吗? 27
信创开放社区邀请他人注册的具体步骤如下 15
如何玩转信创开放社区—从小白进阶到专家 15
方德桌面操作系统 14
我有15积分有什么用? 13
用抖音玩法闯信创开放社区——用平台宣传企业产品服务 13
如何让你先人一步获得悬赏问题信息?(创作者必看) 12
2024中国信创产业发展大会暨中国信息科技创新与应用博览会 9
中央国家机关政府采购中心:应当将CPU、操作系统符合安全可靠测评要求纳入采购需求 8

加入交流群

请使用微信扫一扫!