Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We will continue the analysis started in Problem 4 by calculating the r - squared score for our predictions. The first step in this process
We will continue the analysis started in Problem by calculating the rsquared score for our predictions. The
first step in this process in to calculate the mean of the observed values.
Complete the following steps in a single code cell:
Use the map transformation along with a lambda function to select the first element of each tuple
in the pairs RDD Call the mean method of the resulting RDD storing the result in a variable
named mean.
Print mean.
Note that this calculation might take a couple of minutes to complete.
We will now calculate the sum of the squared deviations between each observed value and their mean. This
quantity is sometimes referred to as SST or total sum of squared deviations
Complete the following steps in a single code cell:
Use the map transformation along with a lambda function to calculate the square of the difference
between each observed value in pairs and mean. Call the sum method of the resulting RDD
storing the result in a variable named SST
Print SST
We will now calculate the rsquared score for the predictions. The formula for this value is given as follow:
Complete the following steps in a single code cell:
Use SSE and SST to calculate rsquared, storing the result in a variable named r
Print r
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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