tropea_clustering.OnionUni

class tropea_clustering.OnionUni(bins='auto', number_of_sigmas=2.0)[source]

Performs onion clustering on a data array.

Returns an array of integer labels, one for each signal sequence. Unclassified sequences are labelled “-1”.

Parameters:
state_list_

List of the identified states. Refer to the documentation of StateUni for accessing the information on the states.

Type:

List[StateUni]

labels_

Cluster labels for signal sequence. Unclassified points are given the label “-1”.

Type:

ndarray of shape (n_particles * n_seq,)

Example

import numpy as np
from tropea_clustering import OnionUni, helpers

# Select time resolution
delta_t = 5

# Create random input data
np.random.seed(1234)
n_particles = 5
n_steps = 1000

input_data = np.random.rand(n_particles, n_steps)

# Create input array with the correct shape
reshaped_input_data = helpers.reshape_from_nt(
    input_data, delta_t,
)

# Run Onion Clustering
clusterer = OnionUni()
clust_params = {"bins": 100, "number_of_sigmas": 2.0}
clusterer.set_params(**clust_params)
clusterer.fit(reshaped_input_data)

Methods

fit

Performs onion clustering on the data array 'X'.

fit_predict

Computes clusters on the data array 'X' and returns labels.

get_params

Get parameters for this estimator.

set_params

Set the parameters of this estimator.

fit(X, y=None)[source]

Performs onion clustering on the data array ‘X’.

Parameters:

X (ndarray of shape (n_particles * n_seq, delta_t)) – The data to cluster. Each signal sequence is considered as a single data point.

Returns:

self – A fitted instance of self.

Return type:

object

fit_predict(X, y=None)[source]

Computes clusters on the data array ‘X’ and returns labels.

Parameters:

X (ndarray of shape (n_particles * n_seq, delta_t)) – The data to cluster. Each signal sequence is considered as a single data point.

Returns:

labels_ – Cluster labels for signal sequence. Unclassified points are given the label “-1”.

Return type:

ndarray of shape (n_particles * n_seq,)

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance