Using the csv file nbaallelo.csv and the Logistic Regression function, construct a logistic regression model to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using the csv file nbaallelo.csv and the Logistic Regression 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 and evaluate the model. Read in the file nbaaello.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 Logistic Regression function to construct a logistic regression model with wins as the target and elo_i as the predictor. Use the test set to predict the wins from the elo_i score. Construct and print the confusion matrix. Calculate and print the sensitivity. Calculate and print the specificity. Ex: If the feature pts is used as the predictor, rather than elo_i, the output is: Ex: If the feature pts is used as the predictor, rather than elo_i, the output is: confusion matrix is [[12220 6730] [ 6530 12415]] Sensitivity is 0.6448548812664907 Specificity is 0.6553180258643442 main.py (default template) # import the necessary libraries # load nbaallelo.csv into a dataframe df = # code to load csv file # Converts the feature "game_result" to a binary feature and adds as new column "wins" wins = df.game_result == "W" ["game_result"]) bool_val = wins = wins_new = df_final == np.multiply(wins, 1) pd.DataFrame(bool_val, columns = pd.concat([df, wins_new], axis=1) wins.rename(columns = {"game_result": "wins"}) # split the data df_final into training and test sets with a test size of 0.3 and random_state train, test = #23 code to split df_final into training and test sets = 0 # build the logistic model using the Logistic Regression function with wins as the target variable and elo_i as the predictor. # use the test set to predict the wins from the elo_i score predictions = # code to predict wins # generate confusion matrix conf = # code to generate confusion matrix print("confusion matrix is ", conf) # calculate the sensitivity sens = # code to calculate the sensitivity print("Sensitivity is ", sens) # calculate the specificity spec = # code to calculate the specificity print ("Specificity is ", spec) Using the csv file nbaallelo.csv and the Logistic Regression 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 and evaluate the model. Read in the file nbaaello.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 Logistic Regression function to construct a logistic regression model with wins as the target and elo_i as the predictor. Use the test set to predict the wins from the elo_i score. Construct and print the confusion matrix. Calculate and print the sensitivity. Calculate and print the specificity. Ex: If the feature pts is used as the predictor, rather than elo_i, the output is: Ex: If the feature pts is used as the predictor, rather than elo_i, the output is: confusion matrix is [[12220 6730] [ 6530 12415]] Sensitivity is 0.6448548812664907 Specificity is 0.6553180258643442 main.py (default template) # import the necessary libraries # load nbaallelo.csv into a dataframe df = # code to load csv file # Converts the feature "game_result" to a binary feature and adds as new column "wins" wins = df.game_result == "W" ["game_result"]) bool_val = wins = wins_new = df_final == np.multiply(wins, 1) pd.DataFrame(bool_val, columns = pd.concat([df, wins_new], axis=1) wins.rename(columns = {"game_result": "wins"}) # split the data df_final into training and test sets with a test size of 0.3 and random_state train, test = #23 code to split df_final into training and test sets = 0 # build the logistic model using the Logistic Regression function with wins as the target variable and elo_i as the predictor. # use the test set to predict the wins from the elo_i score predictions = # code to predict wins # generate confusion matrix conf = # code to generate confusion matrix print("confusion matrix is ", conf) # calculate the sensitivity sens = # code to calculate the sensitivity print("Sensitivity is ", sens) # calculate the specificity spec = # code to calculate the specificity print ("Specificity is ", spec)
Expert Answer:
Related Book For
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe
Posted Date:
Students also viewed these operating system questions
-
Using the csv file nbaallelo.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...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Governmental Funds Statement of Revenues Expenditures and Changes in Fund Balance. You have recently started working as the controller for a small county. The county is preparing its financial...
-
A monopolist's marginal cost curve has shifted upward. What is likely to happen to the monopolist's price, output rate, and economic profits?
-
Michael is single and 35 years old. He is a participant in his employers sponsored retirement plan. How much can Michael contribute to a Roth IRA in 2020 in each of the following alternative...
-
Draw a cash flow diagram of any investment that exhibits both of the following properties: 1. The investment has a 4-year life. 2. The investment has a 10 percent/year internal rate of return.
-
Gordon is the only limited partner in Bushmill Ventures, a limited partnership whose general partners are Daniels and McKenna. Gordon contributed $10,000 for his limited partnership interest and...
-
Calibash, Inc. is a large employer, who has decided to implement employee achievement awards through a non-qualified plan. They have 10 employees, and will distribute $50,000 amongst the 10 of them....
-
1. As a CEO, you have to know the four basic activities that comprise the management process. How are they related to one another? Do you think formal management education help to understand and...
-
Suppose the monetary policy curve is given by r = 1.5 + 0.75, and the IS curve is given by Y = 13 r. a) Find the expression for the aggregate demand curve. b) Calculate aggregate output when the...
-
On 2 January 20x1, P Ltd paid $316,000 to acquire 160,000 ordinary shares (issued at $1 per share) in SA Ltd. At that point, SA Ltds retained earnings were $100,000. SA Ltd had an issued share...
-
What is an asset-backed security?
-
What is the distinguishing characteristic of municipal bonds?
-
List four different kinds of securities issued by the U.S. Treasury.
-
Two solid steel shafts. each of 30mm diameter, are connected by the gears shown. Knowing that G = 77 GPa. determine the angle through which end A rotates when a torque of magnitude T. 200 N m is...
-
KD Insurance Company specializes in term life insurance contracts. Cash collection experience shows that 20 percent of billed premiums are collected in the month before they are due, 60 percent are...
-
See how sensitive the results in Example 16.2 are to the following changes. For each part, make the change indicated, run the simulation, and comment on any differences between your outputs and the...
-
Consider a large population of shoppers, each of whom spends a certain amount during his or her current shopping trip; the distribution of these amounts is normally distributed with mean $55 and...
-
Solve the previous problem using the input data in the file P14_50.xlsx. In the capital budgeting model in Figure 14.40, we supplied the NPV for each investment. Suppose instead that you are given...
-
Discuss two estate planning objectives revealed in Hinkles discussion with Enlow. Enlow wants to transfer some of his wealth to his niece and nephew but isnt sure whether he should use lifetime gifts...
-
Recommend a strategy, alternative to an outright sale of the shares, that will satisfy Omos goals and alleviate his concern. Tesando Omo is a highly successful entrepreneur. The software company that...
-
Which of Boulders observations regarding Maglavs pension plan is correct? A. Only Observation 1 B. Only Observation 2 C. Both Observation 1 and Observation 2 William Azarov is a portfolio manager for...
Study smarter with the SolutionInn App