机器学习-----构建房屋售价预测回归模型

启动graphlab create

import graphlab

读取一些房屋销售数据

sales = graphlab.SFrame('根据自己的目录读取home_data.gl文件')

graphlab.canvas.set_target('ipynb')   //设置画出的图像在ipython notebook中现实

sales.show(view = "Scatter Plot",x = "sqft_living",y = "price")  //设置散点图,以房屋价格和售价为X,Y轴来画图



train_data  数据集 

test_data  训练集

sales.random_split(0.8,seed=0)  随机切片和赋值给训练集和数据集,并确定比例为0.8


sqft_model = graphlab.linear_regression.create(train_data,target='price',features=['sqft_living'])

//调用graphlab的模块linear_regression.create构建数据回归模型以训练集为基准,目标值为价格(x),特征值为房屋面积(y)


最大误差:max_error  平均误差:rmse



求出斜率和标准差


猜你喜欢

转载自blog.csdn.net/fort110/article/details/79388899