sklearn做线性回归
- 生成数据集
1. 调用库
from sklearn.Linear_model import LinerRegression
from skleran.Linear_model import Lasson
from sklearn.Linear_model import Ridge
- 生成数据集
from sklearn.Linear_model import train_test_split
x, y =make_Regression(n_samples=100, n_feature=15, noise=30)
xtrain, ytrain, xtest, ytest = train_test_split(x,y,test_size=0.3)
- 线性回归
# 普通线性回归
lr = LinearRegression().fit(xtrain,ytrain)
# lasso回归
La_l1 = LinearRegressi