IIS_2023_1/malkova_anastasia_lab_2/fit.py

16 lines
341 B
Python
Raw Normal View History

2023-11-11 18:47:17 +04:00
from sklearn.linear_model import Lasso
from sklearn.linear_model import LinearRegression
from sklearn.feature_selection import RFE, f_regression
def fit_models(x, y):
lasso = Lasso(alpha=0.001)
lasso.fit(x, y)
rfe = RFE(lasso, step=2)
rfe.fit(x, y)
f, val = f_regression(x, y, center=False)
return lasso, rfe, f