tbs_plot.py 文件源码

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

项目:eezzy 作者: 3Blades 项目源码 文件源码
def factor_plot(dataFrame, factors, prediction, color="Set3"):
    # First, plot the total for each factor. Then, plot the total for each
    # factor for the prediction variable (so in a conversion example, how
    # many people converted, revenue per country, etc.)

    # These refer to the rows and columns of the axis numpy array; not the
    # data itself.

    row = 0
    column = 0
    sns.set(style="whitegrid")
    # TODO: Set the width based on the max number of unique
    # values for the factors.

    plots = plt.subplots(len(factors), 2, figsize=(8,12))
    # It should
    for factor in factors:
        sns.countplot(x=factor, palette="Set3", data=dataFrame,
                      ax=plots[1][row][column])
        # Then print the total for each prediction
        sns.barplot(x=factor, y=prediction, data=dataFrame,
        ax=plots[1][row][column+1])
        row += 1
    plt.tight_layout() # Need this or else plots will crash into each other
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号