Question
I need a help! I will need to create a program in Python 3.0 to do the following: Requirements You are to create a program
I need a help! I will need to create a program in Python 3.0 to do the following:
Requirements
You are to create a program in Python that performs the following:
1. Loads the cars.csv file into a pandas DataFrame.
2. For each aspiration type , computes the conditional probability of that aspiration, given each of the makes: ( = | = )
3. Displays the conditional probabilities to the screen.
4. Computes the probability of each make and outputs to the screen
5. You cannot import any package except for pandas. You need to use the pandas DataFrame object for storing data. You cannot use the groupby function!
This is what cars.csv file has(I screenshot only part, but it is actually 207 rows):
Which will give the following output:
std std std std gas gas bmw std std make fuel-type aspiration num-of-dc body-style drive-whe alfa-rome gas std two convertibl rwd alfa-rome gas std two convertibl rwd alfa-rome gas std two hatchback rwd audi gas four sedan fwd audi gas four sedan 4wd audi gas two sedan fwd audi four sedan fwd audi gas std four wagon fwd audi gas turbo four sedan fwd audi turbo two hatchback 4wd gas two sedan rwd bmw gas four sedan rwd bmw gas std two sedan rwd bmw gas four sedan rwd bmw gas four sedan rwd bmw gas four sedan rwd bmw gas two sedan rwd bmw gas four sedan rwd chevrolet gas std two hatchback fwd chevrolet gas two hatchback fwd chevrolet gas std four sedan fwd dodge gas hatchback fwd dodge gas hatchback fwd dodge gas turbo two hatchback fwd dodge std four hatchback fwd dodge gas four sedan fwd std std std std std std std two two std gas std STATISTICAL PROGRAMMING Prob(aspiration=std make=renault) = 100.00% Prob(aspiration=turbo make=renault) = 0.00% Prob(aspiration=std make=saab) = 66.67% Prob(aspiration=turbo make=saab) = 33.33% Prob(aspiration=std make=subaru) = 83.33% Prob(aspiration=turbo make=subaru) = 16.67% Prob(aspiration=std make=toyota) = 96.88% Prob(aspiration=turbo make=toyota) = 3.12% Prob(aspiration=std make=volkswagen) = 83.33% Prob(aspiration=turbo make=volkswagen) = 16.67% Prob(aspiration=std make=volvo) = 54.55% Prob(aspiration=turbo make=volvo) = 45.45% Prob(aspiration=std make=alfa-romero) = 100.00% Prob(aspiration=turbo make=alfa-romero) = 0.00% Prob(aspiration=std make=audi) = 71.43% Prob(aspiration=turbo make=audi) = 28.57% Prob(aspiration=std make=bmw) = 100.00% Prob(aspiration=turbo make=bmw) = 0.00% Prob(aspiration=std make=chevrolet) = 100.00% Prob(aspiration=turbo make=chevrolet) = 0.00% Prob(aspiration=std make=dodge) = 66.67% Prob(aspiration=turbo make=dodge) = 33.33% Prob(aspiration=std make=honda) = 100.00% Prob(aspiration=turbo make=honda) = 0.00% Prob(aspiration=std make=isuzu) = 100.00% Prob(aspiration=turbo make=isuzu) = 0.00% Prob(aspiration=std make-jaguar) = 100.00% Prob(aspiration=turbo make-jaguar) = 0.00% Prob(aspiration=std make=mazda) = 100.00% Prob(aspiration=turbo make=mazda) = 0.00% Prob(aspiration=std make=mercedes-benz) = 50.00% Prob(aspiration=turbo make=mercedes-benz) = 50.00% Prob(aspiration=std make=mercury) = 0.00% Prob(aspiration=turbomakemercury) = 100.00% Prob(aspiration=std make-mitsubishi) = 53.85% Prob(aspiration=turbo make=mitsubishi) = 46.15% Prob(aspiration=std make=nissan) = 94.44% Prob(aspiration=turbo make=nissan) = 5.56% Prob(aspiration=std makepeugot) = 45.45% Prob(aspiration=turbo make=peugot) = 54.55% Prob(aspiration=std make=plymouth) = 71.43% Prob(aspiration=turbo make=plymouth) = 28.57% Prob(aspiration=std make=porsche) = 100.00% Prob(aspiration=turbo make=porsche) = 0.00% Prob(make=alfa-romero) = 1.46% Prob(make=audi) = 3.41% Prob (make=bmw) = 3.90% Prob(make=chevrolet) = 1.46% Prob (make=dodge) = 4.39% Prob(make=honda) = 6.34% Prob(make=isuzu) = 1.95% Prob (make-jaguar) = 1.46% Prob(make=mazda) = 8.29% Prob(make=mercedes-benz) = 3.90% Prob (make-mercury) = 0.49% Prob(make=mitsubishi) = 6.34% Prob(make=nissan) = 8.78% Prob(make=peugot) = 5.37% Prob (make=plymouth) = 3.41% Prob(make=porsche) = 2.44% Prob(make=renault) = 0.98% Prob (make=saab) = 2.93% Prob(make=subaru) = 5.85% Prob(make=toyota) = 15.61% Prob (make=volkswagen) = 5.85% Prob(make=volvo) = 5.37%Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started