标签:data get otl 图形 intercept 数据 att .sh cep
from sklearn.datasets import load_boston
boston = load_boston()
print(boston.keys())
from sklearn.datasets import load_boston
import matplotlib.pyplot as plt
boston = load_boston()
data = boston.data
print(boston.keys())
x = data[:,5]
y = boston.target
plt.scatter(x,y)
plt.plot(x,9*x-30,c = 'r') # y = wx+b
plt.show()
from sklearn.datasets import load_boston
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
boston = load_boston()
data = boston.data
x = data[:,5]
y = boston.target
# 使用LinearRegression 计算w,b的值
LineR = LinearRegression()
LineR.fit(x.reshape(-1,1),y)
w = LineR.coef_
b = LineR.intercept_
plt.scatter(x,y)
plt.plot(x,w*x+b,c = 'r') # y = wx+b
plt.show()
标签:data get otl 图形 intercept 数据 att .sh cep
原文地址:https://www.cnblogs.com/vitan/p/10094836.html