gpt4 book ai didi

python - Scikit 学习 : Logistic Regression model coefficients: Clarification

转载 作者:IT老高 更新时间:2023-10-28 20:41:33 26 4
gpt4 key购买 nike

我需要知道如何以我可以自己生成预测概率的方式返回逻辑回归系数。

我的代码如下所示:

lr = LogisticRegression()
lr.fit(training_data, binary_labels)

# Generate probabities automatically
predicted_probs = lr.predict_proba(binary_labels)

我假设 lr.coeff_ 值将遵循典型的逻辑回归,因此我可以返回这样的预测概率:

sigmoid( dot([val1, val2, offset], lr.coef_.T) )

但这不是恰当的表述。有没有人有从 Scikit Learn LogisticRegression 生成预测概率的正确格式?谢谢!

最佳答案

查看文档 (http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html),lr.coef_ 不存储偏移系数_

coef_ array, shape = [n_classes-1, n_features] Coefficient of the features in the decision function. coef_ is readonly property derived from raw_coef_ that follows the internal memory layout of liblinear. intercept_ array, shape = [n_classes-1] Intercept (a.k.a. bias) added to the decision function. It is available only when parameter intercept is set to True.

尝试:

sigmoid( dot([val1, val2], lr.coef_) + lr.intercept_ ) 

关于python - Scikit 学习 : Logistic Regression model coefficients: Clarification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18993867/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com