我想要进行self.getZipCodes(self.nextAddressIndexCallBack);
回归。在R上运行我的代码后,我得到以下错误:
出了点问题;缺少所有准确度指标值:
.col { flex: 0 1 19.4%; margin-right: .6%; }
这是我的代码:
logreg
编辑1:
我将状态更改为二进制(0和1),但仍然有一些错误。这是新代码:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :9 NA's :9
Error in train.default(x, y, weights = w, ...) : Stopping
In addition: There were 19 warnings (use warnings() to see them)
答案 0 :(得分:3)
只需要修复您的数据。逻辑回归 - 这是我假设你想要的,因为你调用了逻辑回归(logreg
)方法,如果你想要像logit那样的其他东西,那么整个问题就不在乎了模型,它永远不会给你错误 - 仅用于二进制变量和它不能理解1和2可以表示二进制数据。它需要文字0和1。
donner <- read.delim("http://web.as.uky.edu/statistics/users/pbreheny/760/data/donner.txt")
set.seed(1234)
library(caret)
donner$Age <- as.numeric(donner$Age)
donner$Status <- as.factor(donner$Status)
donner$Sex <- as.numeric(donner$Sex)
splitIndex <- createDataPartition(donner$Status, p = .80, list = FALSE, times = 1)
trainDF <- donner[splitIndex,]
testDF <- donner[-splitIndex,]
ctrl <- trainControl(method = "cv", number = 3)
donner$Status <- as.character(donner$Status)
donner$Status[!donner$Status == "Survived"] <- 0
donner$Status[donner$Status == "Survived"] <- 1
donner$Age_gr_mean <- 0
donner$Age_gr_mean[donner$Age_gr_mean > mean(donner$Age)] <- 1
donner$Age <- NULL
donner$Status <- as.numeric(donner$Status)
donner$Sex[donner$Sex == 2] <- 0
logregmodel <- train(Status ~ ., data = donner, method = "logreg", trControl = ctrl)
答案 1 :(得分:1)
我个人从未使用&#34; logreg&#34;方法。似乎有些线条也没用。这是我的建议使用&#34; glm&#34;作为一种方法。
## Data
donner <- read.delim("http://web.as.uky.edu/statistics/users/pbreheny/760/data/donner.txt")
set.seed(1234)
library(caret)
donner$Age <- as.numeric(donner$Age)
donner$Status <- as.factor(donner$Status)
donner$Sex <- as.numeric(donner$Sex)-1
splitIndex <- createDataPartition(donner$Status, p = .80, list = FALSE, times = 1)
trainDF <- donner[splitIndex,]
testDF <- donner[-splitIndex,]
ctrl <- trainControl(method = "cv", number = 3)
logregmodel <- train(Status ~ ., data = trainDF, method = "glm", family='binomial', trControl = ctrl)
summary(logregmodel)