zoukankan      html  css  js  c++  java
  • seaborn回归图---回归模型图Implot、线性回归图regplot、线性回归残差图residplot

    回归图只要探讨两连续数值变量的变化趋势情况,绘制x-y的散点图和回归曲线。

    1.lmplot

    seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=None, height=5, aspect=1, markers='o', sharex=True, sharey=True, hue_order=None, col_order=None, row_order=None, legend=True, legend_out=True, x_estimator=None, x_bins=None, x_ci='ci', scatter=True, fit_reg=True, ci=95, n_boot=1000, units=None, order=1, logistic=False, lowess=False, robust=False, logx=False, x_partial=None, y_partial=None, truncate=False, x_jitter=None, y_jitter=None, scatter_kws=None, line_kws=None, size=None)
    • seaborn.lmplot
    • lmplot 同样是用于绘制回归图,但 lmplot 支持引入第三维度进行对比,例如我们设置 hue="species"

    举例:

    sns.lmplot(x="sepal_length", y="sepal_width", hue="species", data=iris)

    2.regplot

    seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatter=True, fit_reg=True, ci=95, n_boot=1000, units=None, order=1, logistic=False, lowess=False, robust=False, logx=False, x_partial=None, y_partial=None, truncate=False, dropna=True, x_jitter=None, y_jitter=None, label=None, color=None, marker='o', scatter_kws=None, line_kws=None, ax=None)

    功能:用线性回归模型对数据做拟合

    • seaborn.regplot
    • regplot 绘制回归图时,只需要指定自变量和因变量即可,regplot 会自动完成线性回归拟合。

    举例:

    sns.regplot(x="sepal_length", y="sepal_width", data=iris)

    3.residplot

    seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None, order=1, robust=False, dropna=True, label=None, color=None, scatter_kws=None, line_kws=None, ax=None)

    功能:展示线性回归模型拟合后各点对应的残值

    举例:可以对以年为单位的地震记录作线性回归拟合。以下两张图分别对应一阶线性回归拟合、拟合后残值分布情况图。

    plt.figure(figsize=(12,6))
    plt.subplot(121) 
    sns.regplot(x="Year", y="ID",
    data=temp,order=1) # default by 1plt.ylabel(' ')
    plt.title('Regression fit of earthquake records by year,order = 1')
     
    plt.subplot(122)
    sns.residplot(x="Year", y="ID",
    data=temp)
    plt.ylabel(' ')
    plt.title('Residual plot when using a simplt regression
    model,order=1')
    plt.show()
  • 相关阅读:
    全链路压测(4):全链路压测的价值是什么?
    基于SVN的版本范围汇总
    一篇值得思考的职业教育之路!
    分享35个讨人喜欢的漂亮进度条UI设计
    转一篇难得的好文章CPU流水线的探秘之旅
    超棒的获奖动物摄影作品集
    解决web.py在SAE云中的Session使用问题
    2012年度最新免费web开发设计资源荟萃
    Endless icon: 每天都更新的图标集
    不容错过的超棒Javascript日期处理类库Moment.js
  • 原文地址:https://www.cnblogs.com/nxf-rabbit75/p/12098549.html
Copyright © 2011-2022 走看看