Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete with Python programming in areas where ### ENTER CODE HERE ### []: # common imports import numpy as np import pandas as pd #

Complete with Python programming in areas where ### ENTER CODE HERE ###

image text in transcribedimage text in transcribedimage text in transcribed

[]: \# common imports import numpy as np import pandas as pd \# Do not change these options; This allows the CodeGrade auto grading to function correctly pd.set_option("display.max_columns', None) import warnings warnings.filterwarnings('ignore') Next you should place the data file called JohnnypiesData.csv and this Jupyter notebook in the same directory. Use the read_csv() function to read in the data from the comma-separated values (csv) file to a Pandas DataFrame called pie_df and output the data to take a look. In [ ]: fileName = "JohnnyPiesData.csv" \#\#\# ENTER CODE HERE \#\# Prepare Data for Linear Regression - Drop the Example column from the pie_df DataFrame, because it offers no information. - Encode all categorical data into numeric data via the "One Hot Encoding" technique provided by the Pandas get dummies() function. - Since we are performing ordinary least squares linear regression, we will want to drop one of the newly created Boolean-valued features (output from the get_dummies() function) to prevent introducing unwanted correlation in the data. Include drop_first = True as an argument to the get_dummies() function. - Store the final features in a DataFrame called features. The one-hot-encoded columns must go in the same order as the original data so that the linear regression coefficients match what codeGrade is expecting. - Store the positive class labels in a DataFrame called response. The response data must be a DataFrame and not a Series or some of the code towards the end of this notebook may not function correctly and your output might be slightly different than what codeGrade is expecting. Note: Since we are not concerned with generalization error in this assignment, we will not split our data into training and test sets. In 'real-world' projects, you would want to split your data to see how your model performs with data that it has never seen before. \#\# ENTER COOE HERE \#\#\# \# You may create more cells throughout as needed, \# but your final submission must be neat and concise Perfrom Linear Regression Model Fitting 1. Import the LinearRegression class from the sklearn.linear_model library. 2. Instantiate an object of the LinearRegression class called reg_model. 3. Train the model by invoking the fit() method of the reg_model object and passing it features and response. Examine Linear Regression Model Parameters View the trained model parameters by using the coef__ and intercept_ attributes of the trained model. Making Predictions Using the Linear Regression Model Evaluate the model's performance on the training data set by invoking the predict() method and passing features to it. Save this output as preds. [ ]: \#\# ENTER CODE HERE \#\# Below are the results from the linear regression model: The column "Class_pos" regards the "positive" or negative classification of the pie. The column "Regression_Predictions" regards the predictions made by the linear regression model directly. The column "Predicted_Responses" are the adjusted prdeictions made by the model after employing the cut-off values of 0 being 00.5 else for reg_output in reg_outputs ]) resp_comp - resp_comp.assign(Regression_Predictions = reg_outputs) resp_comp = resp_comp.assign(Predicted_Responses = predicted_resp) resp_comp Calculate Model Accuracy Use the accuracy_score() function to calculate the accuracy score of the model. Save the accuracy score as acc_score . [ ] : \#\# ENTER CODE HERE \#\#\#

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago