如何使用R预测kaggle房价竞争中的价格?

问题描述

我参加了kaggle竞赛:House Prices: Advanced Regression Techniques。 作为基准,我想创建线性回归。 首先,我清理数据。 其次,我只选择数字变量。

data_num<-data[sapply(data,function(x) is.numeric(x))]
train<-data_num[1:1460,]
test<-data_num[1461:nrow(data_num),]

然后我绘制直方图以查看SalePrice的分布。如我们所见,这里存在偏斜。

enter image description here

因此,我创建了log(SalePrice)。好多了

enter image description here

我的线性模型: 型号

model2<-lm(SalePrice~LotArea+OverallQual+OverallCond+YearBuilt+
             MasVnrArea+ExterQual+BsmtQual+BsmtCond+BsmtFinSF1+`1stFlrSF`+  
             `2ndFlrSF`+BsmtFullBath+BedroomAbvGr+KitchenAbvGr+KitchenQual+
             TotRmsAbvGrd+GarageCars+GarageCond+WoodDeckSF+ScreenPorch,train)
p<-predict(model2,test)

c<-cbind(price,p)


RMSE=sqrt(mean((log(p)-log(price$SalePrice))^2))

#RMSE 0.4215566

  1. 我有正确的战术吗?
  2. 使用日志我能预测什么?
  3. 如果我绘制geom_point log(实际)和log(预测),它看起来像这样

    enter image description here

    点为什么如此分散?

如果我使用随机森林来查找重要变量,则会得到以下信息:

enter image description here

对我来说,建立线性模型很重要。我想将其与更复杂的模型xgboost,套索和其他模型进行比较

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...