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

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

 

相关文章
|
8月前
|
开发框架 算法 .NET
基于ADMM无穷范数检测算法的MIMO通信系统信号检测MATLAB仿真,对比ML,MMSE,ZF以及LAMA
简介:本文介绍基于ADMM的MIMO信号检测算法,结合无穷范数优化与交替方向乘子法,降低计算复杂度并提升检测性能。涵盖MATLAB 2024b实现效果图、核心代码及详细注释,并对比ML、MMSE、ZF、OCD_MMSE与LAMA等算法。重点分析LAMA基于消息传递的低复杂度优势,适用于大规模MIMO系统,为通信系统检测提供理论支持与实践方案。(238字)
|
机器学习/深度学习 算法 数据挖掘
K-means聚类算法是机器学习中常用的一种聚类方法,通过将数据集划分为K个簇来简化数据结构
K-means聚类算法是机器学习中常用的一种聚类方法,通过将数据集划分为K个簇来简化数据结构。本文介绍了K-means算法的基本原理,包括初始化、数据点分配与簇中心更新等步骤,以及如何在Python中实现该算法,最后讨论了其优缺点及应用场景。
1786 6
|
搜索推荐 前端开发 数据可视化
【优秀python web毕设案例】基于协同过滤算法的酒店推荐系统,django框架+bootstrap前端+echarts可视化,有后台有爬虫
本文介绍了一个基于Django框架、协同过滤算法、ECharts数据可视化以及Bootstrap前端技术的酒店推荐系统,该系统通过用户行为分析和推荐算法优化,提供个性化的酒店推荐和直观的数据展示,以提升用户体验。
1025 1
【优秀python web毕设案例】基于协同过滤算法的酒店推荐系统,django框架+bootstrap前端+echarts可视化,有后台有爬虫
|
数据采集 机器学习/深度学习 数据可视化
【优秀python web系统毕设】基于python的全国招聘数据分析可视化系统,包括随机森林算法
本文介绍了一个基于Python的全国招聘数据分析可视化系统,该系统利用数据挖掘技术、随机森林算法和数据可视化技术,从招聘网站抓取数据,进行处理、分析和预测,帮助用户洞察招聘市场,为求职者和企业提供决策支持。
1326 3
|
机器学习/深度学习 算法 数据可视化
利用SVM(支持向量机)分类算法对鸢尾花数据集进行分类
本文介绍了如何使用支持向量机(SVM)算法对鸢尾花数据集进行分类。作者通过Python的sklearn库加载数据,并利用pandas、matplotlib等工具进行数据分析和可视化。
1338 70
|
机器学习/深度学习 数据采集 数据可视化
基于python 机器学习算法的二手房房价可视化和预测系统
文章介绍了一个基于Python机器学习算法的二手房房价可视化和预测系统,涵盖了爬虫数据采集、数据处理分析、机器学习预测以及Flask Web部署等模块。
746 2
基于python 机器学习算法的二手房房价可视化和预测系统
|
数据可视化 搜索推荐 Python
Leecode 刷题笔记之可视化六大排序算法:冒泡、快速、归并、插入、选择、桶排序
这篇文章是关于LeetCode刷题笔记,主要介绍了六大排序算法(冒泡、快速、归并、插入、选择、桶排序)的Python实现及其可视化过程。
390 0
|
机器学习/深度学习 算法 数据可视化
基于Python flask的豆瓣电影数据分析可视化系统,功能多,LSTM算法+注意力机制实现情感分析,准确率高达85%
本文介绍了一个基于Python Flask框架的豆瓣电影数据分析可视化系统,该系统集成了LSTM算法和注意力机制进行情感分析,准确率高达85%,提供了多样化的数据分析和情感识别功能,旨在帮助用户深入理解电影市场和观众喜好。
779 0
|
监控 数据可视化 算法
基于朴素贝叶斯算法的微博舆情监控系统,flask后端,可视化丰富
本文介绍了一个基于朴素贝叶斯算法和Python技术栈的微博舆情监控系统,该系统使用Flask作为后端框架,通过数据爬取、清洗、情感分析和可视化等手段,为用户提供丰富的舆情分析和监测功能。
613 0
|
Dart 算法 数据可视化
用flutter实现五种寻路算法的可视化效果,快来看看!
半年前我写了一篇有关排序算法可视化的文章,挺有意思,还被张风捷特烈-张老师收录进了FlutterUnit,今天让我们再来做一个有关寻路算法的可视化效果吧!

热门文章

最新文章