regression_stealer.py 文件源码

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

项目:Steal-ML 作者: ftramer 项目源码 文件源码
def predict_probas(X, w, intercept, multinomial=True):
    """
    Predict probabilities for each class using either a multinomial or a
    one-vs-rest approach
    """

    #print X.shape
    #print w.shape
    #print intercept.shape

    p = safe_sparse_dot(X, w.T, dense_output=True) + intercept

    if multinomial:
        return softmax(p, copy=False)
    else:
        p = p.ravel() if p.shape[1] == 1 else p

        p *= -1
        np.exp(p, p)
        p += 1
        np.reciprocal(p, p)

        if p.ndim == 1:
            return np.vstack([1 - p, p]).T
        else:
            # OvR normalization, like LibLinear's predict_probability
            p /= p.sum(axis=1).reshape((p.shape[0], -1))
            return p
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号