Bayesian Filtering For Dummies 281
Dynamoo writes "Bayesian filtering for spam is awfully clever stuff, touched on by Slashdot several times before. There's a very accessible article at BBC News explaining in fairly simple terms the drawbacks of current keyword-based filtering. It's slightly ironic that the BBC, through the commissioning of Monty Python, also gave 'spam' its name. Those Vikings have a lot to answer for."
Yes, we must filter out the dummies (Score:5, Funny)
Re:Yes, we must filter out the dummies (Score:3, Funny)
Re:Yes, we must filter out the dummies (Score:5, Interesting)
The key problem is adaptation. "Bayesian filtering is better than simple keyword filtering, but its performance will degrade over time unless its rules are continuously updated (via analysis of new data). And there's the problem that a troll in one story context may be an insightful comment in another.
Moderation by humans apapts rapidly, accomodates a variety of contexts, and will reflect (and grow with) the overall
Re:Yes, we must filter out the dummies (Score:2, Insightful)
So while it works, there's still some holes in the system.
Human filtering (Score:3, Funny)
Re:Yes, we must filter out the dummies (Score:5, Interesting)
If you were to run every slashdot post throu my mail filter as an e-mail message and properly mark the trolls and others you don't want, and the ones you do want, suddenly you would only get the actual good posts, trolling would die quickly... And because of the user classification system currently in place, slashdot has a huge db to build up the word stats, so it could happen immediatly or faster...
Seriously, I ask that the slashdot admins consider adding this to slashcode... even if slashdot does not use it, others would... there are too many trolls out there as it is on the net and many people put them only a few rungs higher than spammers on the evolutionary ladder(but lower than an ameoba still)
The logic behind this can actually be extended, to allow a user to start filtering stories so that they only get ones that interest them, or even to filtering submissions to get rid of the cruft, how often to you think that the trolls post troll story submissions? Save work for the site admins...
I'm curious if an extension of this idea is how Google News works... anyone know?
Enjoy.
Re:Yes, we must filter out the dummies (Score:3, Funny)
Re:Yes, we must filter out the dummies (Score:2)
Re:Yes, we must filter out the dummies (Score:5, Insightful)
Baysian filters for spam work because spam has a significantly different vocabulary distribution than useful e-mail. This is true because spam must deliver a commercial message and play on people's uncertainties.
Good trolls, on the other hand, look ALMOST like insightful, well written articles. The vocabulary distribution in good trolls is not significantly different than the vocabulary distribution of useful posts. So, Baysian filters would be useless, unless you come up with some smarter characteristics on which to train the filter.
You could easily develop a filter for ascii-art porno. But, those are offtopic or flaimbait, not trolls.
Re:Yes, we must filter out the dummies (Score:3, Interesting)
Ahh, but a troll that looks genuine at first, and appears on topic is worth a reading for the laugh. It needs to be marked funny, and depending on how good it is might need some explination in a followup post to keep those not in the know from thinking the wrong thing.
OTOH, first post is always useless and a waste of time. So are a few other posts. ASCI-art might be easy to filter, but can you filter the porn ascii-art without blocking the guy trying to make a diagram of some sort so we can better unde
Re:Yes, we must filter out the dummies (Score:5, Interesting)
The same thing would happen to your mail if the words that your bayesian filter were the same as the words in everybody else's. Spammers would be able to see what make an email seem spamming and they wouldn't do that. Bayesian filtering works for email right now because everybody's filters are a bit different. There is currently no magic bullet to get through everybody's spam filters. Also spammers cannot see your filter so they don't know if their message was filtered. If you opened your archive to me, I could quite easily craft a spam that would land square in your inbox.
Re:Yes, we must filter out the dummies (Score:3, Redundant)
It would work based on the moderations of comments for the learning, and of course the bonus would be totaly userdefinable so you could set it to 0 and it would have no effect.
Just my thoughts on the issue
Re:Yes, we must filter out the dummies (Score:2)
and
b) its optional, so rather than not letting you post at all it lets you post, but some users get the post flagged lower.
Re:Yes, we must filter out the dummies (Score:3, Funny)
Didn't think so.
A bit of info on Bayesian filtering (Score:5, Informative)
Paul Graham's spam page [paulgraham.com]
He talks a little bit more about the technical aspects there.
Re:A bit of info on Bayesian filtering (Score:3, Informative)
A probability can of course be mistaken, but there is little ambiguity about what it means, or how evidence should be combined to calculate it. Based on my corpus, "sex" indicates a
Tough filter for users of dating
Re:A bit of info on Bayesian filtering (Score:5, Insightful)
Re:A bit of info on Bayesian filtering (Score:5, Insightful)
Bayesian filters adapt, that's why they work so well.
Brief Tech Notes on Bayesian Filtering (Score:5, Informative)
Well, the type of Bayesian learning used in this spam filtering is called "Naive Bayesian" and the engine is trained using "supervised learning" technique. Naive Bayes has been proven very successful for text categorization. Spam filtering is even more successful because we essentially categorize e-mails to two labels: "spam" or "not spam".
Supervised learning basically works like this. Feed the engine with multiple examples (in this case, e-mails) with labels (in this case, "spam" or "not spam"). The training usually takes thousands of examples to get good enough accuracy. And take note that we need both "spam" and "not spam" examples to enable the learning engine to distinguish them.
How Naive Bayes works? Well, think of the full Bayesian Network. Bayes net is basically a causal-effect graph with annotated Conditional Probability Table (CPT) on each node denoting the probabilities of possible values. Full Bayes Net takes Directed Acyclic Graph (DAG), but Naive Bayes takes a form of tree instead due to some "naive" assumptions. (Okay, I handwaved a whole lot of details here) And in Learning Naive Bayes, we basically try to construct the tree out of the examples.
Let P(spam) be the percentage of training e-mails that is labelled as "spam" and P(not spam) be the percentage of "not spam" e-mails.
First, let the filter reads all e-mails and collect the words out of them. Weed out duplicates and stop words (common words like "I", "you", "the", etc). Let NumVocab be the number of words after weeding.
Second, process e-mail one by one. Do weeding phase like the above. Let "n" be the number of words on that particular e-mail after the weeding. Scan the word one by one. Let "w" be the current word scanned and "nw" be the number of times word "w" occur in that e-mail. Imagine you have a big two dimensional array to store the result (let's call the array "P"). If the e-mail is labeled "spam", then store (nw+1)/(n+NumVocab) to P[w][spam].
Repeat until all training e-mails are read.
And here comes the testing phase...
When you encounter an e-mail and want to classify whether it's spam or not, you'll need to look up the array P you created earlier. First, you do the weeding phase and scan the word one by one. The algo is like this:
Hope this helps.
Re:Brief Tech Notes on Bayesian Filtering (Score:2, Insightful)
Spam filtering is even more successful because we essentially categorize e-mails to two labels: "spam" or "not spam"
True. You could simply have a spam and a not spam category. I don't think that'll necessarily lead to the highest accuracies though.
Spam naturally seems to come in several categories - porn, penis enlargements, mortgages etc. However, it's unlikely that any one spam will simultaneously advertise porn and mortgages. Simply having a "spam" and a "not" category will not take advantage of
Re:Brief Tech Notes on Bayesian Filtering (Score:4, Insightful)
Certainly there are other categorizations that are useful, e.g., work vs. private mail. Bayesian techniques can be used for further categorization, but they should only be used to categorize as far as the user cares to have their mail categorized.
Bayesian techniques for non-spam wouldn't be that useful, anyway, because non-statistical rules generally work well for everything but spam -- it's only because spammers are specifically trying to defeat non-statistical rules that we need statistical analysis. The only other place for Bayesian techniques, IMHO, is where the user can't articulate the basis of the categorization they desire (but that's probably quite common).
Re:Brief Tech Notes on Bayesian Filtering (Score:2)
Thank you for the additional detail! What I wonder is this: would it be useful for people to be able to somehow pool their examples? The number of spam messa
Re:Brief Tech Notes on Bayesian Filtering (Score:2, Insightful)
Re:Brief Tech Notes on Bayesian Filtering (Score:2)
While I do agree with you, for the most part, it would be plausible to include such e-mails as "wet horny teen sluts want to cum for you" et al.
I have to say that I did notice Mozilla picked up some mail as SPAM right out of the gate. The unfortunate part was; it picked up several false positives. It was
You asked for it ;) (Score:2)
How to Increase Your Penis
And Stop Premature Ejaculation
FREE Bottle Offer 100% Guaranteed to work.
Take Advantage of Our FREE Bottle Offer As Seen On TV !!!
Click here to learn more. [slashdot.org]
NB: Amusingly my first revision of this was smacked down by slashdot's inbuilt junk filtering mechanisms. :P
DON'T implement it like the parent (Score:3, Informative)
You'll soon be running out of bits to store the floating point results. Implement it by adding logarithms of probabilities instead of products of them, thus:
It's not bad... (Score:3, Interesting)
Re:It's not bad... (Score:2, Insightful)
Re:It's not bad... (Score:2)
I've been running POPFile since January, and on over 1,200 messages (until my HD blew up), the accuracy was over 98%.
Good deal!
N.
Re:It's not bad... (Score:3, Informative)
Origin of SPAM (Score:3, Interesting)
Does anyone have proof thats where the name comes from?
Re:Origin of SPAM (Score:5, Informative)
Re:Origin of SPAM (Score:5, Informative)
The sketch is to be found on the album "The Bset of Sellers" - probably released in about 1958, and which also features the nursery rhyme
"Up on the chair behind the door,
hey diddle, diddle,
Hear comes Poppa
so up with the chopper
and split 'im down the middle
And "Balham, gateway to the South" a spoof of the travalogue films that often apepared in the cenema at the time.
Dialect or typo? (Score:3, Funny)
Vikings? (Score:2, Funny)
Re:Vikings? (Score:2)
Re:The Normans WERE Vikings (was: Vikings?) (Score:2)
More Spam! (Score:3, Insightful)
Speaking of dummies... (Score:5, Informative)
Paul
"Alanis irony" (Score:3, Funny)
Re:"Alanis irony" (Score:3, Interesting)
Re:Speaking of dummies... (Score:2, Funny)
Re:Speaking of dummies... (Score:2)
Ironic? (Score:5, Funny)
What's your name, Alanis Morissette ?
Re:Ironic? (Score:2)
Re:Ironic? (Score:4, Insightful)
You see, none of the events she describes in the song is an example of irony, making the choice of the title "Ironic," well, ironic.
Reminds me of a story (Score:3, Funny)
0.0001% response rates (Score:3, Insightful)
Are we missing a critical factor of the end user who actually responds to SPAM?
If spammers survive on 0.0001% response rate, how many people are actually clicking/buying? Are these people who provide the customers for spammers going to stop or use any sort of filters?
No no no, Bayesian Filtering *OF* Dummies please (Score:4, Funny)
Do spammer's techniques work on slashdot ? (Score:5, Funny)
I-f I t-r-o-l-l l-i-k-e t-h-i-s, w-i-l-l i-t p-a-s-s S-l-a-s-h-d-o-t.'s t-r-o-l-l f-i-l-t-e-r ?
Re:Do spammer's techniques work on slashdot ? (Score:2, Funny)
2. wait 15 seconds
3. ???
f-r-i-s-t p-o-s-t!!!
i-m-a-g-i-n-e a b-e-o-w-u-l-f c-l-u-s-t-e-r o-f B-a-y-e-s-i-a-n F-i-l-t-e-r-s!
Re:Do spammer's techniques work on slashdot ? (Score:4, Funny)
B-S-D i-s d-y-i-n-g ! N-e-t-c-r-a-f-t c-o-n-f-i-r-m-s i-t !
Wrong pic... (Score:4, Informative)
Why then, does the article show a pic from a Monty Python animation about the black spot who goes to seek his fortune...
You'd think they'd use the actual pic of the skit with the Vikings in the cafe...
Hmmm (Score:2, Insightful)
I can see the casual (mis)use of this technique by your average user rapidly becoming a problem - putting just one email from a legit e-mail sender into the bayesian filter could concievably snowball into a block on a lot of legit traffic under certain circumstances.
Above and Below knows I have enough hassle with users and their e-mail already
Re:Hmmm (Score:3, Insightful)
It's natural to think that is the case, but in reality it isn't. Accidentally putting one email in the wrong corpus ("good" or "spam") will not be enough to kill you. If you consistently fail to put them in the right corpus then over time,
Required Reading by E-mail Users (Score:4, Interesting)
"The sheer number of spam mail sent means that even tiny response rates, reportedly 0.0001%, means junk mailers turn a profit. "
And this is why I say that educating users is just about as important as implementing spam filtering technology. If people know that they are perpetuating a serious problem by replying to spam, then that's bad news for spammers.
About another fact mentioned in the article: It said Paul Graham's filter extracts "the top 15 features that define them as spam." 15? I thought that most Bayesian filters use many more spam-defining features. Because I'd say that there are quite a few more. Just think of the many features that spam tends to have. But he says his filter works well. Interesting.
Re:Required Reading by E-mail Users (Score:3, Insightful)
Re:Required Reading by E-mail Users (Score:3, Interesting)
Yes, but you haven't reduced your exposure to spam. In fact, it looks like now you have to track your spam intake assiduously so as to keep the filter trained. Not many people would consider this an improvement.
Re:Required Reading by E-mail Users (Score:2)
The reason that spam works so well is that the proportion of idiots out there who either didn't attend the lesson, didn't believe the lesson, or didn't listen in the lesson is small, but significant. There's one born every minute as they say.
About another fact mentioned in the ar
I don't receive spam (Score:5, Interesting)
So existing mail filters work for me, more or less. The few unwanted mails that pass through are easily taken care of by my trusted delete button. This leads me to ask
- Do other people really receive that much spam, or am I an isolated case ?
- Do people who receive spam purchase things online, or register software and other services with their real names and email ?
Re:I don't receive spam (Score:2)
Maybe how you count, but most of us don't need v1agra or naked ch33r1eaders, and therefore consider all those messages to be spam! .. actually, on second thought ;-)
The obvious question is how much mail do you receive in total, how much non-spam, and how many false-positives go completely unnoticed by you? I've had my email account since the late 1980's and I get over 200 per day. I also run a mail gateway for a medium sized company, and we get over 30,000 per day.
There are in fact two big problems wi
Re:I don't receive spam (Score:2)
Well, this is what I can tell you : I've had my corporate email (the one that I really use publicly) for maybe 5 years, and I get maybe 15 mails/day not counting mailing lists, and possibly 300 total, the LKML taking a lot of that extra traffic. During the first year I've worked for my company, I was a support engineer, and I've never had (or heard of) a customer wh
Re:I don't receive spam (Score:4, Insightful)
But that's why Bayesian advocates every user having their own Bayesian statistics. It's not a "one size fits all" for the entire ISP or company, as is the case with most keyword filters. Every user has a different set of Bayesian statistics which is why it is very difficult for spammers to get around this filter--they have no way of knowing what words are in each users' statistics.
2) you still have to waste your bandwidth and CPU before you reject it.
It's better to waste your bandwidth and your CPU than to waste the time of those receiving the spam. IMHO...
So Bayesian filters are a good tool of last resort, but there are many other tools that should be used too.
The quicker everyone uses Bayesian filters (as opposed to waiting until all the other filters are incapable of keeping up with spam) the sooner the spammers will be in trouble. I personally use both a Bayesian filter with an up-to-date blacklist of known spamvertised domains, etc. I find that, quite simply, the simple keyword filters catch spam from known spam sites and Bayesian catches the rest. But if I turned off my normal filters Bayesian would have caught it all since those spams are always assigned a high Bayesian score, too. It almost makes sense to turn off the other filters, but they can be useful if a spammer comes up with a truly unique spam and someone else has already identified the domain name. It's rare, but it can happen. So a combination of technologies is probably the best... but a combination that lacks Bayesian is a combination that could be better.
Re: (Score:2, Informative)
Re:I don't receive spam (Score:2)
Yes, they do... I probably get 50-60 spams a day
Do people who receive spam purchase things online, or register software and other services with their real names and email ?
I made the mistake of putting my unobfuscated email address on my web page... bad idea
Re:I don't receive spam (Score:2)
It was a real question though, I post on usenet too, on various mailing lists that get indexed on google somehow, I maintain several opensource projects, I have a homepage with my email in plaintext at the bottom, etc
Apple's Mail app... (Score:4, Interesting)
Re:Apple's Mail app... (Score:5, Informative)
Evolution and (Score:3, Insightful)
Re:Evolution and (Score:3, Informative)
1. Get and install bogofilter.
2. Make a shell wrapper script that runs bogofilter in passthrough mode, redirect stdout and stderr to files in
#!/bin/bash
status=$?
exit $status
3. Make a new local mail folder in evolution to collect spam.
4. Make a filter in evolution that runs the wrapper script. Tools->Filters, choose Incoming, choose Add. Add a c
Here's one I've used (Score:4, Insightful)
I find in our case it stops 98-99% of spam dead in its tracks. There have been a few false positives, and you do need check from time to time just in case an genuine emails are misclassified, but it's surprising just how quickly the filter sorts the wheat from the chaff.
Don't expect miracles but they can save you a lot of time... what I find cool is that it learns so quickly, almost like a complicated neural net should, but it's such a simple idea. I wonder if there are any other uses for this kind of thing?
Re:Here's one I've used (Score:2)
Use the Reverend to quickly add Bayesian smarts to your app. To use it in your
own application, you either subclass Bayes or pass it a tokenizing function. Bayesian fun
has never been so quick and easy. Many thanks for Christophe Delord for his well written
PopF. Orange also looks good.
Stuff you can do with the Reverend:
- classify recipes by cuisine
- who do you write like? Shakespear, Dickens, Austen, Aesop
- detect the language o
Re:Here's one I've used (Score:3, Funny)
>I wonder if there are any other uses for this kind of thing?
Yes, there is:
http://groups.google.com/groups?q=venue+group:comp
.lang.python&hl=en&lr=&ie=UTF-8&safe=off&selm=mail m =1
man.1048821167.17118.python-list%40python.org&rnu
You mean like automatically deleting unusable links so we don't have to try to figure out how to get them to work?
Crude but effective (Score:5, Insightful)
This is waaaaay better than any other filtermethod I've tried and requires no learning period at all
Re:Crude but effective (Score:3, Funny)
Re:Crude but effective (Score:2, Funny)
Mozilla does this (Score:3, Informative)
1. Is the sender in the address book? If yes, is not spam, otherwise:
2. Does the message have a probability of 90% that it is spam based on the Bayes filter? If so, flag as spam, otherwise not spam.
Slight modification: white-list+Bayesian is useful (Score:5, Interesting)
This allows your single spam/non-spam feedback to the system to do double duty, so that once the program knows that you consider an email source to be "trusted", it will allow even spammy-looking stuff (read: mailing list digests, plane schedules, bank statements, etc) through to your non-spam folder.
Of course, if spammers start constructing google-style databases of who your friends are and impersonating their accounts, then this won't work anymore... but if they start that, all hell is going to break loose anyway.
Re:Slight modification: white-list+Bayesian is use (Score:2)
Take the Tagged Message Delivery Agent [tmda.net], a system that will send a challenge message to anyone it doesn't know (isn't in the whitelist), which you have to reply to.
Then change it so anything allowed through on the whitelist is added to the "Not Spam" category, and anything that is challenged is passed through the filter. If it passes, it doesn't get challenged (but also doesn't get added automatically to Not Spam), and if it _doesn't_
Browser ad-blocking the same way? (Score:2, Insightful)
(And before anyone says "Don't do that, websites will die" my response would be "Good, let most of them die." I hate ads.)
Re:Browser ad-blocking the same way? (Score:2, Informative)
Nostalgia (Score:2)
I don't even try to filter spam out. (Score:3, Insightful)
Most of what's left is spam, so a quick scan of the inbox (and creation of new rules) weeds out the uncaught desirables and the rest gets dropped in the bitbucket.
The point being that legitimate mail doesn't try to spoof my filters. I haven't (yet) had any spam arriving where it shouldn't. I'd rather my ISP dumped all the crud in the bin for me, but my marginal cost is low as I'm on ADSL. I now also use a distinct email for each purpose, making it easy to spot where spammers got it from and to create new rules as needed. It's a shame I didn't do this at the start as I have a couple of early ones that are spammed but I can't dump.
Comment removed (Score:3, Interesting)
naive implementation of naive Bayesian (Score:4, Informative)
The lack of references on Graham's web site to prior work on text classification makes one wonder whether he just is unfamiliar with a huge body of literature going back decades or whether he just deliberately ignores them. Either way, Graham didn't invent any of the techniques and they are far from state-of-the-art. (Incidentally, you'll probably find Octave or Perl/PDL a more convenient language for implementing this stuff than Lisp.)
Anybody seriously interested in text filtering should at least do a little bit of background reading. "Readings in Information Retrieval" by Jones and Willett covers some of the basic papers.
My solution. (Score:3, Interesting)
No Junk Mail please.... (Score:3, Funny)
The best email filter (Score:3, Interesting)
Why go through all the work of training some software to read your email and decide if you might want to read it when most email programs have white list capabilities?
If I don't know you, that means I don't want to talk to you. Your email goes straight a junk folder, which I can quickly scan once every few days for from names I recognize. I can add these names to my white list if I so choose.
Granted, my job does not involve me soliciting contacts from the public at large, so this wouldn't work for everyone. I use it on my personal Hotmail account though, and I get to not even consider lots of crap every day.
Bayesian for windows? (Score:2)
Re:Bayesian for windows? (Score:2)
Re:Bayesian for windows? (Score:2)
Bogofilter 0.9 NOT 0.11 (Score:2)
I gave it a chance for over two weeks, and it never got even close to the success rate of 0.9. Not that I'm complaining, there was nothing left to improve upon in 0.9 AFAIC. (And yes, I did se
Re:who're the vikings? (Score:5, Informative)
Re:who're the vikings? (Score:3, Insightful)
The poster, obviously better schooled in British farce than luncheon meats, is under the impression that the widely accepted nickname for unsolicited e-mail is derived from the comedy sketch and not from Spam(tm), the food.
I don't know for certain if he's wrong, but I have a hunch he is. I'm guessing a lot more peop
Re:who're the vikings? (Score:2, Informative)
However it did not orginally go with bulk email, but instead with some wanker on posting the same post over and over again on a newsgroup or IRC.
[1] Including "normal" users.
Re:who're the vikings? (Score:2)
Re:Spam = /dev/null (Score:5, Informative)
You can try bogofilter [sourceforge.net], ifile [nongnu.org], SpamBayes [sourceforge.net], or POPFile [sourceforge.net]. The newer versions of SpamAssassin [spamassassin.org] also implement some kind of Bayesian filtering.
Re:Spam = /dev/null (Score:2, Insightful)
POPFile does not have this convenient ability (yet), though it does do general purpose sorting (i.e. not just differentiate between spam and non-spam, but stuff like work, school, linux or whatever you want). It does take a while to train though.
Re:Spam = /dev/null (Score:2, Informative)
Re:Spam = /dev/null (Score:2)