TSOutlierDetection

class hana_ai.tools.df_tools.ts_outlier_detection_tools.TSOutlierDetection(connection_context: ConnectionContext, return_direct: bool = False)

This tool detects outliers in time series data.

Parameters:
connection_contextConnectionContext

Connection context to the HANA database.

Returns:
str

The outliers in the time series data and the statistics of the detection.

Note

args_schema is used to define the schema of the inputs as follows:

Field

Description

select_statement

the SQL select statement to execute. If not provided, ask the user. Do not guess.

key

the key of the dataset. If not provided, ask the user. Do not guess.

endog

the endog of the dataset. If not provided, ask the user. Do not guess.

auto

whether to use auto outlier detection, it is optional

detect_intermittent_ts

whether to detect intermittent time series, it is optional

smooth_method

the smoothing method for the time series chosen from {'no', 'median', 'loess'}, it is optional

window_size

odd number, the window size for median filter, not less than 3, it is optional

loess_lag

odd number, the lag for LOESS, not less than 3, it is optional

current_value_flag

whether to take the current data point when using LOESS smoothing method, it is optional

outlier_method

the outlier detection method chosen from {'z1', 'z2', 'mad', 'iqr', 'isolationforest', 'dbscan'}, it is optional

threshold

the threshold for outlier detection, it is optional

detect_seasonality

whether to detect seasonality, it is optional

alpha

the criterion for the autocorrelation coefficient, it is optional

extrapolation

whether to extrapolate the endpoints, it is optional

periods

the number of periods for seasonality, it is optional

random_state

specifies the seed for random number generator only valid for isolationforest, it is optional

n_estimators

the number of trees in the forest only valid for isolationforest, it is optional

max_samples

specifies the number of samples to draw from input to train each tree only valid for isolationforest, it is optional

bootstrap

whether to use bootstrap samples when building trees only valid for isolationforest, it is optional

contamination

the proportion of outliers in the data set only valid for isolationforest, it is optional

minpts

the number of points in a neighborhood for a point to be considered as a core point only valid for dbscan, it is optional

eps

the maximum distance between two samples for one to be considered as in the neighborhood of the other only valid for dbscan, it is optional

distance_method

the distance method for dbscan chosen from {'manhattan', 'euclidean', 'minkowski', 'chebyshev', 'standardized_euclidean', 'cosine'}, it is optional

dbscan_normalization

whether to normalize the data before dbscan, it is optional

dbscan_outlier_from_cluster

specifies how to take outliers from DBSCAN result, it is optional

thread_ratio

the ratio of threads to use for parallel processing, it is optional

residual_usage

specifies which residual to output chosen from {'outlier_detection', 'outlier_correction'}, it is optional

voting_config

the configuration for voting, it is optional

voting_outlier_method_criterion

the criterion for voting outlier method, it is optional

name: str

Name of the tool.

description: str

Description of the tool.

connection_context: ConnectionContext

Connection context to the HANA database.