赞
踩
链接:https://pan.baidu.com/s/1deECYRPQFx8h28BvoZcbWw?pwd=ft5a
提取码:ft5a
--来自百度网盘超级会员V1的分享
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
data= pd.read_csv("boston.csv")
data.head()
x ,r = data[data.columns.delete(-1)], data['MEDV']
x_train, x_test, r_train, r_test = train_test_split(x, r, test_size=0.2, random_state=888)
print(x_train.shape,r_train.shape)
print(x_test.shape,r_test.shape)
#(404, 13) (404,)
#(102, 13) (102,)
linear_model = LinearRegression()
linear_model.fit(x_train, r_train)
line_pre = linear_model.predict(x_test)
print('SCORE:{:.4f}'.format(linear_model.score(x_test, r_test)))
#SCORE:0.7559
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。