Plot correlation matrix using pandas

前端 未结 12 704
渐次进展
渐次进展 2020-11-30 16:23

I have a data set with huge number of features, so analysing the correlation matrix has become very difficult. I want to plot a correlation matrix which we get using d

12条回答
  •  渐次进展
    2020-11-30 16:54

    Form correlation matrix, in my case zdf is the dataframe which i need perform correlation matrix.

    corrMatrix =zdf.corr()
    corrMatrix.to_csv('sm_zscaled_correlation_matrix.csv');
    html = corrMatrix.style.background_gradient(cmap='RdBu').set_precision(2).render()
    
    # Writing the output to a html file.
    with open('test.html', 'w') as f:
       print('Document' + html+'', file=f)
    

    Then we can take screenshot. or convert html to an image file.

提交回复
热议问题