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