Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

kindly help check this code data file is task1.csv def gen_pearson(data): data= ['task1.csv'] col_names = data [0] #create list of tuples of pairs of columns

kindly help check this code data file is task1.csv

def gen_pearson(data): data= ['task1.csv'] col_names = data [0] #create list of tuples of pairs of columns col_pairs = [(col_names[i], col_names[j]) for i in range(len(col_names)) for j in range (i+1, len(col_names))] #calculate pearson correlation coefficient for each pair columns coefficients = [] for pair in col_pairs: col_1 = [row[pair[0]] for row in data[1:]] col_2 = [row[pair[1]] for row in data[1:]]

coefficient = sum((a - mean_col_1) * (b - mean_col_2) for (a,b) in zip (col_1, col_2)) / len (col_1) stdev_x = (sum((a - mean_col_1) **2 for a in col_1)/len(col_1)) **0.5 stdev_y = (sum((b - mean_col_2) **2 for b in col_2)/len(col_2)) **0.5 pearson_result = cov/(stdev_x * stdev_y) print(pearson_result)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Show that lim(Arctan nx) = (/2)sgn x for x R.

Answered: 1 week ago

Question

Analyse the various techniques of training and learning.

Answered: 1 week ago