机器学习算法基础——多元线性回归

多元线性回归和一元线性回归基本一致,只介绍sklearn的方法实现:

import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from sklearn.linear_model import LinearRegression

data=np.genfromtxt('Delivery.csv',delimiter=',')
x_data=data[:,:-1]#取前n-1位
y_data=data[:,-1]#取最后一位

model=LinearRegression()#建立线性回归模型
model.fit(x_data,y_data)

print("[w0]=",model.intercept_)#截距w0
print("[w1,w2]=",model.coef_)#系数w1,w2

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/NEUQ_snowy/article/details/128246095