Quickstart
This is the minimal path from a raw dataset to a completed time series. For details on what your input data needs to look like, see Data format.
import pandas as pd
from mobts import preprocess
from mobts import impute
df = pd.read_csv('your_data.csv')
counter_col = 'counter_id' # column identifying the counter/station
timestamp_col = 'timestamp' # column with the observation timestamp
count_col = 'count_number' # column with the observed count
# Step 1 - preprocess: detect and remove suspicious observations
pp = preprocess()
df_preprocessed = pp.run(
df_raw=df,
counter_col=counter_col,
timestamp_col=timestamp_col,
count_col=count_col,
)
# Step 2 - impute: fill missing values
imp = impute()
df_imputed = imp.run(
df=df_preprocessed,
counter_col=counter_col,
timestamp_col=timestamp_col,
count_col=count_col,
)
The completed time-series is in the count_imputed/clean column of df_imputed.
By default, both steps assume hourly data. If your data is daily, pass data_is_hourly=False to pp.run().
Note
The default preprocessing threshold was tuned on a specific dataset and may not suit yours as-is. Before trusting the preprocessed output, inspect the detected outliers and adjust the threshold if needed. See the example notebook for how.
Next steps
Preprocessing and Imputation explain what each stage does and how methods are chosen.
Pipeline notes covers some notes on the functions and their usages in more detail.
Configuration covers every threshold and configuration you can override.