Core Module Documentation#
- class neuralprophet.components.trend.base.Trend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- abstract add_regularization()#
add regularization to loss
- abstract property get_trend_deltas#
trend deltas for regularization.
update if trend is modelled differently
- class neuralprophet.components.trend.linear.GlobalLinearTrend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- forward(t, meta)#
Computes trend based on model configuration.
- Parameters
t (torch.Tensor float) – normalized time, dim: (batch, n_forecasts)
meta (dict) –
- Metadata about the all the samples of the model input batch. Contains the following:
df_name
(list, str), time series ID corresponding to each sample of the input batch.
- Returns
Trend component, same dimensions as input t
- Return type
torch.Tensor
- class neuralprophet.components.trend.linear.LinearTrend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- add_regularization()#
add regularization to loss
- property get_trend_deltas#
trend deltas for regularization.
update if trend is modelled differently
- class neuralprophet.components.trend.linear.LocalLinearTrend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- forward(t, meta)#
Computes trend based on model configuration.
- Parameters
t (torch.Tensor float) – normalized time, dim: (batch, n_forecasts)
meta (dict) –
- Metadata about the all the samples of the model input batch. Contains the following:
df_name
(list, str), time series ID corresponding to each sample of the input batch.
- Returns
Trend component, same dimensions as input t
- Return type
torch.Tensor
- class neuralprophet.components.trend.piecewise_linear.GlobalPiecewiseLinearTrend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- compute_k_t(current_segment, past_next_changepoint, meta_name_tensor_one_hot=None)#
This method overrides the method from the PiecewiseLinear class.
- compute_m_t(current_segment, past_next_changepoint, meta_name_tensor_one_hot=None)#
This method overrides the method from the PiecewiseLinear class.
- compute_trend(t, k_t, m_t, meta_name_tensor_one_hot=None)#
This method overrides the method from the PiecewiseLinear class.
- class neuralprophet.components.trend.piecewise_linear.LocalPiecewiseLinearTrend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- compute_k_t(current_segment, past_next_changepoint, meta_name_tensor_one_hot)#
This method overrides the method from the PiecewiseLinear class.
- compute_m_t(current_segment, past_next_changepoint, meta_name_tensor_one_hot=None)#
This method overrides the method from the PiecewiseLinear class.
- compute_trend(t, k_t, m_t, meta_name_tensor_one_hot=None)#
This method overrides the method from the PiecewiseLinear class.
- class neuralprophet.components.trend.piecewise_linear.PiecewiseLinearTrend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- add_regularization()#
add regularization to loss
- compute_k_t(current_segment, past_next_changepoint, meta_name_tensor_one_hot)#
For segmentwise, k_t is the model parameter representing the trend slope(actually, trend slope-k_0) in the current_segment at time t (for each sample of the batch).
For not segmentwise, k_t is the model parameter representing the difference between trend slope in the current_segment at time t and the trend slope in the previous segment (for each sample of the batch).
- Parameters
current_segment (torch.Tensor, int) – segment corresponding to time t (batch_size, n_forecasts, segments (+ 1))
past_next_changepoint (torch.Tensor, bool) – whether the a changepoint >= time t (batch_size, n_forecasts, segments (+ 1))
meta_name_tensor_one_hot (torch.Tensor, float) –
Metadata about the all the samples of the model input batch.
- Contains the following:
df_name
(list, str), time series name ID corresponding to each sample of the input batch.
- Returns
k_t, ( batch_size, n_forecasts, quantiles_size)
- Return type
torch.Tensor
- compute_m_t(current_segment, past_next_changepoint, meta_name_tensor_one_hot)#
m_t represents the value at the origin(t=0) that we would need to have so that if we use (k_t + k_0) as slope, we reach the same value at time = chagepoint_start_of_segment_i as we would reach by following the segmented slope (having in each segment the slope trend_deltas(i) + k_0)
- Parameters
current_segment (torch.Tensor, int) – segment corresponding to time t (batch_size, n_forecasts, segments (+ 1))
past_next_changepoint (torch.Tensor, bool) – whether the a changepoint >= time t (batch_size, n_forecasts, segments (+ 1))
meta_name_tensor_one_hot (torch.Tensor, float) –
Metadata about the all the samples of the model input batch.
- Contains the following:
df_name
(list, str), time series name ID corresponding to each sample of the input batch.
- Returns
m_t, ( batch_size, n_forecasts, quantiles_size)
- Return type
torch.Tensor
- compute_trend(t, k_t, m_t, meta_name_tensor_one_hot=None)#
This method computes the trend component of the model.
- Parameters
t (torch.Tensor, float) – time
k_t (torch.Tensor, int) – see compute_k_t
m_t (torch.Tensor, bool) – see compute_m_t
meta_name_tensor_one_hot (torch.Tensor, float) –
Metadata about the all the samples of the model input batch.
- Contains the following:
df_name
(list, str), time series name ID corresponding to each sample of the input batch.
- Returns
trend_component, ( batch_size, n_forecasts, quantiles_size)
- Return type
torch.Tensor
- forward(t, meta)#
Computes trend based on model configuration.
- Parameters
t (torch.Tensor float) – normalized time, dim: (batch, n_forecasts)
meta (dict) –
- Metadata about the all the samples of the model input batch. Contains the following:
df_name
(list, str), time series ID corresponding to each sample of the input batch.
- Returns
Trend component, same dimensions as input t
- Return type
torch.Tensor
- property get_trend_deltas#
trend deltas for regularization.
update if trend is modelled differently
- class neuralprophet.components.trend.static.StaticTrend(config, id_list, quantiles, num_trends_modelled, n_forecasts, device)#
- add_regularization()#
add regularization to loss
- forward(t, meta)#
Computes trend based on model configuration.
- Parameters
t (torch.Tensor float) – normalized time, dim: (batch, n_forecasts)
meta (dict) –
- Metadata about the all the samples of the model input batch. Contains the following:
df_name
(list, str), time series ID corresponding to each sample of the input batch.
- Returns
Trend component, same dimensions as input t
- Return type
torch.Tensor
- property get_trend_deltas#
trend deltas for regularization.
update if trend is modelled differently