# Size of training in Naive Bayes

I just started getting involved with Machine Learning and I decided to create a spam filter for my social app, using the Naive Bayes classifier. I'm following this guide: https://hackernoon.com/how-to-build-a-simple-spam-detecting-machine-learning-classifier-4471fe6b816e

My app has ~70,000 posts and about 3,000 of them are marked as spam. How many of my non-spam posts should I use to train my model?

In general, you do stratified sampling to create training/test splits; otherwise your priors will be biased. Specifically, in Naive Bayes, you estimate class priors from data. If the prior is $$3/70$$ and you choose to equally include spams and non-spams, your prior estimate will be $$\pi=0.5$$, which can easily harm your predictions. A typical train/test split can follow 80/20 convention.

• So I should include all of my spam and non-spam posts in the training process? Aug 6 '19 at 14:16
• no, separate $80 \%$ of your samples for training, and $20 \%$ of them as test set, both for spam and non-spam. Aug 6 '19 at 14:17
• 80% of my whole database, right? Aug 6 '19 at 14:19
• yes, if you include 80 % of your spams and 80 % of your non-spams for training, the training set will be 80 % of your whole dataset. Aug 6 '19 at 14:20
• Thank you very much! Aug 6 '19 at 14:21