Skip to content

Clustering Betas

Methods that apply different clustering and outlier detection algorithms. Offers additional functions to convert console command arguments into variables to use in the function.

Warning

This function is optimized to be used by the console commandline tool

group_betas(beta_index, betas, scale_betas=False, cluster=None, detector=None, cluster_params=None, detector_params=None)

Base function to to group betas into groups, detect outliers. Provides that all different clustering and outlier detection algorythms are implemented in an easy to access environment. To select different clustering and outlier detection algoyrthms, please use appropriate KeywordTypes. A description of each function can be accessed with document_algorythm(keyword) A list of all functions can be accessed with list_detectors_and_clusters()

Parameters:

Name Type Description Default
beta_index

Array containing the file names specific to the betas with the same index in the beta array

required
betas

Numpy array containing the betas. Betas are expected to be of shape (samples, timestep, 3) The three entries per beta can either be dimesnions (x,y,z) or any three betas/eigenvalues

required
cluster

String specifying which clustering algorythm shall be applied. Use ClusterTypefor easier access

None
detector

String specifying which outlier detection algorythm shall be applied. Use DetectorType for easier access

None
cluster_params

Dictionary containing parameters for the clustering algorythms. See the sklearn documentation for the function to learn more.

None
detector_params

Dictionary containing parameters for the outlier detection algorythms. See the sklearn documentation for the function to learn more

None

Returns:

Name Type Description
beta_clusters list

List containing Numpy Arrays of betas in one cluster. If a detector was selected, or the clustering algorythm has its own outlier detection, the first entry in the list will be oultier betas

id_clusters list

List containing lists of beta ids. Each id corresponds to the beta in the same place in the beta_clusters list

err_msg str

Error message if wrong keywords for detector or cluster algorithms were used

Notes

document_algorithm: Prints docstring of each function into console list_detectors_and_clusters: Prints out all detection and clustering algorythms into console Sklearn Userguide chapter 2.3 Clustering: https://scikit-learn.org/stable/modules/clustering.html Detailed overview of different clustering algorythms Sklearn Examples outlier detection: https://scikit-learn.org/stable/auto_examples/plot_anomaly_comparison.html Example of different used outlier detection algorythms

create_cluster_arg_dict(args)

Determines which cluster to use and creates a python dictionary to use as cluster_params

Parameters:

Name Type Description Default
args Sequence[str]

List of strings containing parameters and arguments

required

Returns:

Name Type Description
cluster_type str

determines which cluster algorithm to use

cluster_arg_dict dict

dictionary containing arguments and values for specific cluster_type

err_msg str

message containing error, mostly unrecognised keywords

create_detector_arg_dict(args)

Determines which detector to use and creates a python dictionary to use as detector_params

Parameters:

Name Type Description Default
args Sequence[str]

List of strings containing parameters and arguments

required

Returns:

Name Type Description
detector_type str

determines which cluster algorithm to use

detector_arg_dict dict

dictionary containing arguments and values for specific cluster_type

err_mgs str

message containing error, mostly unrecognised keywords