onion_clustering package¶
The code provides functions for performing Onion Clustering on time-series. For uni-dimensional time-series, use “onion_uni”, for bi- or three-dimensional time-series use “onion_multi”.
onion_clustering.onion_uni¶
onion-clustering for univariate time-series.
- class onion_clustering.onion_uni.OnionUni(bins='auto', number_of_sigmas=2.0)[source]¶
Bases:
BaseEstimator
,ClusterMixin
Perform onion clustering from data array.
References
https://www.pnas.org/doi/abs/10.1073/pnas.2403771121
- Parameters:
bins (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_sigma (default = 2.0) – Sets the thresholds for classifing a signal window inside a state: the window is contained in the state if it is entirely contained inside number_of_sigma * state.sigms times from state.mean.
number_of_sigmas (float)
- state_list_¶
List of the identified states.
- labels_¶
np.ndarray of shape (n_particles, n_frames). Cluster labels for each point. Unclassified points are given the label -1.
- fit(X, y=None)[source]¶
Perform onion clustering from data array.
- Parameters:
X – np.ndarray of shape (n_particles * n_windows, tau_window). The values of the signal for each particle at each frame.
- Returns:
A fitted instance of self.
- fit_predict(X, y=None)[source]¶
Compute clusters from a data matrix and predict labels.
- Parameters:
X – np.ndarray of shape (n_particles * n_windows, tau_window). The values of the signal for each particle at each frame.
- Returns:
np.ndarray of shape (n_particles * n_windows,). Cluster labels. Unclassified points are given the label -1.
- 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
- onion_clustering.onion_uni.onion_uni(matrix, bins='auto', number_of_sigmas=2.0)[source]¶
Perform onion clustering from data array.
References
https://www.pnas.org/doi/abs/10.1073/pnas.2403771121
- Parameters:
matrix (ndarray) – Shape (n_particles * n_windows, tau_window). The values of the signal for each particle at each frame.
bins (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 (default = 2.0) – Sets the thresholds for classifing a signal window inside a state: the window is contained in the state if it is entirely contained inside number_of_sigma * state.sigms times from state.mean.
- Returns:
List of the identified states.
np.ndarray of shape (n_particles, n_frames). Cluster labels for each point. Unclassified points are given the label -1.
onion_clustering.onion_multi¶
onion-clustering for multivariate time-series.
- class onion_clustering.onion_multi.OnionMulti(ndims=2, bins='auto', number_of_sigmas=2.0)[source]¶
Bases:
BaseEstimator
,ClusterMixin
Perform onion clustering from data array.
References
https://www.pnas.org/doi/abs/10.1073/pnas.2403771121
- Parameters:
ndims (default = 2) – Number of components. Must be 2 or 3.
bins (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 (default = 2.0) – Sets the thresholds for classifing a signal window inside a state: the window is contained in the state if it is entirely contained inside number_of_sigma * state.sigms times from state.mean.
- state_list_¶
List of the identified states.
- labels_¶
np.ndarray of shape (n_particles, n_frames). Cluster labels for each point. Unclassified points are given the label -1.
- fit(X, y=None)[source]¶
Perform onion clustering from data array.
- Parameters:
X – ndarray of shape (n_particles, n_frames). The values of the signal for each particle at each frame.
- Returns:
Returns a fitted instance of self.
- fit_predict(X, y=None)[source]¶
Compute clusters from a data matrix and predict labels.
- Parameters:
X – ndarray of shape (n_particles, n_frames). The values of the signal for each particle at each frame.
- Returns:
np.ndarray of shape (n_samples,). Cluster labels. Unclassified points are given the label -1.
- 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
- onion_clustering.onion_multi.onion_multi(matrix, ndims=2, bins='auto', number_of_sigmas=2.0)[source]¶
Perform onion clustering from data array.
References
https://www.pnas.org/doi/abs/10.1073/pnas.2403771121
- Parameters:
matrix (ndarray) – np.ndarray of shape (dims, n_particles, n_frames). The values of the signal for each particle at each frame.
ndims (default = 2) – Number of components. Must be 2 or 3.
bins (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 (default = 2.0) – Sets the thresholds for classifing a signal window inside a state: the window is contained in the state if it is entirely contained inside number_of_sigma * state.sigms times from state.mean.
- Returns:
List of the identified states.
np.ndarray of shape (n_particles, n_frames). Cluster labels for each point. Unclassified points are given the label -1.
Module contents¶
onion-clustering package.