【发布时间】:2019-07-27 15:37:25
【问题描述】:
分数输出正常,但绘制不正确 - 我需要在代码中添加另一个参数吗?
代码和分数输出如下。
library(caret)
#GENERALISED LINEAR MODEL
LR_swim <- lm(racetime_mins ~ event_date+ event_month +year +event_id +
gender + distance_new + New_Condition+
raceNo_Updated +
handicap_mins +points+
Wind_Speed_knots+
Air_Temp_Celsius +Water_Temp_Celsius +Wave_Height_m,
data = SwimmingTrain)
family=gaussian(link = "identity")
varImp2<-varImp(object=LR_swim)
plot(varImp2,main="Variable Importance")
总体 event_date 24.463358 event_month 22.358448 年 24.399390 event_id 26.878342 性别女性 30.422470 性别男 13.273062 distance_new 248.727351 New_Condition 22.574999 raceNo_Updated 9.812053 handicap_mins 134.914137 点数 40.443116 Wind_Speed_knots 14.492203 Air_Temp_Celsius 16.562194 Water_Temp_Celsius 2.861662 Wave_Height_m 8.592716
#ClassOutput
class(varImp2)
[1] "data.frame"
#HeadOutput
> head(varImp2)
Overall
event_date 24.46336
event_month 22.35845
year 24.39939
event_id 26.87834
genderfemale 30.42247
gendermale 13.27306
我的样子;
应该是这样的
【问题讨论】:
-
您可以在问题中添加
class(vaImp2)和head(varImp2)吗?所以我们可以看到vaImp2的格式和类型。 -
@maydin 添加在上面!
-
你试过
plot(varImp2[,1],main="Variable Importance")吗? -
我添加了我的情节现在的样子,我正在寻找的是 y 轴上的变量和 x 上的重要性分数
-
您的数据集中只有一列称为“总体”...所以我不知道另一列是什么?是否要将行名用作 x 值,即使它们是字符?