category
forecaster_common
Shared predicates for forecaster diagnostics, dataset validation, differencing, lag construction, error metrics, seasonal adjustment, and baselines.
logtalk_load(time_series_protocols(loader))staticPublic predicates
(no local declarations; see entity ancestors if any)
Protected predicates
forecaster_diagnostics_data/2
Hook predicate that importing forecaster implementations must define in order to expose diagnostics metadata. A default implementation is provided that assumes the diagnostics list is the last argument of the forecaster term; concrete implementations following that convention do not need to override it.
staticforecaster_diagnostics_data(Forecaster,Diagnostics)forecaster_diagnostics_data(+compound,-list(compound)) - oneforecaster_export_template/4
Hook predicate that importing forecaster implementations must define in order to expose the exported forecaster template for a given functor.
staticforecaster_export_template(Dataset,Forecaster,Functor,Template)forecaster_export_template(+object_identifier,+compound,+atom,-callable) - oneforecaster_term_template/2
Hook predicate that importing forecaster implementations must define in order to expose the learned forecaster term template used by pretty-printing helpers.
staticforecaster_term_template(Forecaster,Template)forecaster_term_template(+compound,-callable) - oneprint_forecaster_template/1
Pretty-printing helper predicate used by importing forecaster implementations to show the learned forecaster term template.
staticprint_forecaster_template(Forecaster)print_forecaster_template(+compound) - onedataset_series/2
Collects the dataset time-ordered observation values. Checks that the observation indices form a complete, gap-free, 1-based sequence and that the declared series length matches the observed length.
staticdataset_series(Dataset,Series)dataset_series(+object_identifier,-list) - one_or_errordomain_error(non_empty_series,Dataset)domain_error(series_index_sequence,Dataset)instantiation_errortype_error(integer,DeclaredLength)domain_error(positive_integer,DeclaredLength)consistency_error(series_length,DeclaredLength,ObservedLength)evaluation_error(Error)check_series/2
Checks that a time series is non-empty and that every observation value is a number.
staticcheck_series(Dataset,Series)check_series(+object_identifier,+list) - one_or_errorSeries is a partial list or a list with an element which is a variable:instantiation_errorValue of the Series list is neither a variable nor a number:type_error(number,Value)Series is empty:domain_error(non_empty_series,Dataset)check_series/3
Checks that a time series is non-empty and that every observation value is of one of the given types.
staticcheck_series(Dataset,Series,Types)check_series(+object_identifier,+list,+list) - one_or_errorSeries is a partial list:instantiation_errorValue of the Series list is neither a variable nor a number:domain_error(types(Types),Value)Series is empty:domain_error(non_empty_series,Dataset)check_series_length/3
Checks that a time series has at least the given minimum number of observations.
staticcheck_series_length(Dataset,Series,MinimumLength)check_series_length(+object_identifier,+list,+non_negative_integer) - one_or_errorMinimumLength is a variable:instantiation_errorMinimumLength is neither a variable nor an integer:type_error(integer,MinimumLength)MinimumLength is an integer but is negative:domain_error(non_negative_integer,MinimumLength)Series is shorter than MinimumLength:domain_error(series_length,Dataset)check_observation/1
Checks that an observation is a number or an unbound variable representing a missing observation.
staticcheck_observation(Observation)check_observation(@term) - one_or_errorObservation is neither a variable nor a number:type_error(number,Observation)series_observation_summary/4
Returns the elapsed length, numeric observation count, and numeric sum of a series. Unbound observations are counted in the length only and are not instantiated. An empty list has zero length, count, and sum.
staticseries_observation_summary(Series,Length,ObservedCount,Sum)series_observation_summary(+list,-non_negative_integer,-non_negative_integer,-number) - one_or_errorSeries is a variable or a partial list:instantiation_errorSeries is neither a variable nor a list:type_error(list,Series)type_error(number,Observation)evaluation_error(Error)normalize_missing_series/3
Copies numeric-or-unbound observations, sharing a fresh variable among missing positions without binding input variables.
staticnormalize_missing_series(Series,Normalized,Missing)normalize_missing_series(+list,-list,-term) - one_or_errorinstantiation_errortype_error(list,Series)type_error(number,Value)indexed_series_observations/3
Collects known numeric values with their original one-based time indices.
staticindexed_series_observations(Series,Indices,Values)indexed_series_observations(+list,-list(positive_integer),-list(number)) - one_or_errorinstantiation_errortype_error(list,Series)type_error(number,Value)evaluation_error(Error)residual_fitted_values/3
Reconstructs aligned pre-update fits from numeric-or-unbound observations and residuals after the first known initialization anchor. Missing positions and the anchor have fresh independent unbound output placeholders.
staticresidual_fitted_values(Series,Residuals,Values)residual_fitted_values(+list,+list(number),-list) - one_or_errorinstantiation_errortype_error(list,List)type_error(number,Value)domain_error(residual_count,Residuals)evaluation_error(Error)valid_residual_history/5
Validates ground parallel numeric residuals and strictly increasing original indices after the initialization anchor. Both lists must match the scored count. The caller validates finiteness; this predicate does not reconstruct error totals or certify historical observations.
staticvalid_residual_history(Residuals,Indices,Anchor,Length,ScoredCount)valid_residual_history(@list,@list,@positive_integer,@positive_integer,@non_negative_integer) - zero_or_one_or_errorevaluation_error(Error)base_forecaster_diagnostics/5
Builds the common part of a forecaster diagnostics metadata list, combined with implementation-specific extra diagnostics terms.
staticbase_forecaster_diagnostics(Model,TrainingSeriesLength,Options,ExtraDiagnostics,Diagnostics)base_forecaster_diagnostics(+atom,+integer,+list(compound),+list(compound),-list(compound)) - onevalid_forecaster_metadata/2
True when diagnostics metadata contains the expected model term.
staticvalid_forecaster_metadata(Model,Diagnostics)valid_forecaster_metadata(+atom,+list(compound)) - zero_or_onevalid_forecaster_metadata/3
True when diagnostics metadata contains the expected model term and records the given effective options.
staticvalid_forecaster_metadata(Model,Options,Diagnostics)valid_forecaster_metadata(+atom,+list(compound),+list(compound)) - zero_or_onereplace_diagnostic/4
Replaces the value of the first unary diagnostic with the given name, preserving order. Fails when no such diagnostic exists.
staticreplace_diagnostic(Name,Value,Diagnostics,UpdatedDiagnostics)replace_diagnostic(+atom,+term,+list(compound),-list(compound)) - zero_or_oneupdated_observation_diagnostics/3
Updates the training length, update count, observed count, and missing count of validated diagnostics after a numeric or missing observation, preserving metadata order and all other diagnostics. Requires existing non-negative integer counters.
staticupdated_observation_diagnostics(Diagnostics,Observation,UpdatedDiagnostics)updated_observation_diagnostics(+list(compound),@term,-list(compound)) - one_or_errorObservation is neither a variable nor a number:type_error(number,Observation)evaluation_error(Error)difference_series/2
Computes the first-order differences of a series: Differences[i] = Series[i+1] - Series[i]. The result has one fewer element than Series.
staticdifference_series(Series,Differences)difference_series(+list(number),-list(number)) - one_or_errorSeries is empty:domain_error(non_empty_series,Series)integrate_series/3
Reconstructs a series of levels from a series of differences and a starting base value (typically the last observed original value), by cumulative summing. Used to undo difference_series/2 on forecasted differences.
staticintegrate_series(Differences,Base,Series)integrate_series(+list(number),+number,-list(number)) - onelagged_rows/3
Builds a list of Lags-Target rows from a series, where Lags is a list of the Order most recent values preceding Target, most recent first ([X(t-1), X(t-2), ..., X(t-Order)]-X(t)). Requires the series to have more than Order observations.
staticlagged_rows(Series,Order,Rows)lagged_rows(+list(number),+positive_integer,-list(pair)) - one_or_errorOrder is a variable:instantiation_errorOrder is neither a variable nor an integer:type_error(integer,Order)Order is an integer but is not positive:domain_error(positive_integer,Order)Series has Order or fewer observations:domain_error(series_length,Series)accumulate_forecast_error/4
Adds one numeric actual/prediction error to validated forecast_error_totals(Count, AbsoluteSum, SquaredSum), without retaining observations. Requires a non-negative integer count and non-negative numeric sums; forecast_error_totals(0,0,0) initializes accumulation. Missing observations must be skipped by the caller.
staticaccumulate_forecast_error(Actual,Prediction,Totals,UpdatedTotals)accumulate_forecast_error(+number,+number,+compound,-compound) - one_or_errorActual or Prediction is a variable:instantiation_errorActual or Prediction is not a number:type_error(number,Value)evaluation_error(Error)forecast_error_metrics/3
Computes MAE and RMSE from validated forecast_error_totals(Count, AbsoluteSum, SquaredSum). Requires non-negative numeric sums and a positive integer count. Does not retain or reconstruct actual/predicted observations.
staticforecast_error_metrics(Totals,MAE,RMSE)forecast_error_metrics(+compound,-float,-float) - one_or_errorinstantiation_errortype_error(integer,Count)domain_error(positive_integer,Count)evaluation_error(Error)mean_absolute_error/3
Computes the mean absolute error (MAE) between actual and predicted value lists of matching length.
staticmean_absolute_error(Actual,Predicted,MAE)mean_absolute_error(+list(number),+list(number),-float) - one_or_errordomain_error(non_empty_series,Series)consistency_error(same_length,Actual,Predicted)root_mean_squared_error/3
Computes the root mean squared error (RMSE) between actual and predicted value lists of matching length.
staticroot_mean_squared_error(Actual,Predicted,RMSE)root_mean_squared_error(+list(number),+list(number),-float) - one_or_errordomain_error(non_empty_series,Series)consistency_error(same_length,Actual,Predicted)mean_absolute_percentage_error/3
Computes the mean absolute percentage error (MAPE), as a percentage, between actual and predicted value lists of matching length.
staticmean_absolute_percentage_error(Actual,Predicted,MAPE)mean_absolute_percentage_error(+list(number),+list(number),-float) - one_or_errordomain_error(non_empty_series,Series)consistency_error(same_length,Actual,Predicted)evaluation_error(zero_divisor)naive_forecast/3
Repeats the last observed series value Horizon times (the naive/persistence baseline forecast). A zero horizon returns an empty list.
staticnaive_forecast(Series,Horizon,Forecasts)naive_forecast(+list(number),+non_negative_integer,-list(number)) - one_or_errorHorizon is a variable:instantiation_errorHorizon is neither a variable nor an integer:type_error(integer,Horizon)Horizon is an integer but is negative:domain_error(non_negative_integer,Horizon)constant_forecast/3
Repeats a value for the given forecast horizon. A zero horizon returns an empty list.
staticconstant_forecast(Value,Horizon,Forecasts)constant_forecast(+number,+non_negative_integer,-list(number)) - one_or_errorHorizon is a variable:instantiation_errorHorizon is neither a variable nor an integer:type_error(integer,Horizon)Horizon is an integer but is negative:domain_error(non_negative_integer,Horizon)linear_trend_forecast/4
Forecasts Last + Step * Slope for steps one through the horizon. A zero horizon returns an empty list.
staticlinear_trend_forecast(Last,Slope,Horizon,Forecasts)linear_trend_forecast(+number,+number,+non_negative_integer,-list(number)) - one_or_errorHorizon, Last, or Slope is a variable:instantiation_errorHorizon is neither a variable nor an integer:type_error(integer,Horizon)Horizon is an integer but is negative:domain_error(non_negative_integer,Horizon)Last is neither a variable nor a number:type_error(number,Last)Slope is neither a variable nor a number:type_error(number,Slope)evaluation_error(Error)check_forecast_horizon/1
Checks that a forecast horizon is a non-negative integer.
staticcheck_forecast_horizon(Horizon)check_forecast_horizon(+non_negative_integer) - one_or_errorHorizon is a variable:instantiation_errorHorizon is neither a variable nor an integer:type_error(integer,Horizon)Horizon is an integer but is negative:domain_error(non_negative_integer,Horizon)seasonal_naive_forecast/4
Repeats the last full seasonal cycle of Frequency observations, cycling as needed to cover Horizon forecasts (the seasonal naive baseline forecast).
staticseasonal_naive_forecast(Series,Frequency,Horizon,Forecasts)seasonal_naive_forecast(+list(number),+positive_integer,+non_negative_integer,-list(number)) - one_or_errorFrequency is a variable:instantiation_errorFrequency is neither a variable nor an integer:type_error(integer,Frequency)Frequency is an integer but is not positive:domain_error(positive_integer,Frequency)Horizon is a variable:instantiation_errorHorizon is neither a variable nor an integer:type_error(integer,Horizon)Horizon is an integer but is negative:domain_error(non_negative_integer,Horizon)Series has fewer than Frequency observations:domain_error(series_length,Series)check_frequency/1
Checks that a seasonal frequency is a positive integer.
staticcheck_frequency(Frequency)check_frequency(+positive_integer) - one_or_errorFrequency is a variable:instantiation_errorFrequency is neither a variable nor an integer:type_error(integer,Frequency)Frequency is an integer but is not positive:domain_error(positive_integer,Frequency)seasonal_autocorrelation_test/4
Tests original-lag available-pair autocorrelations using the known observation count and requiring two known pairs at every tested lag.
staticseasonal_autocorrelation_test(Series,Frequency,Statistic,Seasonal)seasonal_autocorrelation_test(+list,+positive_integer,-number,-boolean) - one_or_errorinstantiation_errortype_error(number,Value)type_error(list,Series)domain_error(non_empty_series,Series)type_error(integer,Frequency)domain_error(positive_integer,Frequency)evaluation_error(Error)classical_seasonal_adjustment/5
Deseasonalizes known values using complete centered windows and normalized phase factors, preserving missing observations as unbound variables.
staticclassical_seasonal_adjustment(Series,Frequency,Method,AdjustedSeries,Factors)classical_seasonal_adjustment(+list,+positive_integer,+atom,-list,-list(number)) - one_or_errorinstantiation_errortype_error(number,Value)type_error(list,Series)domain_error(non_empty_series,Series)type_error(integer,Frequency)domain_error(positive_integer,Frequency)domain_error(seasonal_frequency,Frequency)domain_error(series_length,Series)domain_error(seasonal_adjustment_method,Method)domain_error(insufficient_seasonal_phase_observations,Phase)domain_error(positive_number,Value)evaluation_error(Error)restore_seasonality/5
Adds or multiplies a seasonal cycle, advancing phase through missing positions without instantiating them.
staticrestore_seasonality(Method,Factors,StartPhase,Values,RestoredValues)restore_seasonality(+atom,+list(number),+positive_integer,+list,-list) - one_or_errorinstantiation_errortype_error(number,Value)type_error(list,List)domain_error(non_empty_series,Factors)domain_error(seasonal_adjustment_method,Method)type_error(integer,StartPhase)domain_error(positive_integer,StartPhase)domain_error(seasonal_phase,StartPhase)domain_error(positive_number,Value)evaluation_error(Error)Private predicates
sorted_observations/5
Validates sorted indices without binding them while collecting values and counting observations.
staticsorted_observations(Pairs,Dataset,ExpectedIndex,Length,Series)sorted_observations(@list(pair),+object_identifier,+positive_integer,-non_negative_integer,-list) - one_or_errorinstantiation_errordomain_error(series_index_sequence,Dataset)evaluation_error(Error)normalize_missing_values/4
Copies known numbers and replaces unbound inputs with a fresh shared variable.
staticnormalize_missing_values(Series,Missing,Context,Normalized)normalize_missing_values(+list,-term,+term,-list) - one_or_errortype_error(number,Value)indexed_known_values/5
Extracts known observations while retaining elapsed positions.
staticindexed_known_values(Series,Index,Context,Indices,Values)indexed_known_values(+list,+positive_integer,+term,-list,-list) - one_or_errortype_error(number,Value)evaluation_error(Error)check_numeric_residuals/2
Checks residual numbers without completing lists or binding entries.
staticcheck_numeric_residuals(Residuals,Context)check_numeric_residuals(+list,+term) - one_or_errorinstantiation_errortype_error(number,Value)aligned_residual_fits/5
Consumes residuals only at known positions after the initialization anchor, failing on a count mismatch.
staticaligned_residual_fits(Series,Residuals,AnchorSeen,Context,Values)aligned_residual_fits(+list,+list(number),+boolean,+term,-list) - zero_or_one_or_errortype_error(number,Value)evaluation_error(Error)valid_residual_positions/3
Checks original residual positions in strict chronological order within the elapsed length.
staticvalid_residual_positions(Indices,Previous,Length)valid_residual_positions(+list(integer),+integer,+positive_integer) - zero_or_one_or_errorevaluation_error(Error)seasonal_centered_values/5
Centers validated observations and accumulates squared deviations.
staticseasonal_centered_values(Series,Mean,Centered,Variance0,Variance)seasonal_centered_values(+list(number),+number,-list(number),+number,-number) - one_or_errorevaluation_error(Error)seasonal_lag_scores/7
Accumulates earlier squared autocorrelations and the seasonal-lag score.
staticseasonal_lag_scores(Lag,Frequency,Centered,Variance,Squares0,Squares,Last)seasonal_lag_scores(+positive_integer,+positive_integer,+list(number),+number,+number,-number,-number) - one_or_errorevaluation_error(Error)seasonal_covariance/4
Accumulates products of aligned centered observations.
staticseasonal_covariance(Suffix,Series,Covariance0,Covariance)seasonal_covariance(+list(number),+list(number),+number,-number) - one_or_errorevaluation_error(Error)seasonal_check_method/1
Checks the seasonal adjustment method without binding it.
staticseasonal_check_method(Method)seasonal_check_method(@term) - one_or_errorinstantiation_errordomain_error(seasonal_adjustment_method,Method)seasonal_positive_values/1
Requires strictly positive validated numeric values.
staticseasonal_positive_values(Values)seasonal_positive_values(+list(number)) - one_or_errordomain_error(positive_number,Value)evaluation_error(Error)seasonal_window_means/5
Computes successive moving averages with a rolling sum.
staticseasonal_window_means(Entering,Leaving,Frequency,Sum,Means)seasonal_window_means(+list(number),+list(number),+positive_integer,+number,-list(number)) - one_or_errorevaluation_error(Error)seasonal_center_even/2
Centers even-period moving averages using adjacent means.
staticseasonal_center_even(Means,Centered)seasonal_center_even(+list(number),-list(number)) - one_or_errorevaluation_error(Error)seasonal_deviations/4
Computes interior differences or ratios against centered trend estimates.
staticseasonal_deviations(Trends,Values,Method,Deviations)seasonal_deviations(+list(number),+list(number),+atom,-list(number)) - one_or_errordomain_error(positive_number,Value)evaluation_error(Error)seasonal_fold_cycles/3
Accumulates complete and partial cycles into phase buckets.
staticseasonal_fold_cycles(Values,Buckets0,Buckets)seasonal_fold_cycles(+list,+list(compound),-list(compound)) - one_or_errorevaluation_error(Error)seasonal_bucket_means/2
Computes phase means from nonempty phase totals.
staticseasonal_bucket_means(Buckets,Means)seasonal_bucket_means(+list(compound),-list(number)) - one_or_errorevaluation_error(Error)seasonal_normalize/4
Normalizes phase factors to zero or unit mean.
staticseasonal_normalize(Values,Method,Mean,Factors)seasonal_normalize(+list(number),+atom,+number,-list(number)) - one_or_errordomain_error(positive_number,Value)evaluation_error(Error)seasonal_inverse_factors/3
Negates additive factors or reciprocates positive multiplicative factors.
staticseasonal_inverse_factors(Factors,Method,Inverses)seasonal_inverse_factors(+list(number),+atom,-list(number)) - one_or_errorevaluation_error(Error)seasonal_restore_values/5
Restores validated values while cycling through phase factors.
staticseasonal_restore_values(Values,Method,Factors,Cycle,Restored)seasonal_restore_values(+list,+atom,+list(number),+list(number),-list) - one_or_errorevaluation_error(Error)seasonal_complete_autocorrelation_test/4
Computes the original complete-data seasonality statistic for validated inputs.
staticseasonal_complete_autocorrelation_test(Series,Frequency,Statistic,Seasonal)seasonal_complete_autocorrelation_test(+list(number),+positive_integer,-number,-boolean) - one_or_errorevaluation_error(Error)classical_complete_seasonal_adjustment/5
Computes classical seasonal factors for validated complete data.
staticclassical_complete_seasonal_adjustment(Series,Frequency,Method,Adjusted,Factors)classical_complete_seasonal_adjustment(+list(number),+positive_integer,+atom,-list(number),-list(number)) - one_or_errordomain_error(positive_number,Value)evaluation_error(Error)seasonal_gap_centered/4
Centers known values without removing gaps.
staticseasonal_gap_centered(Series,Mean,Centered,Variance)seasonal_gap_centered(+list,+number,-list,-number) - one_or_errorevaluation_error(Error)seasonal_gap_lags/7
Accumulates original-lag scores, failing when fewer than two pairs are available.
staticseasonal_gap_lags(Lag,Frequency,Centered,Variance,Squares0,Squares,Last)seasonal_gap_lags(+positive_integer,+positive_integer,+list,+number,+number,-number,-number) - zero_or_one_or_errorevaluation_error(Error)seasonal_gap_covariance/4
Sums centered products and counts pairs with both positions known.
staticseasonal_gap_covariance(Suffix,Series,Covariance,Pairs)seasonal_gap_covariance(+list,+list,-number,-non_negative_integer) - one_or_errorevaluation_error(Error)seasonal_gap_windows/5
Computes moving averages with rolling sums and missing counts, marking incomplete windows.
staticseasonal_gap_windows(Entering,Leaving,Frequency,Window,Means)seasonal_gap_windows(+list,+list,+positive_integer,+compound,-list) - one_or_errorevaluation_error(Error)seasonal_gap_even/2
Centers adjacent complete windows, requiring the full even-period support.
staticseasonal_gap_even(Means,Trends)seasonal_gap_even(+list,-list) - one_or_errorevaluation_error(Error)seasonal_gap_deviations/4
Computes only known deviations with complete trend support, retaining phase positions.
staticseasonal_gap_deviations(Trends,Values,Method,Deviations)seasonal_gap_deviations(+list,+list,+atom,-list) - one_or_errordomain_error(positive_number,Value)evaluation_error(Error)seasonal_accumulate_cycle/4
Advances a phase bucket for every position, skipping missing contributions.
staticseasonal_accumulate_cycle(Values,Buckets,Updated,Rest)seasonal_accumulate_cycle(+list,+list(compound),-list(compound),-list) - one_or_errorevaluation_error(Error)seasonal_check_buckets/2
Reports the lowest absolute phase lacking an estimable seasonal deviation.
staticseasonal_check_buckets(Buckets,Phase)seasonal_check_buckets(+list(compound),+positive_integer) - one_or_errordomain_error(insufficient_seasonal_phase_observations,Phase)evaluation_error(Error)Operators
(none)