机器学习(8)-- 多元线性回归

from numpy import genfromtxt
from sklearn import linear_model
"""
[100.    4.    9.3]
 [ 50.    3.    4.8]
 [100.    4.    8.9]
 [100.    2.    6.5]
 [ 50.    2.    4.2]
 [ 80.    2.    6.2]
 [ 75.    3.    7.4]
 [ 65.    4.    6. ]
 [ 90.    3.    7.6]
 [ 90.    2.    6.1]
"""
data = genfromtxt(r"Delivery.csv",delimiter=',')
print(data)

x = data[:, 0:-1]
y = data[:, -1]
print(x, y)

lr = linear_model.LinearRegression()
lr.fit(x, y)
print(lr.coef_)
print(lr.intercept_)
print(lr.predict([[20, 2], [90, 5]]))

猜你喜欢

转载自blog.csdn.net/qq_38876114/article/details/94560552