I have data that consists of discrimination Between Two Species of Microtus using both Classified and Unclassified Observations
I built a logistic model from the 89 specimens that I used to predict the group membership of the remaining 199 specimen’s
a sample of my data
Group M1 M2 Fora Phone len height Rost
1 multiplex 2078 1649 1708 3868 5463 2355 805
2 subterraneus 1749 1482 1462 3797 4855 2218 765
3 unknown 1841 1562 1585 3750 5024 2232 821
I split the data into 89 observation to train my model and kept 199 unknown observations to be predicted
train.data = microtus[c(1:89),c(1:9)]
test.data = microtus[c(90:288),c(1:9)]
train.data$Group =ifelse(train.data$Group=="multiplex", 1, 0)
My Model
model <- glm(Group ~ M1Left + M3Left + Foramen + Length + Height,
family = binomial(), data = train.data)
summary(model)
Predictions
pred <- predict(model, test.data, type = "response")
I built a confusion matrix
createConfusionMatrix=function(actual, preds){
predClass=ifelse(preds<0.5, 0, 1)
table(actual,predClass)
}
## Confusion matrix
createConfusionMatrix(test.data$Group,pred)
my output
predClass
actual 0 1
multiplex 0 0
subterraneus 0 0
unknown 70 129
This output does not seem right to me?
Can I get help on how to build a confusion matrix?