0
$\begingroup$

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?

$\endgroup$
1

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ So I should include all of my spam and non-spam posts in the training process? $\endgroup$ Aug 6, 2019 at 14:16
  • $\begingroup$ no, separate $80 \%$ of your samples for training, and $20 \%$ of them as test set, both for spam and non-spam. $\endgroup$
    – gunes
    Aug 6, 2019 at 14:17
  • $\begingroup$ 80% of my whole database, right? $\endgroup$ Aug 6, 2019 at 14:19
  • $\begingroup$ 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. $\endgroup$
    – gunes
    Aug 6, 2019 at 14:20
  • $\begingroup$ Thank you very much! $\endgroup$ Aug 6, 2019 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.