bounded_logistic.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pyAFM 作者: cmaclell 项目源码 文件源码
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))))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号