metaclean3.changepoint¶
Module Contents¶
Functions¶
|
List the gains for values fit on a ruptures class on given changepoints. |
|
Calculates the gain of a single changepoint. |
|
Converts changepoint indices to an integer segment label array. |
|
Converts an integer segment label array to changepoint indices. |
-
metaclean3.changepoint.list_gains(chpts0M: list | numpy.ndarray | pandas.Series, rpt_class: ruptures.Binseg, chpts_inds: list | numpy.ndarray | pandas.Series | None =
None, dif: bool =True)¶ List the gains for values fit on a ruptures class on given changepoints.
- Args:
- chpts0M (list | numpy.ndarray | pandas.Series): A vector listing the
index of the first element in each segment + a last element that indicates the length of the fitted values.
- rpt_class (rpt.Binseg): A ruptures.Binseg object that is already fit on
values we are calculating gains on.
- chpts_inds (list | numpy.ndarray | pandas.Series | None, optional):
If the user only wants to calculate gains on a subset of the given changepoints, chpts_inds is a vector that lists the indices of chpts_inds for which a gain should be calculated. Defaults to None.
- dif (bool, optional): Whether to use gain difference (True) or to use
gain ratio (False). Defaults to True.
- Returns:
numpy.ndarray: A 1D array containing a gain for each given changepoint.
-
metaclean3.changepoint.binseg_gain(start: int, bkp: int, end: int, rpt_class: ruptures.Binseg, dif: bool =
True)¶ Calculates the gain of a single changepoint.
- Args:
start (int): Start index (first inde of first segment). bkp (int): Breakpoint index (first inde of second segment). end (int): End index (not inclusive). rpt_class (rpt.Binseg): A ruptures.Binseg (for example) object that is
already fit on values we are calculating the gain on.
- dif (bool, optional): Whether to use gain difference (True) or to use
gain ratio (False). Defaults to True.
- Returns:
float: Gain value.
- metaclean3.changepoint.chpts0M_to_segments(chpts0M: list | numpy.ndarray | pandas.Series)¶
Converts changepoint indices to an integer segment label array.
- Args:
- chpts0M (list | numpy.ndarray | pandas.Series): Changepoint indices
where the first value is 0 and the last value is the length of the desired segment label array.
- Returns:
numpy.ndarray: A 1D integer segment label array.
- metaclean3.changepoint.segments_to_chpts0M(segments: list | numpy.ndarray | pandas.Series)¶
Converts an integer segment label array to changepoint indices.
- Args:
- segments (list | numpy.ndarray | pandas.Series):
A 1D integer segment label array.
- Returns:
numpy.ndarray: A 1D integer changepoint indices array.