logistic regression in R, problem with output I am trying to  predict logistic regression. 
For instance
fit <- glm(TARGET~ x+y, data=trainData,family=binomial)

The data (TARGET) has a label of 0 and 1. 
I want to get an output of 0 and 1 from the prediction. 
if I run
predict(fit,ValData, type="response"), 
I can a bunch of 0.001 something like that. How do I get a binary output ? What is that 0.001 represent? (Probability of equal to 1 is 0.001?)
Thanks
 A: Yes, your output is the probability of the target variable being 1. See ?predict.glm.
If you want to output 0-1 predictions, you can simply use a threshold and label each predicted probability that exceeds this threshold as a predicted 1. A threshold of 0.5 is most often used, but it is not set in stone - a different one may yield a better tradeoff between errors of the two kinds.
However, I'd recommend you think about whether you really only want 0-1 predictions. This would lose all the information that one instance was only slightly above the threshold (prediction of 0.51) while another one was far above (prediction of 0.99). If possible, it's usually more enlightening to stay with predicted probabilitiy. (Plus, it allows you to assess your predictions' quality more finely, using scoring-rules or similar.)
A: As you said, predict(fit,ValData, type="response") will give you the probability of 1 for each case. If you want a 0-1 prediction, depending on your threshold you can use:
(predict(fit, ValData, type="response") > 0.5) * 1

That should give a 0 or 1 depending of the cut-off point (0.5 here).
