Aggregators

Module of aggregators.

An aggregator combines multiple lists of anomalies into one.

class adtk.aggregator.AndAggregator[source]

Aggregator that identifies a time point as anomalous only if it is included in all the input anomaly lists.

Return type

None

aggregate(lists)

Aggregate multiple lists of anomalies into one.

Parameters

lists (pandas.DataFrame, a dict of Series/DataFrame, or a dict of lists) –

Anomaly lists to be aggregated.

  • If a pandas DataFrame, every column is a binary Series representing a type of anomaly.

  • If a dict of pandas Series/DataFrame, every value of the dict is a binary Series/DataFrame representing a type or some types of anomaly;

  • If a dict of list, every value of the dict is a type of anomaly as a list of events, where each event is represented as a pandas Timestamp if it is instantaneous or a 2-tuple of pandas Timestamps if it is a closed time interval.

Returns

Aggregated list of anomalies.

  • If input is a pandas DataFrame or a dict of Series/DataFrame, return a single binary pandas Series;

  • If input is a dict of lists, return a single list of events.

Return type

list or a binary pandas Series

get_params()

Get the parameters of this model.

Returns

Model parameters.

Return type

dict

predict(lists)

Aggregate multiple lists of anomalies into one.

Parameters

lists (pandas.DataFrame, a dict of Series/DataFrame, or a dict of lists) –

Anomaly lists to be aggregated.

  • If a pandas DataFrame, every column is a binary Series representing a type of anomaly.

  • If a dict of pandas Series/DataFrame, every value of the dict is a binary Series/DataFrame representing a type or some types of anomaly;

  • If a dict of list, every value of the dict is a type of anomaly as a list of events, where each event is represented as a pandas Timestamp if it is instantaneous or a 2-tuple of pandas Timestamps if it is a closed time interval.

Returns

Aggregated list of anomalies.

  • If input is a pandas DataFrame or a dict of Series/DataFrame, return a single binary pandas Series;

  • If input is a dict of lists, return a single list of events.

Return type

list or a binary pandas Series

set_params(**params)

Set the parameters of this model.

Parameters
  • **params – Model parameters to set.

  • params (Any) –

Return type

None

class adtk.aggregator.CustomizedAggregator(aggregate_func, aggregate_func_params=None)[source]

Aggregator derived from a user-given function and parameters.

Parameters
  • aggregate_func (function) –

    A function aggregating multiple types of anomaly.

    The first input argument must be a pandas DataFrame, a dict of pandas Series/DataFrame, or a dict of event lists.

    • If a pandas DataFrame, every column is a binary Series representing a type of anomaly.

    • If a dict of pandas Series/DataFrame, every value of the dict is a binary Series/DataFrame representing a type or some types of anomaly;

    • If a dict of list, every value of the dict is a type of anomaly as a list of events, where each event is represented as a pandas Timestamp if it is instantaneous or a 2-tuple of pandas Timestamps if it is a closed time interval.

    Optional input argument may be accepted through parameter aggregate_func_params.

    The output must be a list of pandas Timestamps.

    • If input is a pandas DataFrame or a dict of Series/DataFrame, return a single binary pandas Series;

    • If input is a dict of lists, return a single list of events.

  • aggregate_func_params (dict, optional) – Parameters of aggregate_func. Default: None.

Return type

None

aggregate(lists)

Aggregate multiple lists of anomalies into one.

Parameters

lists (pandas.DataFrame, a dict of Series/DataFrame, or a dict of lists) –

Anomaly lists to be aggregated.

  • If a pandas DataFrame, every column is a binary Series representing a type of anomaly.

  • If a dict of pandas Series/DataFrame, every value of the dict is a binary Series/DataFrame representing a type or some types of anomaly;

  • If a dict of list, every value of the dict is a type of anomaly as a list of events, where each event is represented as a pandas Timestamp if it is instantaneous or a 2-tuple of pandas Timestamps if it is a closed time interval.

Returns

Aggregated list of anomalies.

  • If input is a pandas DataFrame or a dict of Series/DataFrame, return a single binary pandas Series;

  • If input is a dict of lists, return a single list of events.

Return type

list or a binary pandas Series

get_params()

Get the parameters of this model.

Returns

Model parameters.

Return type

dict

predict(lists)

Aggregate multiple lists of anomalies into one.

Parameters

lists (pandas.DataFrame, a dict of Series/DataFrame, or a dict of lists) –

Anomaly lists to be aggregated.

  • If a pandas DataFrame, every column is a binary Series representing a type of anomaly.

  • If a dict of pandas Series/DataFrame, every value of the dict is a binary Series/DataFrame representing a type or some types of anomaly;

  • If a dict of list, every value of the dict is a type of anomaly as a list of events, where each event is represented as a pandas Timestamp if it is instantaneous or a 2-tuple of pandas Timestamps if it is a closed time interval.

Returns

Aggregated list of anomalies.

  • If input is a pandas DataFrame or a dict of Series/DataFrame, return a single binary pandas Series;

  • If input is a dict of lists, return a single list of events.

Return type

list or a binary pandas Series

set_params(**params)

Set the parameters of this model.

Parameters
  • **params – Model parameters to set.

  • params (Any) –

Return type

None

class adtk.aggregator.OrAggregator[source]

Aggregator that identifies a time point as anomalous as long as it is included in one of the input anomaly lists.

Return type

None

aggregate(lists)

Aggregate multiple lists of anomalies into one.

Parameters

lists (pandas.DataFrame, a dict of Series/DataFrame, or a dict of lists) –

Anomaly lists to be aggregated.

  • If a pandas DataFrame, every column is a binary Series representing a type of anomaly.

  • If a dict of pandas Series/DataFrame, every value of the dict is a binary Series/DataFrame representing a type or some types of anomaly;

  • If a dict of list, every value of the dict is a type of anomaly as a list of events, where each event is represented as a pandas Timestamp if it is instantaneous or a 2-tuple of pandas Timestamps if it is a closed time interval.

Returns

Aggregated list of anomalies.

  • If input is a pandas DataFrame or a dict of Series/DataFrame, return a single binary pandas Series;

  • If input is a dict of lists, return a single list of events.

Return type

list or a binary pandas Series

get_params()

Get the parameters of this model.

Returns

Model parameters.

Return type

dict

predict(lists)

Aggregate multiple lists of anomalies into one.

Parameters

lists (pandas.DataFrame, a dict of Series/DataFrame, or a dict of lists) –

Anomaly lists to be aggregated.

  • If a pandas DataFrame, every column is a binary Series representing a type of anomaly.

  • If a dict of pandas Series/DataFrame, every value of the dict is a binary Series/DataFrame representing a type or some types of anomaly;

  • If a dict of list, every value of the dict is a type of anomaly as a list of events, where each event is represented as a pandas Timestamp if it is instantaneous or a 2-tuple of pandas Timestamps if it is a closed time interval.

Returns

Aggregated list of anomalies.

  • If input is a pandas DataFrame or a dict of Series/DataFrame, return a single binary pandas Series;

  • If input is a dict of lists, return a single list of events.

Return type

list or a binary pandas Series

set_params(**params)

Set the parameters of this model.

Parameters
  • **params – Model parameters to set.

  • params (Any) –

Return type

None

adtk.aggregator.print_all_models()[source]

Print description of every model in this module.

Return type

None