balance_preditctor.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:DSI-personal-reference-kit 作者: teb311 项目源码 文件源码
def plot_resid(model, x):
    '''
        Given a trained StatsModel linear regression model, plot the residual error
        in a scatter plot as well as a qqplot

        model: a trained StatsModel linear regression model.
        x: the input data which was used to train the model.

        returns: the figure upon which the residuals were drawn
    '''
    fig, ax_list = plt.subplots(1, 2)

    y_hat = model.predict(x)
    resid = model.outlier_test()['student_resid']

    ax_list[0].scatter(y_hat, resid, alpha=.2)
    ax_list[0].axhline(0, linestyle='--')
    sm.qqplot(resid, line='s', ax=ax_list[1])

    fig.tight_layout()
    return fig
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号