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
|
115 Discussions
|
Please Login in order to post a comment
from scipy.stats import pearsonr https://temuapps.click/ Given data physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]
Calculate Pearson's correlation coefficient r, _ = pearsonr(physics_scores, history_scores)
Print the result formatted to three decimal places print(f"{r:.3f}")
from scipy.stats import pearsonr
Given data physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15] https://bestspickleball.com/
Calculate Pearson's correlation coefficient r, _ = pearsonr(physics_scores, history_scores)
Print the result formatted to three decimal places print(f"{r:.3f}")
from scipy.stats import pearsonr
Given data
physics_scores = [15, 12, 8, 8, 7, 7, 7, 6, 5, 3] history_scores = [10, 25, 17, 11, 13, 17, 20, 13, 9, 15]
Calculate Pearson's correlation coefficient
r, _ = pearsonr(physics_scores, history_scores)
Print the result formatted to three decimal places
print(f"{r:.3f}")
import numpy as np physics = np.array([15, 12, 8, 8, 7, 7, 7, 6, 5, 3]) history = np.array([10, 25, 17, 11, 13, 17, 20, 13, 9, 15])
n= len(physics) # num of pairs of score
calculate means
mean_physics = np.mean(physics) mean_history = np.mean(history)
calculate deviations
dev_physics = physics - mean_physics dev_history = history- mean_history
calculate the sum of product of deviations
sum_prod_dev = np.sum(dev_physics * dev_history)
calculate the sum of squared deviations
sq_dev_physics = np.sum(dev_physics**2) sq_dev_history = np.sum(dev_history**2)
calculate correlation coefficient
r = sum_prod_dev/ np.sqrt(sq_dev_physics * sq_dev_history)
print(f"Pearson's correlation coefficient: {r:.3f}")
I really just had to hardcode the input into my code to pass the testcases, I was wondering for over half an hour what was wrong with my code :')
There is no input from STDIN, you need to hardcode the input in yourcode. Misleading question.