0
$\begingroup$

I am using the mgcv package in R. I trained a GAM, for a binary classification task, so I used binomial as a family. But when I run the predict method on the Test Set, I don't get 0 or 1 output, but numeric values. Why does mgcv provide these outputs? How do I get binary outputs?

$\endgroup$

1 Answer 1

1
$\begingroup$

The predictions are on the scale of the link function, in the form of log odds. Even if you changes the predictions to be on the response scale, the response scale is in terms of probability, bounded between 0 and 1. This is what the actual model you fitted, the expected probability of the event. This is unlike other class prediction tools like trees, which typically give back a predicted class (although in the case of trees, this class is often majority vote, so it includes some form of decision rule to output the 0 and 1 class).

You will need to come up with a decision rule to convert the probability of the event/feature into a binary prediction of either 0 or 1.

$\endgroup$
5
  • $\begingroup$ Perfect, thank you very much I understand !! So, for example, it will be enough for me to associate class 1 if the output probability is greater than 0.5, otherwise 0. $\endgroup$ Sep 8, 2020 at 18:41
  • 1
    $\begingroup$ @FrancescoLadogana Watch out for treating $0.5$ as the magic threshold. There are a number of posts on here about proper scoring rules. The accepted answer here has a good discussion, and the links in that answer (and the links in the linked pages, etc) are good reads. $\endgroup$
    – Dave
    Sep 8, 2020 at 19:44
  • $\begingroup$ @Dave +1 Was just about to respond similarly $\endgroup$ Sep 8, 2020 at 19:54
  • 1
    $\begingroup$ It would help if I included the link... stats.stackexchange.com/questions/464636/… $\endgroup$
    – Dave
    Sep 8, 2020 at 19:56
  • $\begingroup$ Perfect I get it, thank you very much for this tip !! $\endgroup$ Sep 8, 2020 at 20:59

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.