我的逻辑回归模型的准确率达到了 68%。我想提高模型的准确性。如何在此代码中应用逐步回归以及它对我的模型有多大好处?我应该在我的代码中进行哪些更改以使我的数据集更加准确。我在下面附上了我的数据集。以下是我的代码:
library(dplyr)
data1 <- read.csv("~/hj.csv", header=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)
以下是我的数据集:链接 1:http ://www.filedropper.com/hj_2
