线性回归API
from sklearn.linear_model import LinearRegression# 加载数据x = [[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]# 实例化APIestimator
·
from sklearn.linear_model import LinearRegression
# 加载数据
x = [[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)
print(estimator.coef_)
# 对未知样本预测
estimator.predict([[100, 80]])
更多推荐
所有评论(0)