问题描述
我需要知道如何以自己可以生成预测概率的方式返回逻辑回归系数.
I need to know how to return the logistic regression coefficients in such a manner that I can generate the predicted probabilities myself.
我的代码如下:
lr = LogisticRegression()
lr.fit(training_data, binary_labels)
# Generate probabities automatically
predicted_probs = lr.predict_proba(binary_labels)
我假设lr.coeff_值将遵循典型的逻辑回归,因此我可以返回如下所示的预测概率:
I had assumed the lr.coeff_ values would follow typical logistic regression, so that I could return the predicted probabilities like this:
sigmoid( dot([val1, val2, offset], lr.coef_.T) )
但这不是适当的表述.有没有人具有从Scikit Learn LogisticRegression生成预测概率的正确格式?谢谢!
But this is not the appropriate formulation. Does anyone have the proper format for generating predicted probabilities from Scikit Learn LogisticRegression?Thanks!
推荐答案
看一下文档(),lr.coef _
take a look at the documentations (http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html), offset coefficient isn't stored by lr.coef_
尝试:
sigmoid( dot([val1, val2], lr.coef_) + lr.intercept_ )
这篇关于Scikit学习:Logistic回归模型系数:澄清度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!