# How do I predict if it is rainy or not?

I'm building a weather station, where I'm sensing temperature, humidity, air pressure, brightness, $$CO_2$$, but I don't have a raindrop sensor.

Is it possible to create an AI which can say if it's raining or not, with the help of the given data above and maybe analyzing the slope from the last hour or something? Which specific technology should I use and how can I train it?

• I think this question would be better suited for stats.stackexchange.com, even though, there, this question may sound too basic, given that this question is about "prediction"/"inference", in general. There you will find a lot more competent people that can answer this question. But, honestly, this is the type of questions that I would like to see more on this website, because they are actually useful. – nbro Nov 13 '18 at 18:21
• Anyway, just to give you an idea. What you're sensing, e.g. the temperature, the humidity, are usually called, in the context of machine learning (and AI, in general), features. In statistics, these are called variables. These variables can be independent or confounding. Anyway, the idea is to combine these variables in certain way, so as to create an output which needs to correspond to the output of the raindrop sensor. Which model to use and how to deal with your variables, it's more technical, and sometimes the choice of model, etc., requires a little domain knowledge. – nbro Nov 13 '18 at 18:27

## 1 Answer

This sounds like a great project, although this exact setup limits your options somewhat. Supervised machine learning approaches are effectively ruled out because you don't have the necessary training data to develop a model (i.e. the dependent variable: whether it is raining or not). You could look at accessing similar data (from what source depends on your geographical location) that includes precipitation information, and attempt to train a model based on that, before applying it to your own data to 'predict' the current conditions.

If you want a model to determine whether it's raining or not (rather than attempting to define the type, rate or other characteristics of precipitation) then you need a binary classification model. If you can get the data to train a supervised model, there are many such models available. Which one to choose depends on a number of factors – enough factors that it is as much an art as a science (and often the best way to choose is just to try several and pick the best one). XGBoost is a popular choice for a wide range of problems, including binary classification. State Vector Classifiers (SVCs, a subtype of State Vector Machine, SVM) are also common. Of course there are neural networks also. Depending on how the dependent variable correlates with the independent ones, you may find a simpler model to be more effective. If you choose to try a neural network, I suggest keeping it simple and starting with a Multi-Layer Perceptron (MLP).

Alternatively, you could try an unsupervised approach, which commonly takes the form of clustering. In this instance, you would look to try clustering algorithms, such as DBSCAN, to see if the independent variables naturally form groups (clusters) which differentiate between when it is raining or not. Of course you can cluster the data using an unsupervised model, but you would still need to then correlate that with rainfall in order to make sense of the model.

There are a number of challenges you may need overcome. For example, depending on the frequency with which the data is sampled and stored, you may need to downsample it to a manageable size. Presumably you also have the time at which the data was collected. If not, you would also need to make use of the brightness sensor to differentiate between night and day, which may confound or over-power any cooling effect from rainfall. (You could look at clustering the data, based on temperature and brightness, in order to create a new feature which indicates night and day.)

To summarise, there are numerous approaches you could take, all of which will, at some point, require data on whether it is/was raining or not in order to train a model. If you have suitably localised weather data available, you may be able to train a model using that, synchronised via time and/or the other data you'll be collecting. The problem, as stated, is a binary classification one (as opposed to a time series prediction one, i.e. weather forecasting, for example). So look into classification and clustering models for supervised and unsupervised machine learning respectively. Scikit Learn for python or Caret for R are commonly used packages for the types of models I've described.