我开始预测名为“房价:高级回归技术”的初学者 kaggle 比赛。我的线性回归工作正常。直到岭回归给出了这个错误。
Error in enet(x = as.matrix(trainPredictors), y = trainClasses, lambda = 1e-04) :
Some of the columns of x have zero variance
我更喜欢清理后的数据称为 complete_data5.Rdata。代码可以在 model_ridge.r 中找到。文件可以在这里找到:https ://github.com/kennethng2017/HousingPrice
ridgeModel <- enet(x = as.matrix(trainPredictors), y = trainClasses,
lambda = 0.0001)
Error in enet(x = as.matrix(trainPredictors), y = trainClasses, lambda = 1e-04) :
Some of the columns of x have zero variance
trainPredictors 具有虚拟变量。
会话信息
sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.4
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reshape2_1.4.2 corrplot_0.77 dplyr_0.5.0 elasticnet_1.1
[5] lars_1.2 Metrics_0.1.2 doSNOW_1.0.14 snow_0.4-2
[9] iterators_1.0.8 foreach_1.4.3 caret_6.0-73 ggplot2_2.2.1
[13] lattice_0.20-34
loaded via a namespace (and not attached):
[1] Rcpp_0.12.10 compiler_3.3.3 nloptr_1.0.4 plyr_1.8.4
[5] tools_3.3.3 lme4_1.1-12 tibble_1.3.0 nlme_3.1-131
[9] gtable_0.2.0 mgcv_1.8-17 Matrix_1.2-8 DBI_0.6-1
[13] parallel_3.3.3 SparseM_1.76 stringr_1.2.0 MatrixModels_0.4-1
[17] stats4_3.3.3 grid_3.3.3 nnet_7.3-12 R6_2.2.0
[21] minqa_1.2.4 car_2.1-4 magrittr_1.5 scales_0.4.1
[25] codetools_0.2-15 ModelMetrics_1.1.0 MASS_7.3-45 splines_3.3.3
[29] assertthat_0.2.0 pbkrtest_0.4-7 colorspace_1.3-2 labeling_0.3
[33] quantreg_5.29 stringi_1.1.5 lazyeval_0.2.0 munsell_0.4.3
请随时提出任何问题。