Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this challenge, you'll calculate the Pearson's r test returning the correlation score and the p-value for two sets of variables. You'll use a preloaded
In this challenge, you'll calculate the Pearson's r test returning the correlation score and the p-value for two sets of variables. You'll use a preloaded DataFrame that contains information about medical costs in different regions of the country and across other demographics, including age, sex, BMI (body mass index), number of children, and smoker versus nonsmoker. For this challenge, you'li focus on the correlations between oge and chorges, and bmi and charges. Before you get started, you'll be introduced to a new Python concept to help you in this tasks assigning values to multiple variables at once. In Python, it's possible (and often very convenient) to assign values to multiple variables at once (on the same line of code). Consider the following code: a,b=5,10print(a)print(b) The above is equivalent to this code: a=5b=10print(a)print(b) The pearsonr method that you'll be using returns two values at once, so you'll need to assign them to two variables at once, just . like in the code above. 1. For the correlation between oge and charges, assign the test value to the variable results. 2. For the correlation between bmi and chorges, assign the test value to the variable and the p-value to ap. Print out both results. You'll notice that they both have significant p-values (less than 0.05). However, your results should show that age is more highly correlated with charges than bmi is. Interestingl
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started