Generative Model, Walkthrough, Data Science.
class. class_labels = np.unique(y_train) n_classes = len(class_labels) n_samples = len(y_train) priors = [] means = [] covariances = [] for label in class_labels: x_class = x_train[y_train==label] priors.append(len(x_class)/n_samples) means.append(np.mean(x_class, axis=0))