labels_to_changepoints#
- labels_to_changepoints(labels: ndarray) ndarray[source][source]#
Convert per-sample segment labels to changepoint indices.
- Parameters:
- labelsnp.ndarray
Segment labels, shape (n_samples,).
- Returns:
- np.ndarray
Changepoint indices, shape (n_changepoints,). Empty if no changepoints.
Examples
>>> labels = np.array([0]*50 + [1]*50 + [2]*50) >>> changepoints = labels_to_changepoints(labels) >>> changepoints array([50, 100])