Skip to content

Instantly share code, notes, and snippets.

@tarlanahad
Created April 10, 2020 08:46
Show Gist options
  • Save tarlanahad/47b74dddf89be8da9b8639c9a44ef2ac to your computer and use it in GitHub Desktop.
Save tarlanahad/47b74dddf89be8da9b8639c9a44ef2ac to your computer and use it in GitHub Desktop.
def fit(self):
for c in self.classes:
x_c = self.X[c == self.y] # Get a feature vector that belongs to the class
self.means.append(x_c.mean(axis=0)) # axis = 0 => column-wise Mean
self.stds.append(x_c.std(axis=0)) # axis = 0 => column-wise STD
self.priors.append(len(x_c) / len(self.X)) # Calculate frequency of each class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment