kats.models.nowcasting.nowcasting module¶

Nowcasting is the basic model for short-term forecasting.

This modules contains class NowcastingParams, which is the class parameter and class NowcastingModel, which is the model.

Typical usage example:

nr = NowcastingModel(data = data, params = NowcastingParams(step = 10)) nr.feature_extraction() nr.label_extraction() nr.fit() output = nr.predict()

class kats.models.nowcasting.nowcasting.NowcastingModel(data: kats.consts.TimeSeriesData, params: kats.models.nowcasting.nowcasting.NowcastingParams, model: Optional[Any] = None, feature_names: List[str] = [])[source]¶

Bases: Generic[kats.models.model.ParamsType]

The class for Nowcasting Model.

This class performs data processing and short term prediction, for time series based on machine learning methodology.

TimeSeriesData¶

Time Series Data Source.

NowcastingParams¶

parameters for Nowcasting.

feature_extraction()None[source]¶

Extracts features for time series data.

Example of output: .. list-table:: Title :widths: 10 50 25 25 25 :header-rows: 1

    • index - time - y - ROC_10 - ROC_15

    • 30 - 2020-02-05 00:00:00 - 7234.93 - -0.278597 - -0.266019

    • 31 - 2020-02-06 00:00:00 - 7272.51 - -0.275543 - -0.271799

fit()None[source]¶

Fits model.

label_extraction()None[source]¶

Extracts labels from time seires data.

load_model(model_as_bytes: bytes)None[source]¶

Loads model_as_str and decodes into the class NowcastingModel.

Parameters

model_as_bytes – a binary variable, indicating whether to read as bytes.

plot()[source]¶

Raises: NotImplementedError(“Subclasses should implement this!”)。

predict(model=None, df=None, **kwargs)[source]¶

Predicts the time series in the future.

Nowcasting forecasts at the time unit of step ahead. This is in order to keep precision and different from usual algorithms. If model or df are overwritten in the function, it won’t use the internal ones.

Parameters
  • model – An external sklearn model.

  • df – An external dataset.

Returns

A float variable, the forecast at future step.

save_model()bytes[source]¶

Saves sklearn model as bytes.

class kats.models.nowcasting.nowcasting.NowcastingParams(step: int = 1, **kwargs)[source]¶

Bases: kats.consts.Params

The class for Nowcasting Parameters.

Takes parameters for class NowcastingModel.

step¶

An integer indicating how many steps ahead we are forecasting. Default is 1.

validate_params()[source]¶

Raises: NotImplementedError(“Subclasses should implement this!”).