Configuration
Every stage of mobts is controlled by small configuration dataclasses with sensible defaults. This page lists what each one controls and how to override it.
Preprocessing configuration
PreprocessConfig
Controls the always-on measurement-error rules described in Preprocessing.
Field |
Default |
Meaning |
|---|---|---|
|
|
Absolute low-count threshold (daily) |
|
|
Low-count threshold as a fraction of the counter’s median |
|
|
Minimum consecutive low-count days before they’re nulled |
|
|
Max allowed rate of zero observations for an hour to be considered a real zero (hourly) |
|
|
Minimum consecutive zero hours before they’re nulled |
|
|
Max length of a real-looking “island” surrounded by gaps to still be nulled |
|
|
Minimum surrounding gap length for the island rule above to apply |
Fixed, not currently overridable: night_hours ([1, 2, 3, 4, 5, 6]). The hours excluded from the hourly zero-rate check.
STLConfig (preprocessing)
Parameters for the STL decomposition used to compute each observation’s outlier score. Only applies to daily data .Hourly outlier scoring uses a different, lighter-weight method.
Field |
Default |
|---|---|
|
|
|
|
OutlierConfig
The threshold an outlier score has to cross to be flagged and replaced with NaN.
Field |
Default |
|---|---|
|
|
|
|
PlotConfig
Cosmetic and sampling settings for plot_outliers().
Field |
Default |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default_max_counters is only used when plot_outliers() is called without an explicit counters list or max_counters value .It caps how many counters get randomly sampled for the plot in that case.
PipelineConfig
Aggregates all of the above into one object, passed to preprocess() as a whole:
from mobts import preprocess
from mobts.configs.config_preprocessing import PipelineConfig, PreprocessConfig, OutlierConfig
custom_cfg = PipelineConfig(
preprocess=PreprocessConfig(low_abs_daily=10),
outliers=OutlierConfig(threshold_daily=15),
)
pp = preprocess(cfg=custom_cfg)
You only need to override the sub-config(s) you actually want to change. Anything you do not set keeps its default.
Imputation configuration
Imputation doesn’t have a single aggregating config object. Each config is passed to impute() individually.
STLConfig (imputation)
A different class from the preprocessing STLConfig above, despite the same name .This one controls the STL-based gap-filling used as imputation’s univariate fallback.
Field |
Default |
|---|---|
|
|
|
|
Fixed, not currently overridable: clip_lower (0), stl_robust (False), stl_season_daily (7), stl_season_hourly (168).
DonorsConfig
Thresholds governing donor eligibility and selection for the regression and scaled-median methods.
Field |
Default |
Meaning |
|---|---|---|
|
|
Fraction of correlated counters considered as candidate donors |
|
|
Maximum number of donors used per target counter |
|
|
Minimum overlapping history required between target and donors |
|
|
Minimum length of the missing period for coverage checks to apply |
|
|
Minimum donor coverage required over the missing period |
|
|
Minimum overlap required specifically for scaled-median imputation |
OutputConfig
Names of the output columns imputation produces, and the labels written into imputation_method.
Field |
Default |
|---|---|
|
|
|
|
|
|
|
|
|
|
Fixed, not currently overridable: col_intp ('count_intp'), an internal interpolation column not present in final output.
Note
Column names containing / or () (the current col_reg_imputed/col_sm_imputed/col_stl_imputed/col_final defaults) work fine with normal pandas indexing (df['multi-variate(regression)']), but will break df.query()/df.eval() unless backtick-escaped, and can’t be accessed as attributes (df.count_imputed/clean is not valid Python).
Putting it together
from mobts import impute
from mobts.configs.config_imputation import STLConfig, OutputConfig
imp = impute(
stl_cfg=STLConfig(rolling_median_window=3),
out_cfg=OutputConfig(col_final='final_count'),
)