2. 线性回归api初步使用
Last updated
Last updated
from sklearn.linear_model import LinearRegressionx = [[80, 86],
[82, 80],
[85, 78],
[90, 90],
[86, 82],
[82, 90],
[78, 80],
[92, 94]]
y = [84.2, 80.6, 80.1, 90, 83.2, 87.6, 79.4, 93.4]# 实例化API
estimator = LinearRegression()
# 使用fit方法进行训练
estimator.fit(x,y)
estimator.coef_
estimator.predict([[100, 80]])