Answered step by step
Verified Expert Solution
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
LAB: Creating simple linear regression models
The nbaalleloslr dataset contains information on NBA games between and 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 eloi 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, is used instead of the output is:
The intercept of the linear regression line is
The slope of the linear regression line is
The proportion of variation explained by the linear regression model is
LAB
ACTIVITY
: LAB: Creating simple linear regression models
main.py
Load default template...
# Import the necessary modules
import pandas as pd
import numpy as
from sklearn.linearmodel import LinearRegression
# Read in nbaalleloslrcsv
nba# Your code here
# Create a new column in the data frame that is the difference between pts and opppts
nbay #Your code here
# Store relevant columns as variables
# Your code here
# Your code here
# Initialize the Linear regression model
SLRModel # Your code here
# Fit the model on and
# 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
printf score
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