Professional Documents
Culture Documents
DWM Experiment 05
DWM Experiment 05
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
Color Stolen
red no 2
yes 3
yellow no 3
yes 2
dtype: int64
------------------
Type Stolen
sports no 2
yes 4
suv no 3
yes 1
dtype: int64
------------------
Origin Stolen
domestic no 3
yes 2
imported no 2
yes 3
dtype: int64
------------------
Stolen
Stolen
yes 5
no 5
Name: count, dtype: int64
In [51]: import pandas as pd
# Load the data from the CSV file
data = pd.read_csv('data.csv')
def bayestheorem():
print('Posterior [P(c|x)] - Posterior probability of the target/class (c
print('Prior [P(c)] - Prior probability of the class (target)'),
print('Likelihood [P(x|c)] - Probability of the predictor (x) given the
print('Evidence [P(x)] - Prior probability of the predictor (x))')
ct = pd.crosstab(data['Color'], data['Stolen'], margins = True)
print(ct)
Color
red 2 3 5
yellow 3 2 5
All 5 5 10
In [38]: import pandas as pd
# Load the data from the CSV file
data = pd.read_csv('data.csv')
pd.crosstab(data['Type'], data['Stolen'], margins = True)
Type
sports 2 4 6
suv 3 1 4
All 5 5 10
Origin
domestic 3 2 5
imported 2 3 5
All 5 5 10
Stolen
no 5 5
yes 5 5
All 10 10