Question: 8 . 9 LAB: Logistic regression using logit ( ) Using the csv file nbaallelo _ log . csv and the logit function, construct a
LAB: Logistic regression using logit
Using the csv file nbaallelologcsv and the logit function, construct a logistic regression model to classify whether a team will win or lose a
game based on the team's eloi score.
Read in the file nbaaellologcsv
The target feature will be converted from string to a binary feature by the provided code.
Split the data into percent training set and percent testing set. Set randomstate
Use the logit function to construct a logistic regression model with wins as the target and eloi as the predictor.
Print the coefficients of the model.
Ex: If the feature pts is used as the predictor, rather than eloi the output is:
Optimization terminated successfully.
Current function value:
Iterations
Intercept
pts
dtype: float
main.pyload nbaallelologcsv into a dataframe
df # code to load csv filewins dfgameresult W
boolval npmultiplywins
wins pdDataFrameboolval, columns gameresult"
winsnew wins.renamecolumns gameresult": "wins"
dffinal pdconcatdf winsnew axistrain test # code to split dffinal into training and test setslmmathrm # code to construct logistic model using the logit functionprint# code to return coefficients
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
