房子的价格可能由【面积】【卧室数量】【是否装修】【朝向】等因素决定。
假设有这样的一些arff数据
@relation house
@attribute houseSize numeric
@attribute houseNumber numeric
@attribute houseDirection numeric
@attribute decoration numeric
@attribute sellingPrice numeric
@data
145,3,1,1,260
132,3,1,0,236
130,3,0,0,225
135,2,1,1,210
120,3,1,1,240
120,2,1,1,220
118,3,1,1,225
118,2,1,0,208
98,2,0,1,199
63,2,1,1,129
60,2,1,0,115
54,2,0,1,110
50,1,1,1,111
56,1,0,1,108
48,1,0,0,80
第一个房子的解释是145方,3个房间,南北向已装修,价格260万。
在weka中读入数据,可以看一看数据集的统计信息:
如卧室间数的最小值为1,最大值为3,平均值为2.133,标准差为0.743
-
模型选择:Classify→functions→LinearRegression(线性回归)
-
将之作为训练集:Test options→Using training set
-
需要预测的是房价:Test options的组合框→sellingPrice
-
开始建模:点击 Start
可以看到得到的模型结果是:
sellingPrice = 1.3915 * houseSize + 15.4595 * houseNumber + 12.3114 * decoration + 2.9818
也就是说110方,两卧南北朝向已装修的房子的预测价格应该是:
1.3915 * 110 + 15.4595 * 2 + 12.3114 * 1 + 2.9818 = 199.2772 万元
模型解释
-
每平方米对房屋价格的贡献为1.3915万元
-
每间房间对房屋价格的贡献为15.4595万元
-
装修与否对房屋价格的贡献为12.3114万元
-
房子的朝向对房屋价格没有关系
参考:《大学计算机案例实验教程——紧密结合学科需要》(教材) 南开大学公共计算机基础教学部