Created
January 16, 2022 15:09
-
-
Save EvanGertis/002b33aa8cfbac2ab96114099089f70e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prob_continous_value(A, v, classAttribute, dataset, x): | |
# calcuate the average for all values of A in dataset with class = x | |
a = dataset[dataset[classAttribute] == x][A].mean() | |
# calculate the standard deviation for all values A in dataset with class = x | |
stdev = 1 | |
stdev = dataset[dataset[classAttribute] == x][A].std() | |
v = dataset[A].iloc[0] | |
if stdev == 0.0: | |
stdev = 0.00000000000001 | |
return (1/(math.sqrt(2*math.pi)*stdev))*math.exp(-((v-a)*(v-a))/(2*stdev*stdev)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment