Optimal link prediction with matrix logistic regression