Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Conditional Probability with Pandas (Python 3.x) without the use of the groupby function. Note: Use only Pandas and no other libraries. **Edit: Received a comment

Conditional Probability with Pandas (Python 3.x) without the use of the groupby function.

Note: Use only Pandas and no other libraries.

**Edit: Received a comment that basically said that they don't have knowledge about Python. I implore you to keep the question standing until it is answered by someone who knows Python. I also ask that you do not leave unnecessary and unproductive comments that may take the question off the answering boards.**

We have a dataset that has make and aspiration types - we need to figure out the conditional probability of aspiration given make.

Here's the dataset (showing only 13 but there are more)

image text in transcribed

Here's the sample output:

image text in transcribed

I've managed to figure out the probability of aspiration and make separately but I'm unable to move forward with it.

Any ideas?

X - DataFrame Index aspiration make alfa-romero std alfa-romero std alfa-romero std audi std audi std audi std audi std audi std audi turbo audi turbo bmw std bmw std bmw std bmw std 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=stamake=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=stamake-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=turbo make=mercury) = 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 make=peugot) = 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(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(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(makepeugot) = 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% X - DataFrame Index aspiration make alfa-romero std alfa-romero std alfa-romero std audi std audi std audi std audi std audi std audi turbo audi turbo bmw std bmw std bmw std bmw std 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=stamake=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=stamake-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=turbo make=mercury) = 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 make=peugot) = 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(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(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(makepeugot) = 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

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Question Can any type of stock or securities be used in an ESOP?

Answered: 1 week ago