Question: 8 . 9 LAB: Logistic regression using logit ( ) Using the csv file nbaallelo _ log . csv and the logit function, construct a

8.9 LAB: Logistic regression using logit()
Using the csv file nbaallelo_log.csv 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 elo_i score.
Read in the file nbaaello_log.csv.
The target feature will be converted from string to a binary feature by the provided code.
Split the data into 70 percent training set and 30 percent testing set. Set random_state =0.
Use the logit function to construct a logistic regression model with wins as the target and elo_i as the predictor.
Print the coefficients of the model.
Ex: If the feature pts is used as the predictor, rather than elo_i, the output is:
Optimization terminated successfully.
Current function value: 0.621201
Iterations 5
Intercept -5.908580
pts 0.057528
dtype: float64
main.pyload nbaallelo_log.csv into a dataframe
df = # code to load csv filewins = df.game_result =="W"
bool_val = np.multiply(wins,1)
wins = pd.DataFrame(bool_val, columns =["game_result"])
wins_new = wins.rename(columns ={"game_result": "wins"})
df_final = pd.concat([df, wins_new], axis=1)train, test = # code to split df_final into training and test setslm}=\mathrm{ # code to construct logistic model using the logit functionprint(# code to return coefficients)
8 . 9 LAB: Logistic regression using logit ( )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!