Question: What is wrong with my Python code? 4.10 LAB: Prediction with Logistic Regression The file Invistico Airitise,LR. Csv contains information from an aitine using the




4.10 LAB: Prediction with Logistic Regression The file Invistico Airitise,LR. Csv contains information from an aitine using the atias invistico Artine on custorner satisfaction as well as details on each customer. The columns of interest are Gender. Age, Class, Arrivat.Deloy in Minutes, and satisfaction - Read the file Invatico.Aurline.L. R. csvinto a data frame. - Obtain user defined values female, age, economy, and delay - Re-pode the categorical varables Gender, Class, arid satiafaction into dummy variables - Create a new data frame X from the predictor variables Gender female, Age. Class. Fco, and Aerival.Delay in Minumes, in that order. - Create a response variabie Y from the dummy variable natistaction iabisfied. - Perform logistic regression on X and Y. - Use the user defined values to predict the probability that a customer with those values is natisfied Ex if the input is 134010 the ouput is: [0,62343979] main.py Load Uefinit minpiate. I a imapert the necessary modules 2 import pandas as pd \begin{tabular}{l|l} Les \\ Activir. & 4.10.1 : LA P. Prediction with Log stic Regression \end{tabular} main.py Lose detwat inmplate 1 H import the necessary modules ieport pandas as pd import scipy.stats as stats import stotsinodels.opi as 5m from statsinodels. tools import add_constant 7 femate = int ( input ()) 8 age = float (input ()) 9 econony = int (input ()) 18 deloy = floot ( input()) 11 11 flights = pd. read_csv("Invistico_Airtine_LR. csv2 ) 13 14 * remove missing data 14 flights, dropno(axis 6, inplace - True) Run your program as often as you'd like, before submitting for grading Below type any needed input values in the first box, then click Run program and observe the program's output in the second box: main.py Lse detain tempisin17 18x - pd. concotC[ftights, Gender.Femate, flights. Age, flights. Class_Eco, flights. Arrivol_Oetay,in_mirutes], Ca 19 * creote a neis dote frame from the voriables Gender_Fetole, Age, Class.Eco, and Arrival.Oeloy,in Mirutes. 21x - add_constant (x) 22Y = flights.satisfactionusatisfied set Y as the response voriable satisfoction sotisfied 23 24 model = sm, GLMCY, X, family= sm, famities. BinomialO).fitOf perform logistic regressian on X and Y 26 ex - np, arrayC[ 25 , fenale, age, economy, deldy]]] d create an array mith 1 for the intercept, and the user input 27 28 prediction = model, predict (ex) find the predicted probablility that a custoner with the user ingut values 29 print(prediction) Run your program as often as youd like, before submitting for grading. Below, type any needed 4.10.1: LB. Prediction with Logistio Regression 0/2 Run your program as often as youdd like, before submitting for grading. Below, type any needed second box. Run your program as often as youd like, before submating for grading. Below, type any needed input values in the first box, then click Run program and observe the proghams output in the second box. Enter program input (optional) 1340.10 Program errors displayed here File"main.py",1ine16. x p pd.coneat ( 111ghta, Gender_Female, tlighta, Nge, tlighta.claas_Eco, flughta, Artivalibelsyal Ayntaxtincorelinvald inynitax
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
