Answered step by step
Verified Expert Solution
Question
1 Approved Answer
DATA - 5 1 1 0 0 : Statistical Programming Programming Assignment 4 Estimating Probabilities Introduction Probability is a number that indicates the likelihood of
DATA: Statistical Programming
Programming Assignment Estimating Probabilities
Introduction
Probability is a number that indicates the likelihood of some outcome occurring, where each outcome comes from
a set called the sample space, denoted by Omega Probabilities are used in situations where there is uncertainty in data,
either due to a lack of sufficient data or some inherent randomness associated with the data. Formally, probability
of each outcome is a value, that satisfies the following properties:
in Omega in each probability value has to be between zero and one
and
in Omega sum of all probabilities needs to be one
A set of outcomes defines an event. The probability of an event E is defined as
in
In many applications, it is necessary to estimate probabilities from data. If the data contains nominal ie
categorical values, we can estimate the probability of a particular value occurring in the data by counting the
number of instances in which the value occurs. In particular, assume the data consists of N instances, which is
associated with a fixed number of feature values. Then the probability of a particular feature having a particular
value can be computed as
#
We can also compute the conditional probability of a particular feature value, given some other features values as
#
#
Note that the denominator is assumed to be nonzero. Such estimates can then be used for various data analysis
applications, such as modeling or machine learning.
Requirements
You are to create a program in Python that performs the following:
Loads the carscsv file into a pandas DataFrame.
For each aspiration type computes the conditional probability of that aspiration, given each of the
makes:
Displays the conditional probabilities to the screen.
Computes the probability of each make and outputs to the screen.
Additional Requirements
The name of your source code file should be ProbEst.py All your code should be within a single file.
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!
Your code should follow good coding practices, including good use of whitespace and use of both inline
and block comments.
You need to use meaningful identifier names that conform to standard naming conventions.
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.
The output of your program should exactly match the sample program output given at the end.
What to Turn In
You will turn in the single ProbEst.py file as well as a screenshot of your outputs using BlackBoard.
Sample Program Output
DATAsemesteryear
NAME: put your name here
PROGRAMMING ASSIGNMENT #
Probaspirationstdmakealfaromero
Probaspirationturbomakealfaromero
Probaspirationstdmakeaudi
Probaspirationturbomakeaudi
Probaspirationstdmakebmw
Probaspirationturbomakebmw
Probaspirationstdmakechevrolet
Probaspirationturbomakechevrolet
Probaspirationstdmakedodge
Probaspirationturbomakedodge
Probaspirationstdmakehonda
Probaspirationturbomakehonda
Probaspirationstdmakeisuzu
Probaspirationturbomakeisuzu
Probaspirationstdmakejaguar
Probaspirationturbomakejaguar
Probaspirationstdmakemazda
Probaspirationturbomakemazda
Probaspirationstdmakemercedesbenz
Probaspirationturbomakemercedesbenz
Probaspirationstdmakemercury
Probaspirationturbomakemercury
Probaspirationstdmakemitsubishi
Probaspirationturbomakemitsubishi
Probaspirationstdmakenissan
Probaspirationturbomakenissan
Probaspirationstdmakepeugot
Probaspirationturbomakepeugot
Probaspirationstdmakeplymouth
Probaspirationturbomakeplymouth
Probaspirationstdmakeporsche
Probaspirationturbomakeporsche
Probaspirationstdmakerenault
Probaspirationturbomakerenault
Probaspirationstdmakesaab
Probaspirationturbomakesaab
Probaspirationstdmakesubaru
Probaspirationturbomakesubaru
Probaspirationstdmaketoyota
Probaspirationturbomake
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