Issue
This is my code about using correlation matrix in python:
import numpy as np
from sklearn.datasets import load_breast_cancer
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
data = {
's_name_supplier' : ['Tiki Trading', 'Tiki Trading', 'Phụ Kiện Store 76'],
's_is_best_price_guaranteed' : [1, 1, 0],
's_quantity_sold' : [22213, 5801, 8],
's_rating_average' : [4.7, 5, 4.8],
's_price_of_product' : [308000, 230000, 190000],
's_review_count_product' : [3041, 1540, 63],
's_repaid' : ['111', '111', '111'],
's_avg_rating_point' : [4.61, 4.49, 4.74],
's_review_count_supplier' : [2846008, 2846008, 75028],
's_total_follower' : [225730, 225730, 345],
's_year_participate' : [2017, 2017, 2020],
's_product_cancell_rate' : ['0', '0', '0'],
's_product_return_rate' : ['0', '0', '0'],
's_total_product_seller_detail' : [134302, 134302, 70000],
's_certificate' : ['None', 'None', 'None'],
's_complaint' : [2.0, 0.0, 2.8],
's_ppm_rate' : [0.0, 40.0, 0.0]
}
features = ['s_name_supplier', 's_is_best_price_guaranteed',
's_quantity_sold', 's_rating_average', 's_price_of_product',
's_review_count_product', 's_repaid', 's_avg_rating_point',
's_review_count_supplier', 's_total_follower', 's_year_participate',
's_product_cancell_rate', 's_product_return_rate', 's_certificate',
's_complaint', 's_ppm_rate'
]
df = pd.DataFrame(data, columns = features)
correlation_mat = df.corr()
sns.heatmap(correlation_mat, annot = True)
plt.title("Correlation matrix of Breast Cancer data", y=-1)
plt.xlabel("cell nucleus features")
plt.ylabel("cell nucleus features")
plt.show()
Then, output this code:
Expected: I want to get array by Python with name column of chart:
Example:
['s_is_best_price_guaranteed', 's_quantity_sold', 's_rating_average',
's_price_of_product', 's_review_count_product', 's_avg_rating_point',
's_review_count_supplier', 's_total_follower', 's_year_participate',
's_complaint', 's_ppm_rate']
I'm trying
array_column = sorted_pairs[abs(sorted_pairs) > 0.5]
print(array_column)
but it dosen't success
Please help me about this my problem. Thank you so much and love you!!!!
Solution
correlation_mat[correlation_mat>0.5].index.values
Answered By - aj7amigo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.