python - seaborn的coefplot函数抛出错误
问题描述
我正在尝试使用 seaborn 的coefplot
功能,但它没有显示输出。相反,我收到一个错误:
AttributeError:模块“seaborn”没有属性“coefplot”。
myresultsmyresult .env_corr(env_vars)
def env_corr(self, env_vars, coeff_plot=False, qq_plot=False):
"""
Determine correlations with environmental/non-discretionary variables
using a logit regression. Tobit will be implemented when available
upstream in statsmodels.
Takes:
env_vars: A pandas dataframe of environmental variables
Returns:
corr_mod: the statsmodels' model instance containing the inputs
and results from the logit model.
Note that there can be no spaces in the variables' names.
"""
import matplotlib.pyplot as plt
from statsmodels.regression.linear_model import OLS
from statsmodels.graphics.gofplots import qqplot
import seaborn as sns
env_data = _to_dataframe(env_vars)
corr_data = env_data.join(self['Efficiency'])
corr_mod = OLS.from_formula(
"Efficiency ~ " + " + ".join(env_vars.columns), corr_data)
corr_res = corr_mod.fit()
#plot coeffs
if coeff_plot:
coefplot("Efficiency ~ " + " + ".join(env_vars.columns),
data=corr_data)
plt.xticks(rotation=45, ha='right')
plt.title('Regression coefficients and standard errors')
#plot qq of residuals
if qq_plot:
qqplot(corr_res.resid, line='s')
plt.title('Distribution of residuals')
print(corr_res.summary())
return corr_res
请帮忙。
解决方案
我相信 seaborn 的 coefplot 功能已经在 0.8.0 版本(2017 年 7 月)正式弃用
请参考以下链接:
https://seaborn.pydata.org/whatsnew.html
谢谢!
推荐阅读
- rust - 在短值中使用多个字母
- kotlin - kotlin REPL 中的粘贴模式/多行代码段?
- swift - MLModel 风格迁移预测。比例效果(笔触)
- python - 这个回文算法的时间复杂度是多少?
- entity-framework-core - EF Core 中按 ID 和类型的关系
- html - Bootstrap v5:列元素在较小的屏幕上变得更远?
- javascript - 如何使用:JavaScript Canvas 中多个对象的 globalCompositeOperation
- python - 在python中遍历数组元素的更优雅和简单的方法?
- laravel - 如何添加 saml:创建 LightSAML IDP 响应时的 XML 前缀
- python - 检查 10 个 GCS 存储桶中的文件