MLR:利用多元线性回归法,从大量数据中提取五个因变量来预测一个自变量—Jason niu

时间:2023-12-25 13:38:31
from numpy import genfromtxt
from sklearn import linear_model datapath=r"Delivery_Dummy.csv"
data = genfromtxt(datapath,delimiter=",") x = data[1:,:-1]
y = data[1:,-1]
print (x)
print (y) mlr = linear_model.LinearRegression() mlr.fit(x, y) print (mlr)
print ("coef:")
print (mlr.coef_)
print ("intercept")
print (mlr.intercept_) xPredict = [[120,3,1,0,0]]
yPredict = mlr.predict(xPredict) print ("predict:")
print (yPredict)