資源簡介
利用隨機坐標下降法和循環坐標下降法求解lasso回歸,并作比較。
代碼片段和文件信息
import?numpy?as?np
import?pandas?as?pd
import?matplotlib.pyplot?as?plt
from?sklearn?import?linear_model
from?sklearn?import?preprocessing
from?sklearn.model_selection?import?train_test_split
import?copy
class?Algorithm:
“““
This?is?a?demo?of?using?coordinate?descent?algorithm?(including?both?cyclic?coordinate?descent?
and?randomized?coordinate?descent)?to?solve?the?LASSO?problem?that?is?the?‘l1-regularized?
least-squares?regression?problem.
“““
def?__init__(self?lambduh=6.46?max_iter=1000):
“““
Coordinate?descent?algorithm?to?solve?the?LASSO?problem.
Parameters
----------
lambduh?:?float
Regularization?parameter.
The?default?lambduh?is?set?as?6.46?(the?optimal?lambduh?from?cross?validation?result).?
However?users?are?allowed?set?lambduh?in?the?__main__?function
- 上一篇:Opencv針式儀表盤識別.py
- 下一篇:python 類QQ即時通訊-聊天軟件
評論
共有 條評論