We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Artificial Intelligence
- Statistics and Machine Learning
- Correlation and Regression Lines - A Quick Recap #1
- Discussions
Correlation and Regression Lines - A Quick Recap #1
Correlation and Regression Lines - A Quick Recap #1
Sort by
recency
|
133 Discussions
|
Please Login in order to post a comment
“Interesting problem! Karl Pearson’s correlation really shows how data can uncover hidden relationships. I recently realized how similar concepts apply even outside of academics. For example, in home improvement projects like bathroom remodeling, we often analyze the correlation between budget, material quality, and customer satisfaction. By looking at patterns, we can predict which design choices will give the best long-term results.it’s fascinating how statistics tie into real-world projects too!
The tricky part with this one is keeping the calculation clean because the data has repeats. Once you plug it into the Pearson formula, the correlation actually comes out slightly negative, around -0.144. It shows that higher Physics scores don’t really align with higher History scores in this set.
Enter your code here. Read input from STDIN. Print output to STDOUT
I have submitted this code still getting compilation error physics_marks = [15,12,8,8,7,7,7,6,5,3] history_score = [10,25,17,11,13,17,20,13,9,15]
calculate correlation coefficient
x_avg = sum(physics_marks)/10 y_avg = sum(history_score)/10 corr_coeff_num = sum([(physics_marks[i] - x_avg)*(history_score[i]-y_avg) for i in range(10)]) corr_coeff_deno = (sum([(physics_marks[i]**2)for i in range(10)])*sum([(history_score[i]**2)for i in range(10)]))**0.5 correlation_coefficient = corr_coeff_num/corr_coeff_deno print(f"{correlation_coefficient:.3f}")
physics_marks = [15,12,8,8,7,7,7,6,5,3] history_score = [10,25,17,11,13,17,20,13,9,15]
calculate correlation coefficient
correlation_coefficient = np.corrcoef(physics_marks,history_score)[0,1]
x_avg = sum(physics_marks)/10 y_avg = sum(history_score)/10 corr_coeff_num = sum([(physics_marks[i] - x_avg)*(history_score[i]-y_avg) for i in range(10)]) corr_coeff_deno = (sum([(physics_marks[i]**2)for i in range(10)])*sum([(history_score[i]**2)for i in range(10)]))**0.5 correlation_coefficient = corr_coeff_num/corr_coeff_deno print(f"{correlation_coefficient:.3f}")
The problem statement is misleading. You are told that you are required to take the input from stdin (python3 -> input())
The sample also has strings at the begginng that need to be handled on input.
However the actual submission is passed by hardcoding the example data as numerical lists in the code which is not what the instructions state. There is no feedback on the submission either to see if stdin/inputs are even being provided in the submission test cases.