Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to create a program in Python that performs the following: Asks the user

ID: 3787210 • Letter: Y

Question

You are to create a program in Python that performs the following:

Asks the user for the number of cars(i.e. data instances)

2. For each car, asks the user to enter the following fields: make, model, type (coupe, sedan, SUV), rating (A,B, C, D, or F).Save the feature values for each car in a DataFrame object.

3. Displays the resulting DataFrame

4. Computes the probability of each rating and outputs to the screen

5. For each type , computesthe conditional probability of that type, given each of the ratings: P(type=t, rating=r

6. Displays the conditional probabilities to the screen

1. The name of your source code fileshould be ProbEst.py. All your code should be within a single file.

2. You cannot import any package except for pandas. You need to use the pandas DataFrame object for storing data.

3. Your code should follow good coding practices, including good use of whitespace

and use of both inline and block comments.

4. You need to use meaningful identifier names that conform to standard naming conventions.

5. At the top of each file, you need to put in a block comment with the following information: your name, date, course name, semester, and assignment name.

6. The output of your program should exactly match the sample program output given at the end

Sample Program Output

70

-

511

, [semester] [year]

NAME: [put your name here]

PROGRAMMING ASSIGNMENT #4

Enter the number of car instances:

6

Enter the make,model,type,rating:

ford,mustang,coupe,A

Enter the make,m

odel,type,rating:

chevy,camaro,coupe,B

Enter the make,model,type,rating:

ford,fiesta,sedan,C

Enter the make,model,type,rating:

ford,focus,sedan,A

Enter the make,model,type,rating:

ford,taurus,sedan,B

Enter the make,model,type,rating:

toyota,camry,sedan,B

make model type rating

0 ford mustang coupe A

1 chevy camaro coupe B

2 ford fiesta sedan C

3 ford focus sedan A

4 ford taurus sedan B

5 toyota camry sedan B

Prob(rating=A) = 0.333333

Prob(rating=B) = 0.500000

Prob(rating=C) = 0.166667

Prob(type=coupe|rating=A) = 0.500000

Prob(type=sedan|rating=A) = 0.500000

Prob(type=coupe|rating=B) = 0.333333

Prob(type=sedan|rating=B) = 0.666667

Prob(type=coupe|rating=C) = 0.000000

Prob(type=sedan|rating=C) = 1.000000

Explanation / Answer

class Vehicle(object): # no instance of this class should be created def __init__(self, typ, make, model, color, year, miles): self.typ = typ self.make = make self.model = model self.color = color.lower() self.year = year self.miles = miles def vehicle_print(self): print('Vehicle Type: ' + str(self.typ)) print('Make: ' + str(self.make)) print('Model: ' + str(self.model)) print('Color: ' + str(self.color)) print('Year: ' + str(self.year)) print('Miles driven: ' + str(self.miles)) class GasVehicle(Vehicle): def __init__(self, fuel_tank, *args): self.fuel_tank = fuel_tank Vehicle.__init__(self, *args) def vehicle_print(self): Vehicle.vehicle_print(self) print('Fuel capacity (gallons): ' + str(self.fuel_tank)) class ElectricVehicle(Vehicle): def __init__(self, energy_storage, *args): self.energy_storage = energy_storage Vehicle.__init__(self, *args) def vehicle_print(self): Vehicle.vehicle_print(self) print('Energy Storage (Kwh): ' + str(self.energy_storage)) class HeavyVehicle(GasVehicle): # no instance of this class should be created def __init__(self, max_weight, wheels, length, *args): self.max_weight = max_weight self.wheels = wheels self.length = length GasVehicle.__init__(self, *args) def vehicle_print(self): GasVehicle.vehicle_print(self) print('Maximum load (tons): ' + str(self.max_weight)) print('Wheels: ' + str(self.wheels)) print('Length (m): ' + str(self.length)) class ConstructionTruck(HeavyVehicle): def __init__(self, cargo, *args): self.cargo = cargo HeavyVehicle.__init__(self, *args) def vehicle_print(self): HeavyVehicle.vehicle_print(self) print('Cargo: ' + str(self.cargo)) class Bus(HeavyVehicle): def __init__(self, seats, * args): self.seats = seats HeavyVehicle.__init__(self, *args) def vehicle_print(self): HeavyVehicle.vehicle_print(self) print('Number of seats: ' + str(self.seats)) class HighPerformance(GasVehicle): # no instance of this class should be created def __init__(self, hp, top_speed, *args): self.hp = hp self.top_speed = top_speed GasVehicle.__init__(self, *args) def vehicle_print(self): GasVehicle.vehicle_print(self) print('Horse power: ' + str(self.hp)) print('Top speed: ' + str(self.top_speed)) class SportCar(HighPerformance): def __init__(self, gear_box, drive_system, *args): self.gearbox = gear_box self.drive_system = drive_system HighPerformance.__init__(self, *args) def vehicle_print(self): HighPerformance.vehicle_print(self) print('Gear box: ' + self.gearbox) print('Drive system: ' + self.drive_system) bmw = GasVehicle(30, 'SUV', 'BMW', 'X5', 'silver', 2003, 120300) # regular car bmw.vehicle_print() print tesla = ElectricVehicle(85, 'Sport', 'Tesla', 'Model S', 'red', 2014, 1243) # electric car tesla.vehicle_print() print lambo = SportCar('manual', 'rear wheel', 650, 160, 23, 'race car', 'Lamborgini', 'Enzo', 'dark silver', 2014, 3500) # sportscar lambo.vehicle_print() print truck = ConstructionTruck('cement', 4, 12, 21, 190, 'transport', 'Dirt Inc.', 'Dirt Blaster 100', 'blue', 1992, 120030) # Construction truck truck.vehicle_print()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote