Question: Exploratory Data Analysis (EDA) often involves looking for relationships between features in a dataset. Using the following dataset of university features: tuition = [52000, 48000,

Exploratory Data Analysis (EDA) often involves looking for relationships between features in a dataset. Using the following dataset of university features: tuition = [52000, 48000, 50000, 40000] grad_rate = [95, 90, 92, 85] faculty_ratio = [7, 9, 8, 10]Write a Python function to compute the correlation between tuition and graduation rate using the following formula for Pearson correlation: r = P(xi x)(yi y) pP(xi x) 2 pP(yi y) 2 Where x is the mean of the first variable and y is the mean of the second variable. Hint: Here's how you might calculate the correlation: def mean ( data ) : return sum ( data ) / len ( data ) def correlation (x , y ) : x_mean = mean ( x ) y_mean = mean ( y ) numerator = sum (( x_i - x_mean ) * ( y_i - y_mean ) for x_i , y_i in zip (x , y ) ) denominator_x = sum (( x_i - x_mean ) ** 2 for x_i in x ) denominator_y = sum (( y_i - y_mean ) ** 2 for y_i in y ) return numerator / ( denominator_x ** 0.5 * denominator_y ** 0.5)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!