Chapter 5 Exercicio aula 9
library(caret) library(MASS)
GET(“http://www.ime.usp.br/~jmsinger/MorettinSinger/inibina.xls”, write_disk(tf <- tempfile(fileext = “.xls”))) inibina <- read_excel(tf) str(inibina)
nrow(inibina) sum() inibina\(difinib = inibina\)inibpos - inibina\(inibpre inibina\)resposta = as.factor(inibina$resposta)
plot(inibina\(difinib ~ inibina\)resposta, ylim = c(0, 400) print(inibina, n = 32)
5.1 Hmisc::describe(inibina)
summary(inibina) sd(inibina$difinib)
modLogist01 = glm(resposta ~ difinib, family = binomial, data = inibina) summary(modLogist01)
predito = predict.glm(modLogist01, type = “response”) classPred = ifelse(predito>0.5, “positiva”, “negativa”) classPred = as.factor(classPred) confusionMatrix(classPred, inibina$resposta, positive = “positiva”)
modFisher01 = lda(resposta ~ difinib, data = inibina, prior = c(0.5, 0.5)) predito = predict(modFisher01) classPred = predito\(class confusionMatrix(classPred, inibina\)resposta, positive = “positiva”)
inibina\(resposta modBayes01 = lda(resposta ~ difinib, data = inibina, prior = c(0.65, 0.35)) predito = predict(modBayes01) classPred = predito\)class # table(classPred) confusionMatrix(classPred, inibina$resposta, positive = “positiva”)