# How get correct prediction in Generalized Additive Model?

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?

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.

• 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. Sep 8, 2020 at 18:41
• @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.
– Dave
Sep 8, 2020 at 19:44
• @Dave +1 Was just about to respond similarly Sep 8, 2020 at 19:54
• It would help if I included the link... stats.stackexchange.com/questions/464636/…
– Dave
Sep 8, 2020 at 19:56
• Perfect I get it, thank you very much for this tip !! Sep 8, 2020 at 20:59