Naive-Bayes weather predictions in python
I need some help in creating a weather prediction system using Naive-Bayes in python. What it will do is take in a file which contains weather data — such as temperature (mean, max, min), wind, dew 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.There are two .csv files which contain the data for training and testing(also named the same).I have the code handles the input of the data file, I just need to create the classifier but I am not sure how to do it.My program must take data in training.csv and train a Naive Bayes model that takes the following as inputs:
- Mean temperature
- Maximum temperature
- Minimum temperature
- The dew point
- Average humidity
- Maximum humidity
- Minimum humidity
- Sea Level Pressure
- Wind speed
- Maximum wind speed
- Maximum gust speed
- Visibility This is what I've written so far:
import Evaluation
import sys
import string
####################### Main Program #########################
# Checks if it has 2 .csv files as the input
if len(sys.argv) != 3:
sys.exit("Incorrect amount of arugements")
trainFileName = string.split(sys.argv[1], '.')
testFileName = string.split(sys.argv[2], '.')
if (trainFileName[len(trainFileName) -1] != "csv") or (testFileName[len(testFileName) - 1] != "csv"):
sys.exit("Incorrect file type");
# Handles input
trainingData = wd.WeatherData(sys.argv[1])
testingData = wd.WeatherData(sys.argv[2])
### my training goes here
### my prediction generation goes here, prediction is a list of strings
predictions = []
####################
# this is dummy code to generate predictions I will delete it in my final version
for day in testingData.getMeasurements():
predictions.append(day.condition)
####################```
You're "not sure how to do it." Ok… right. Well, what do you want us to do, then? Should we give you a full implementation of a naive Bayesian classifier in Python? Because those can be found here: http://bit.ly/h7tOjf Or do you want us to explain what the classifier does? Because an explanation can be found here: http://bit.ly/7OIMj
Either do your own homework, or ask specific questions, please.
I found something about this… http://orange.biolab.si/doc/ofb/c_pythonlearner.htm Maybe I cant assimilate some useful knowledge from it
You didn't write this code. All it does is read in data from the two CSV files and creates two WeatherData instances for both the training and testing data which you will use.
Have a look at WeatherData.py and DayWeatherMeasurements.py to see how these classes work as you will have to use them in the training and testing of the classifier.
I recommend reading the notes here:
http://www.inf.ed.ac.uk/teaching/courses/inf2b/learnnotes/inf2b11-notes.pdf
Chapters 5 and 6 explain naive Bayes but since the weather data is continuous you will need to model it as a Gaussian (normal) distribution which is explained in chapters 8 and 9.