enter image description here我对数据科学和R语言还很陌生,所以请耐心等待我:)
我想要的是事后进行逻辑回归模型和混淆矩阵,但是我得到以下警告消息:
glm.fit:发生数字为0或1的拟合概率
我有14个解释变量和1个二进制目标变量用于信用审批(未批准0,已批准1)dataset structure
creditApproval <- read.table(file.choose(), header=TRUE)
summary(creditApproval)
dim(creditApproval)
str(creditApproval)
creditApproval$class <- as.factor(creditApproval$class)
### Setting seed for reproductability
set.seed(2567)
# Normalizing dataset
approvalNORM <- creditApproval
for(i in 1:length(colnames(creditApproval))-1) {
if(class(creditApproval[,i]) == "numeric" || class(creditApproval[,i]) == "integer")
{ minimum<-min(creditApproval[,i])
maximum<-max(creditApproval[,i])
approvalNORM[,i] <- as.vector(scale(creditApproval[,i],center=minimum,scale=maximum-minimum)) } }
summary(approvalNORM) # Normalization
# Logistic Regression
model <- glm(class ~., family=binomial(link='logit'), data=approvalNORM)
summary(model)