在 R 中进行逻辑回归时,我使用带有 family = 'binomial' 的 glm 实现了 68% 的准确度。我不知道如何通过我的代码指定迭代次数。有什么建议吗?随机梯度下降的应用是否适用于 epoch。如果是这样,我如何在我的代码中应用它?我想提高模型的准确性。以下是我的代码:
rm(list=ls())
library(dplyr)
data1 <- read.csv("~/hj.csv", head`enter preformatted text here`er=T)
train<- data1[1:116,]
VALUE<-as.numeric(rownames(train))
testset<- data1[1:116,]
mylogit <- glm(VALUE ~ POINT1 + POINT2 + POINT3 + POINT4 , data = data1, family ="binomial")
testset$predicted.value = predict(mylogit, newdata = testset, type="response")
for (i in 1: nrow(testset)){
if(testset$predicted.value[i] <= 0.50)
testset$outcome[i] <- 0
else testset$outcome[i] <- 1
}
print(testset)
tab = table(testset$VALUE, testset$outcome) %>% as.matrix.data.frame()
accuracy = sum(diag(tab))/sum(tab)
print(accuracy)
print(tab)
table(testset$VALUE, testset$outcome)
