我有一个如下所示的数据框:
我已经应用了逻辑回归,我想在另一个数据框中获得 p 分数和 t 值
Algorithm Success
A 0.91
B 0.98
C 0.76
.
.
.
B 0.77
C 0.68
D 0.43
代码:
p1_logit_model=sm.MNLogit(group["Algorithm"], group["Success"].astype(float))
输出:
Results: MNLogit
===============================================================
Model: MNLogit Pseudo R-squared: 0.104
Dependent Variable: algorithm AIC: 184.2255
Date: 2018-12-18 17:19 BIC: 194.2622
No. Observations: 55 Log-Likelihood: -87.113
Df Model: 0 LL-Null: -97.227
Df Residuals: 50 LLR p-value: nan
Converged: 1.0000 Scale: 1.0000
No. Iterations: 9.0000
--------------------------------------------------------------
algorithm = 0 Coef. Std.Err. t P>|t| [0.025 0.975]
--------------------------------------------------------------
p1_less100ms 0.2326 0.5804 0.4008 0.6886 -0.9050 1.3702
--------------------------------------------------------------
algorithm = 1 Coef. Std.Err. t P>|t| [0.025 0.975]
--------------------------------------------------------------
p1_less100ms -6.3891 3.9519 -1.6167 0.1059 -14.1346 1.3565
我想将每个值的 p 值和 t 分数存储到算法中,有人可以帮助我吗?
最佳答案
我认为您需要首先拟合模型才能访问 p 值和 t 值。试试这个:
fit = p1_logit_model.fit()
print(fit.pvalues[i])
print(fit.tvalues[i])
其中 i
是您有兴趣从多项式模型中查看的任何类别的索引。提示,如果您确实希望使用逻辑回归模型,则应该使用 model = sm.Logit(y, X)
。
关于python - 打印逻辑回归中的 p 值 MNLogit(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53838507/