-
Notifications
You must be signed in to change notification settings - Fork 17
Forecasters and Learners
When organizing the code to build a forecasting model in AtmoSeer, we found it useful to use a class organization based on the Bridge design pattern. Wikipedia offers the following description for such pattern:
The bridge pattern is a design pattern used in software engineering that is meant to "decouple an abstraction from its implementation so that the two can vary independently"
The image below depics the main components of that pattern.
In the context of AtmoSeer, consider a forecasting model that produces RAIN/NO_RAIN as its output. Hence, this model can be considered a binary classifier. In the Machine Learning parlance, a binary classifier is a type of supervised learning algorithm that is designed to classify input data into one of two possible classes or categories. These two classes are typically denoted as the positive class (often labeled as "1") and the negative class (often labeled as "0"). A binary classifier can be implemented in several alternative ways. For example, we can use a neural network equiped with several LSTM layers as feature extractors. We could also use a neural net in which the feature extractor component is comprised of Conv1D layers.
In the example above, we consider the concept of binary classifier an abstraction, and the two ways to implement it are called implementations. Notice that, were we interested in building an ordinal classifier (instead of a binary classifier) there would still exist several ways to implement it. Also notice that, to build a forecaster that is an ordinal classifier, the same learning algorithms could be used. Hence, in AtmoSeer we have two concerns that vary independently of each other. One is the type of forecaster we want to build (binary classifier, ordinal classifier, regressor, etc), and the other is the particular algorithm we use to fit (i.e., traing) the forecasting model.
Therefore, to separate these two concerns, we decided to use the Bridge design pattern. In particular, we organize forecasters (i.e., classifiers and regressors) and learners (the algorithms used to fit the forecasting model) as two independent class hierarchies, as shown below.
---
title: Forecasters and Learners organization ("Bridge pattern")
---
classDiagram
BaseForecaster <|-- BaseClassifier
BaseForecaster <|-- BaseRegressor
BaseClassifier <|-- BinaryClassifier
BaseClassifier <|-- OrdinalClassifier
BaseLearner <|-- BaseNeuralNet
BaseNeuralNet <|-- LstmNeuralNet
BaseNeuralNet <|-- Conv1DNeuralNet
BaseForecaster --> "1" BaseLearner: impl