elasticai.preprocessor._check_funcs#

Module Contents#

Classes#

MetricTimestamps

Class with metrics for comparing timestamps of predicted classes and true classes Attributes: f1_score: Float with F1-Score TP: Integer with true positives FP: Integer with false positives FN: Integer with false negatives

Functions#

check_key_elements

Function for checking if all elements are in key (logical AND)

check_string_equal_elements_all

Function for checking if all elements are in text string (logical AND)

check_string_equal_elements_any

Function for checking if elements are in text string (logical OR)

check_keylist_elements_all

Function for checking if all elements are in key list (logical AND)

check_keylist_elements_any

Function for checking if all elements are in key list (logical OR)

check_elem_unique

Function for checking if all elements are unique

check_value_range

Function for checking if value is within range

is_close

Function for checking if float value is in near of the target value

compare_timestamps

This function compares the timestamps of the predicted classes and the true classes and returns TP, FP, FN and new arrays which only contain the classes that have matched timestamps in both arrays. The function should be used before plotting a confusion matrix of the classes when working with actual data from the pipeline. Args: true_labels: List with true labels pred_labels: List with predicted labels window: Window size for acceptance rate Returns: Class MetricTimeStamps with metrics

API#

elasticai.preprocessor._check_funcs.check_key_elements(key: str, elements: list[str]) bool[source]#

Function for checking if all elements are in key (logical AND)

Parameters:
  • key – Key to check

  • elements – List of elements to check if available in key

Returns:

True if all elements are present in key

elasticai.preprocessor._check_funcs.check_string_equal_elements_all(text: str, elements: list[str]) bool[source]#

Function for checking if all elements are in text string (logical AND)

Parameters:
  • text – String with a text

  • elements – List of elements to check if available in text

Returns:

True if all elements are present in text

elasticai.preprocessor._check_funcs.check_string_equal_elements_any(text: str, elements: list[str]) bool[source]#

Function for checking if elements are in text string (logical OR)

Parameters:
  • text – String with a text

  • elements – List of elements to check if available in text

Returns:

True if any elements are present in text

elasticai.preprocessor._check_funcs.check_keylist_elements_all(keylist: list[str], elements: list[str]) bool[source]#

Function for checking if all elements are in key list (logical AND)

Parameters:
  • keylist – List with keys to check

  • elements – List with elements to check if available in key

Returns:

True if all elements are present in key

elasticai.preprocessor._check_funcs.check_keylist_elements_any(keylist: list[str], elements: list[str]) bool[source]#

Function for checking if all elements are in key list (logical OR)

Parameters:
  • keylist – List with keys to check

  • elements – List with elements to check if available in key

Returns:

True if any elements are present in key

elasticai.preprocessor._check_funcs.check_elem_unique(elements: list) bool[source]#

Function for checking if all elements are unique

Parameters:

elements – List of elements to check

Returns:

True if all elements are unique

elasticai.preprocessor._check_funcs.check_value_range(value: float | int, range: list[float | int]) bool[source]#

Function for checking if value is within range

Parameters:
  • value – Value to check (float or integer)

  • range – List with two values to indicate the range

Returns:

Boolean if value is in range

elasticai.preprocessor._check_funcs.is_close(value: float, target: float, tolerance: float = 0.05) bool[source]#

Function for checking if float value is in near of the target value

Parameters:
  • value – Float value to check

  • target – Target value

  • tolerance – Tolerance value [around target value]

class elasticai.preprocessor._check_funcs.MetricTimestamps[source]#

Class with metrics for comparing timestamps of predicted classes and true classes Attributes: f1_score: Float with F1-Score TP: Integer with true positives FP: Integer with false positives FN: Integer with false negatives

f1_score: float#

None

TP: int#

None

FP: int#

None

FN: int#

None

elasticai.preprocessor._check_funcs.compare_timestamps(true_labels: list, pred_labels: list, window: int = 2) elasticai.preprocessor._check_funcs.MetricTimestamps[source]#

This function compares the timestamps of the predicted classes and the true classes and returns TP, FP, FN and new arrays which only contain the classes that have matched timestamps in both arrays. The function should be used before plotting a confusion matrix of the classes when working with actual data from the pipeline. Args: true_labels: List with true labels pred_labels: List with predicted labels window: Window size for acceptance rate Returns: Class MetricTimeStamps with metrics