Implementing Naive Bayes From Scratch


As stated in the general overview, we need to calculate the summary statistics for each class (and feature) as well as the prior. First of all, we need to gather some basic information about the dataset and create three zero-matrices to store the mean, the variance, and the prior for each class. Next, we iterate over all the classes, compute the statistics and update our zero-matrices accordingly. For example, assume we have two unique classes (0,1) and two features in our dataset. The matrix storing the mean values, therefore will have a two rows and two columns (2x2). The prior is just a single vector (1x2), containing the ratio of a single classes' samples divided by the total sample size.

Duplicate Docs Excel Report

None found

Similar Docs  Excel Report  more

None found