IIS_2023_1/malkova_anastasia_lab_5/fit.py
2023-11-17 00:28:29 +04:00

21 lines
426 B
Python

from sklearn.linear_model import Lasso, Ridge, LinearRegression
from sklearn.feature_selection import RFE, f_regression
def fit_models(x, y):
lm = LinearRegression()
lm.fit(x, y)
ridge = Ridge(alpha=0.001)
ridge.fit(x, y)
lasso = Lasso(alpha=0.001)
lasso.fit(x, y)
rfe = RFE(lasso, step=2)
rfe.fit(x, y)
f, pval = f_regression(x, y, center=False)
return lm, ridge, lasso, rfe, f