【问题标题】:How to Output Regression Table in Python Pandas如何在 Python Pandas 中输出回归表
【发布时间】:2020-10-19 11:28:52
【问题描述】:

如何添加回归表(包含 t 统计量、p 值、r^2 等的表)。我附上了我的一些代码的图片。

【问题讨论】:

标签: python pandas regression


【解决方案1】:

sklearn 是针对预测建模的,所以你不会得到你习惯的回归表。 Python 中 sklearn 的替代方法是 statsmodels

另见How to get a regression summary in Python scikit like R does?

【讨论】:

    【解决方案2】:

    我已经阅读了两种方式 statsmodel 和 classification_report

    统计模型

    import statsmodels.api as sm

    X = sm.add_constant(X.ravel())

    results = sm.OLS(y,x).fit()

    results.summary()

    分类报告

    from sklearn.metrics import classifiation_report

    y_preds = reg.predict(X_test)

    print(classification_report(y_test,y_preds)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-12
      • 2017-08-31
      • 2018-09-28
      • 2019-10-31
      • 2017-05-21
      • 2013-08-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多