Using R, I used logistic regression to predict a binary target variable. But using a rule like "$<50\%$ then $0$ and $\ge 50\%$ then $1$" feels arbitrary.
How can I do that with R? I mean compute a cutoff point according to my data.
Using R, I used logistic regression to predict a binary target variable. But using a rule like "$<50\%$ then $0$ and $\ge 50\%$ then $1$" feels arbitrary.
How can I do that with R? I mean compute a cutoff point according to my data.
That depends on what you mean by "optimal". You need to choose a loss function.
That said, as mentioned in the comments, logistic regression is a method for probabilistic classification rather than discrete classification, so if all you need as predicted output is a class, is logistic regression really what you want?