0
$\begingroup$

I have a set of data, that gives the length of a species of abalone, and its corresponding type (male, M, female, F, or infant, I). (https://archive.ics.uci.edu/ml/datasets/abalone)

I have constructed a logistic regression to create a model that will determine whether the abalone is M/F or I, given the length. (M and F are classed as the same.)

So I write the following in R to generate and test the model on data points:

g <- glm(sex ~ length, family="binomial")
pairs <- paste(round(predict(g, type="response")), sex)
table(pairs)

The output table is:

pairs
0 F  0 I  0 M  1 F  1 I  1 M 
218    6  210 1089 1336 1318

How can I correctly interpret this?

These are the options I have come up with:

  1. 1089 females correctly identified, 218 females incorrectly identified; 1318 males correctly identified, 210 males incorrectly identified; 1336 infants correctly identified, 6 incorrectly identified.

  2. 218 females correctly identified, 6 infants and 210 males incorrectly identified; 1089 females incorrectly identified, 1336 infants and 1318 males incorrectly identified.

$\endgroup$
7
  • $\begingroup$ How come there are 3 values in your outcome when you are using Binomial? Generally Binomial is 1/0 or True/False or Yes/No. You have mentioned that Male and Female are same but you din't combine them together. Now these would be treated as 3 different levels in feature(Male/Female/Infant) then it would no more be Binomial. $\endgroup$
    – Toros91
    Nov 14 '17 at 5:03
  • $\begingroup$ @Toros91 should I use multinomial instead? Also, I thought that I could combine M and F once this table is obtained. So for example, 0F=218 and 0M=210 becomes 0FM=428. Is that not OK/ $\endgroup$
    – ODP
    Nov 14 '17 at 9:11
  • $\begingroup$ but that is wrong way of doing it and you will end up interpreting wrong insights. which is of no use. You need to combine them before giving them to the model. As you said, you to need to give multinomial if you have more than 2 factors in a feature $\endgroup$
    – Toros91
    Nov 14 '17 at 9:13
  • $\begingroup$ Thanks @Toros91 , I now converted all F to M, meaning that I can get an easily-interpreted binomial confusion matrix as above $\endgroup$
    – ODP
    Nov 14 '17 at 10:24
  • $\begingroup$ Your welcome!, do let me know if you have any additional questions. $\endgroup$
    – Toros91
    Nov 14 '17 at 10:26
2
$\begingroup$

The outcome of a multi-nomial or binomial is confusion matrix (2*2 for binomial, n*n for multinomial),

Interpretation of the confusion matrix is for example:

enter image description here

Accuracy of the model : ((TP + TN) / (TP + FN + FP + TN) ) * 100 It means you model could exactly pick this much percent of data was classified correctly.

Precision: (TP / (TP + FP))*100 That measure of correctness achieved in positive prediction i.e. of observations labeled as positive, how many are actually labeled positive

Recall: (TP / (TP + FN)) * 100 It is a measure of actual observations which are labeled (predicted) correctly i.e. how many observations of positive class are labeled correctly. It is also known as ‘Sensitivity’.

F-Measure: ((1 + β)² × Recall × Precision) / ( β² × Recall + Precision ) It combines precision and recall as a measure of effectiveness of classification in terms of ratio of weighted importance on either recall or precision as determined by β coefficient. generally β is 1.

If you want read them in just normal words in you example:

        Predicted  
          M   F
       M 100 150
actual F 100 300

It means your model could predict 100+300 correctly out of 100+150+100+300

Actual number of males where 250 but you could classify 100 correctly and 50 wrongly.

Similarly, Actual number of females where 400 but you could classify 300 correctly and 100 wrongly.

If you any need more detail let me know.

Go through this Link, you will get better idea. This Link is an interactive chart, which will give you better understanding.

$\endgroup$
2
  • $\begingroup$ So using the stuff you have explained I have a good 2x2 matrix for M and I, whereby M encapsulates both M and F. So now the binomial confusion matrix is clear and is: 0I(722), 0M(285), 1I(620), 1M(2550). Is this saying 722 'I' correctly predicted, or 620 'I' correctly predicted? I think the former but I am not 100% certain. $\endgroup$
    – ODP
    Nov 14 '17 at 10:28
  • 1
    $\begingroup$ It means that you have correctly predicted 722 infants and 2550 Male/Female. It would be sum of principal diagonal of the matrix. $\endgroup$
    – Toros91
    Nov 14 '17 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.