visualization.py 文件源码

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

项目:Default-Credit-Card-Prediction 作者: AlexPnt 项目源码 文件源码
def visualize_hist_pairplot(X,y,selected_feature1,selected_feature2,features,diag_kind):
    """
    Visualize the pairwise relationships (Histograms and Density Funcions) between classes and respective attributes

    Keyword arguments:
    X -- The feature vectors
    y -- The target vector
    selected_feature1 - First feature
    selected_feature1 - Second feature
    diag_kind -- Type of plot in the diagonal (Histogram or Density Function)
    """

    #create data
    joint_data=np.column_stack((X,y))
    column_names=features

    #create dataframe
    df=pd.DataFrame(data=joint_data,columns=column_names)

    #plot
    palette = sea.hls_palette()
    splot=sea.pairplot(df, hue="Y", palette={0:palette[2],1:palette[0]},vars=[selected_feature1,selected_feature2],diag_kind=diag_kind)
    splot.fig.suptitle('Pairwise relationship: '+selected_feature1+" vs "+selected_feature2)
    splot.set(xticklabels=[])
    # plt.subplots_adjust(right=0.94, top=0.94)

    #save fig
    output_dir = "img"
    save_fig(output_dir,'{}/{}_{}_hist_pairplot.png'.format(output_dir,selected_feature1,selected_feature2))
    # plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号