特征选择:Boston house prices 数据集分析(R 语言)

本文介绍了如何使用R语言进行特征选择。通过建立多元线性模型,选择显著性水平为0.001的特征,如average_room_number和lower_class_ratio。通过绘制图像探讨特征间潜在的关联,例如指数和多项式关系,并构建相关系数矩阵,发现average_room_number与lower_class_ratio高度相关。最终模型的R平方达到0.81,在测试集上预测的rsq值为0.834。
摘要由CSDN通过智能技术生成

How the choose the features?

怎样选择特征?

  • construct a multivariate linear model using all the provided features and choose those with 0.001 significance level(or 0.01, 0.05 significance level)
  • 使用所有的特征建立多元线性回归模型并且选择那些具有高显著性的特征
  • plotting the dependent variable vs each of the chosen features and explore the potential correlation (like logarithm, polynomial)
  • 绘制待预测变量与每一个选择的特征的图像并且探索图像中潜在的关系(如指数关系、n次多项式关系)
  • construct the covariance matrix and make an interaction of those with high correlation
  • 构建相关系数矩阵并且将相关性高的特征乘起来

General Implementation with R

R 语言实现

# import some necessary packages
library(haven) # used to load our data
library(texreg) # used to display fit info
library(dplyr) # used to manipulate data
library(tidyr) # used for the drop_na function
library(ggplot2) # in case we want to make ggplots
library(caTools)
library(MASS)
library(corrgram)
# import Boston dataset
boston_df <- Boston
# change the name of the columns
names(boston_df) <- c("crime", "zoned_bigger_25000", "non_retail_proportion","chas_river", "nitrogen_density", "average_room_number", "built_before_1940_ratio", "distance_to_centre", "ac
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值