Question: # import the necessary modules female = int ( input ( ) ) age = float ( input ( ) ) economy = int (
# import the necessary modules
female intinput
age floatinput
economy intinput
delay floatinput
flights # read in the file InvisticoAirlineLRcsv
# remove missing data
flights.dropnaaxis inplace True
flights # recode the categorical variables Gender, Class, and satisfaction as dummy variables
X # create a new data frame from the variables GenderFemale, Age, ClassEco, and ArrivalDelayinMinutes, in that order.
X addconstantX
Y # set Y as the response variable satisfactionsatisfied
model # perform logistic regression on X and Y
ex # create an array with for the intercept, and the user input values female, age, economy, and delay
prediction # find the predicted probablility that a customer with the user input values is satisfied
printprediction LAB: Prediction with Logistic Regression
The file InvisticoAirlineLRcsv contains information from an airline using the alias Invistico Airline on customer satisfaction, as well as
details on each customer. The columns of interest are Gender, Age, Class, ArrivalDelayinMinutes, and satisfaction.
Read the file InvisticoAirlineLRcsv into a data frame.
Obtain user defined values female, age, economy, and delay.
Recode the categorical variables Gender, Class, and satisfaction into dummy variables.
Create a new data frame X from the predictor variables Genderfemale, Age, ClassEco, and ArrivalDelayinMinutes, in that order.
Create a response variable from the dummy variable satisfactionsatisfied.
Perform logistic regression on and
Use the user defined values to predict the probability that a customer with those values is satisfied.
Ex: If the input is the ouput is:
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
