Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Naive-Bayes weather predictions in python


ghost's Avatar
0 0

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:

  1. Mean temperature
  2. Maximum temperature
  3. Minimum temperature
  4. The dew point
  5. Average humidity
  6. Maximum humidity
  7. Minimum humidity
  8. Sea Level Pressure
  9. Wind speed
  10. Maximum wind speed
  11. Maximum gust speed
  12. 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)
####################```

GTADarkDude's Avatar
Member
0 0

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.


ghost's Avatar
0 0

How can I implement the naive bayse classifier to achieve a weather prediction system?I do not now where to start so I'm looking for some guidance because I want to understand how to create the program… The links you provided above don't work


ghost's Avatar
0 0

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.


spyware's Avatar
Banned
0 0

Do your own homework, fuck off.