tropea_clustering.OnionMultiSmooth¶
- class tropea_clustering.OnionMultiSmooth(delta_t, bins='auto', number_of_sigmas=3.0, max_area_overlap=0.8)[source]¶
Performs onion clustering on a data array.
Returns an array of integer labels, one for each frame. Unclassified frames are labelled “-1”.
Note
This class is currently in beta testing. Its operations could change in the future. Use with caution.
- Parameters:
delta_t (int) – The minimum lifetime required for the clusters. Also referred to as the “time resolution” of the clustering analysis.
bins (int, default="auto") – The number of bins used for the construction of the histograms. Can be an integer value, or “auto”. If “auto”, the default of numpy.histogram_bin_edges is used (see https://numpy.org/doc/stable/reference/generated/numpy.histogram_bin_edges.html#numpy.histogram_bin_edges).
number_of_sigmas (float, default=3.0) – Sets the thresholds for classifing a signal sequence inside a state: the sequence is contained in the state if it is entirely contained inside number_of_sigma * state.sigms times from state.mean.
max_area_overlap (float, default=0.8) – Thresold to consider two Gaussian states overlapping, and thus merge them together.
- state_list_¶
The list of the identified states. Refer to the documentation of StateMulti for accessing the information on the states.
- Type:
List[StateMulti]
- labels_¶
Cluster labels for each frame. Unclassified points are given the label “-1”.
- Type:
ndarray of shape (n_particles, n_frames)
Example
import numpy as np from tropea_clustering import OnionMultiSmooth # Select time resolution delta_t = 2 # Create random input data np.random.seed(1234) n_features = 2 n_particles = 5 n_steps = 1000 input_data = np.random.rand(n_particles, n_steps, n_features) # Run Onion Clustering clusterer = OnionMultiSmooth(delta_t) clust_params = {"bins": 100, "number_of_sigmas": 2.0} clusterer.set_params(**clust_params) clusterer.fit(input_data)
Methods
Performs onion clustering on the data array 'X'.
Computes clusters on the data array 'X' and returns labels.
get_paramsset_params- fit(X, y=None)[source]¶
Performs onion clustering on the data array ‘X’.
- Parameters:
X (ndarray of shape (n_particles, n_frames, n_features)) – The time-series data to cluster.
- Returns:
self – A fitted instance of self.
- Return type:
- fit_predict(X, y=None)[source]¶
Computes clusters on the data array ‘X’ and returns labels.
- Parameters:
X (ndarray of shape (n_particles, n_frames, n_features)) – The time-series data to cluster.
- Returns:
labels_ – Cluster labels for each frame. Unclassified points are given the label “-1”.
- Return type:
ndarray of shape (n_particles, n_frames)