Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7 . 5 LAB: Creating simple linear regression models The nbaallelo _ slr dataset contains information on 1 2 6 3 1 5 NBA games

7.5 LAB: Creating simple linear regression models
The nbaallelo_slr dataset contains information on 126315 NBA games between 1947 and 2015. The columns report the points made
by one team, the Elo rating of that team coming into the game, the Elo rating of the team after the game, and the points made by the
opposing team. The Elo score measures the relative skill of teams in a league.
Load the dataset into a data frame.
Create a new column y in the data frame that is the difference between the points made by the two teams.
Use sklearn's LinearRegression () function to perform a simple linear regression on the y and elo_i columns.
Compute the proportion of variation explained by the linear regression using the LinearRegression object's score method.
Ex: If the Elo rating of the team after the game, elon, is used instead of eloi, the output is:
The intercept of the linear regression line is -59.135.
The slope of the linear regression line is 0.040.
The proportion of variation explained by the linear regression model is 0.111.
525076.2609636.q3zqy7
LAB
ACTIVITY
7.5.1: LAB: Creating simple linear regression models
main.py
Load default template...
# Import the necessary modules
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
# Read in nbaallelo_slr.csv
nba=# Your code here
# Create a new column in the data frame that is the difference between pts and opp_pts
nba['y']= #Your code here
# Store relevant columns as variables
x=# Your code here
y=# Your code here
# Initialize the Linear regression model
SLRModel =# Your code here
# Fit the model on x and y
# Your code here
# Print the intercept
intercept =# Your code here
print ('The intercept of the linear regression line is ', end="")
# Print the slope
slope = # Your code here
print ("The slope of the linear regression line is ", end="")
# Compute the proportion of variation explained by the linear regression using the LinearRegression object's score me
score = # Your code here
print ('The proportion of variation explained by the linear regression model is ', end="")
print('%.3f'% score +".")]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases 28th British National Conference On Databases Bncod 28 Manchester Uk July 2011 Revised Selected Papers Lncs 7051

Authors: Alvaro A.A. Fernandes ,Alasdair J.G. Gray ,Khalid Belhajjame

2011th Edition

3642245765, 978-3642245763

More Books

Students also viewed these Databases questions

Question

Factor by any method. 4z 2 + 28z + 49

Answered: 1 week ago

Question

Prepare and properly label figures and tables for written reports.

Answered: 1 week ago