def predict_proba(self, X):
"""
Returns the probability of class 1 for each x in X.
"""
try:
getattr(self, "intercept_")
getattr(self, "coef_")
except AttributeError:
raise RuntimeError("You must train classifer before predicting data!")
X = check_array(X)
if self.fit_intercept:
X = np.insert(X, 0, 1, axis=1)
w = np.insert(self.coef_, 0, self.intercept_)
return invlogit_vect(np.dot(w, np.transpose(X)))
评论列表
文章目录