如何从列车中提取计算出的精度"宾语?

时间:2014-07-22 15:39:24

标签: r

请考虑以下示例数据测试

z   a   b   c
0   1   40  185
0   1   25  128
0   0   32  100
0   0   29  100
1   1   30  107
0   0   30  133
1   1   38  132
1   1   37  127
1   0   30  184
1   0   40  199
1   1   26  185
0   1   21  185
0   0   21  134
0   0   20  137
1   1   22  135
0   0   23  189
1   0   32  109
1   0   31  152
1   0   38  130
1   1   37  191
0   1   39  168
1   0   28  183
0   1   26  171
1   1   23  164
0   1   32  111
0   0   34  131
1   0   30  121
1   0   27  195
1   1   29  117
1   0   26  187
1   0   34  183
0   0   28  189
0   1   34  150
0   1   34  176
0   1   24  140
1   0   37  181
0   1   36  109
1   0   39  198
0   0   32  164

我想使用结果变量z和预测变量a,b,c执行逻辑回归。

以下是代码:

library(caret)
set.seed(825)
fitControl <- trainControl(method= "repeatedcv", number=10, repeats=10)
logitex <- train(z~ a+b+c, data=test, method="glm", trControl = fitControl)
logitex


set.seed(825)
fitControl2 <- trainControl(method= "cv", number=10)
logitex2 <- train(z~ a+b+c, data=test, method="glm", trControl = fitControl2)
logitex2

第一个代码块的输出是:

广义线性模型

39 samples
 3 predictors
 2 classes: '0', '1' 

No pre-processing
Resampling: Cross-Validated (10 fold, repeated 10 times) 

Summary of sample sizes: 35, 35, 35, 36, 35, 35, ... 

Resampling results

  Accuracy  Kappa  Accuracy SD  Kappa SD
  0.521     0.042  0.239        0.48    

第二段代码的输出是:

Generalized Linear Model 

39 samples
 3 predictors
 2 classes: '0', '1' 

No pre-processing
Resampling: Cross-Validated (10 fold) 

Summary of sample sizes: 35, 35, 35, 36, 35, 35, ... 

Resampling results

  Accuracy  Kappa  Accuracy SD  Kappa SD
  0.458     -0.1   0.189        0.394   

第一个代码块的输出不应该有10行(每行有精度,kappa等)吗?请注意,z是一个因素。

以下是数据的结构:

 'data.frame':   39 obs. of  4 variables:
 $ z: Factor w/ 2 levels "0","1": 1 1 1 1 2 1 2 2 2 2 ...
 $ a: Factor w/ 2 levels "0","1": 2 2 1 1 2 1 2 2 1 1 ...
 $ b: int  40 25 32 29 30 30 38 37 30 40 ...
 $ c: int  185 128 100 100 107 133 132 127 184 199 ...

0 个答案:

没有答案