How should I go about writing a naive Bayesian classifier in Python?
I need to create a weather prediction system in Python. What it will do is take in a file which contains weather data — such as temperature (mean, max, min), wind, dew开发者_StackOverflow point, humidity, condition (fog, rain, snow, none) etc. — and use this to train a naive Bayesian model so it can then predict the condition of the next day, i.e will the next day be fog, rain, snow or none.
This is part of an assignment so they provided code which handles the input of the data file, I just need to create the classifier but I am not sure how to do it.
Can anyone point me in the right direction?
The nltk.classify.naivebayes
module may be what you're looking for. Here is a page with examples of how to use nltk classifiers. It shows how to classify text, but should provide some hints as to how to train a classifier based on your weather features.
Paul Graham described Bayesian classification, in the context of spam filtering, here:
- http://www.paulgraham.com/spam.html
Might be a good starting point.
精彩评论