models#
Provides Models.
- class AveragePredictor(time_series_params: TimeSeriesConfig, model_params: ModelConfig)#
Bases:
ModelDefines a model, which predicts the average of the train data.
Inits the AveragePredictor.
- Parameters:
time_series_params – parameters of the time series that influence the training and archicture of the model.
model_params – configuration for the model.
- property name: str#
Returns the models name.
- Returns:
The models name.
- predict(data: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]#
Predicts the next timestamps for every row.
- Parameters:
data – 3 dimensional numpy array. First dimension contains time-series. Second dimension contains time steps of a time-series. Third dimension contains the attributes at a single timestep.
- Returns:
A 3 dimensional numpy array, with the predicted values.
Example
>>> import numpy as np >>> from simba_ml.prediction.time_series.models import average_predictor >>> from simba_ml.prediction.time_series.config import time_series_config >>> train = np.array([[[1,2], [1,2]], [[2,5], [2,6]], [[10, 11], [12,12]]])
>>> train.shape (3, 2, 2) >>> model_config = average_predictor.AveragePredictorConfig() >>> ts_config = time_series_config.TimeSeriesConfig() >>> ts_config.input_length = 2 >>> model = average_predictor.AveragePredictor(ts_config, model_config) >>> model.train(train=train) >>> model.avg 5.5 >>> test_input = np.array([[[10, 10], [20, 20]], [[15, 15], [15, 16]]]) >>> print(test_input) [[[10 10] [20 20]] [[15 15] [15 16]]] >>> print(model.predict(test_input)) [[[5.5 5.5]] [[5.5 5.5]]]
- train(train: list[numpy.ndarray[Any, numpy.dtype[numpy.float64]]]) None#
Trains the model with the given data.
- Parameters:
train – data, that can be used for training.
- validate_prediction_input(data: ndarray[Any, dtype[float64]]) None#
Validates the input of the predict function.
- Parameters:
data – a single dataframe containing the input data, where the output will be predicted.
- Raises:
ValueError – if data has incorrect shape (row length does not equal )
- class LastValuePredictor(time_series_params: TimeSeriesConfig, model_params: ModelConfig)#
Bases:
ModelDefines a model, which predicts the previous value.
Inits the model.
- Parameters:
time_series_params – Time-series parameters that affect the training and architecture of models
model_params – configuration for the model.
- Raises:
TypeError – if input_length or output_length is not an integer.
- property name: str#
Returns the models name.
- Returns:
The models name.
- predict(data: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]#
Predicts the next timestamps for every row.
- Parameters:
data – 3 dimensional numpy array. First dimension contains time-series. Second dimension contains time steps of a time-series. Third dimension contains the attributes at a single timestep.
- Returns:
A 3 dimensional numpy array, with the predicted values.
Example
>>> import numpy as np >>> from simba_ml.prediction.time_series.models import last_value_predictor >>> from simba_ml.prediction.time_series.config import time_series_config >>> train = np.array([[[1,2], [1,2]], [[2,5], [2,6]], [[10, 11], [12,12]]]) >>> train.shape (3, 2, 2) >>> model_config = last_value_predictor.LastValuePredictorConfig() >>> ts_config = time_series_config.TimeSeriesConfig() >>> ts_config.input_length = 2 >>> model = last_value_predictor.LastValuePredictor(ts_config, model_config) >>> model.train(train=train) >>> test_input = np.array([[[10, 10], [20, 20]], [[15, 15], [15, 16]]]) >>> print(test_input) [[[10 10] [20 20]] [[15 15] [15 16]]] >>> print(model.predict(test_input)) [[[20 20]] [[15 16]]]
- train(train: list[numpy.ndarray[Any, numpy.dtype[numpy.float64]]]) None#
Trains the model with the given data.
- Parameters:
train – data, that can be used for training.
- validate_prediction_input(data: ndarray[Any, dtype[float64]]) None#
Validates the input of the predict function.
- Parameters:
data – a single dataframe containing the input data, where the output will be predicted.
- Raises:
ValueError – if data has incorrect shape (row length does not equal )
- class Model(time_series_params: TimeSeriesConfig, model_params: ModelConfig)#
Bases:
ABCDefines the abstract model.
Inits the model.
- Parameters:
time_series_params – Time-series parameters that affect the training and architecture of models
model_params – configuration for the model.
- Raises:
TypeError – if input_length or output_length is not an integer.
- property name: str#
Returns the models name.
- Returns:
The models name.
- abstract predict(data: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]#
Predicts the next timesteps.
- Parameters:
data – 3 dimensional numpy array. First dimension contains time-series. Second dimension contains time steps of a time-series. Third dimension contains the attributes at a single timestep.
- abstract train(train: list[numpy.ndarray[Any, numpy.dtype[numpy.float64]]]) None#
Trains the model with the given data.
- Parameters:
train – training data.
- validate_prediction_input(data: ndarray[Any, dtype[float64]]) None#
Validates the input of the predict function.
- Parameters:
data – a single dataframe containing the input data, where the output will be predicted.
- Raises:
ValueError – if data has incorrect shape (row length does not equal )
Provides a model, which predicts the average of the train data. |
|
Factory for creating a models. |
|
Registers the keras models as plugins. |
|
Provides a model, which predicts the last given input value. |
|
Provides an abstract Model. |
|
|
Converts a model to a transfer learning model. |
Registers the pytorch lightning models as plugins. |
|
Provides the sklearn models. |
|
|
Factory for creating a transfer learning models. |
|
Provides an abstract Model. |