Skip to content

Commit

Permalink
[ENH] BinarySegmentation fixes for new detection interface (#7504)
Browse files Browse the repository at this point in the history
#### Reference Issues/PRs

Fixes #7411.

#### What does this implement/fix? Explain your changes.

Removes binary segmentation tests from the exclude list so they now run are part of the CI/CD pipeline.
  • Loading branch information
Alex-JG3 authored Dec 29, 2024
1 parent 591c359 commit 381610c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/07_detection_anomaly_changepoints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"id": "3af4e386-e7fa-4a03-a324-305d6d864ae6",
"metadata": {},
"outputs": [
Expand All @@ -856,7 +856,7 @@
"from sktime.detection.bs import BinarySegmentation\n",
"\n",
"model = BinarySegmentation(threshold=1000)\n",
"predicted_change_points = model.fit_predict(df)\n",
"predicted_change_points = model.fit_predict(df[\"KSI\"])\n",
"print(predicted_change_points)"
]
},
Expand Down
15 changes: 9 additions & 6 deletions sktime/detection/bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class BinarySegmentation(BaseDetector):
>>> model = BinarySegmentation(threshold=1)
>>> X = pd.Series([1, 1, 1, 1, 5, 5, 5, 5])
>>> model.fit_predict(X)
0 3
dtype: int64
ilocs
0 3
>>> X = pd.Series([1.1, 1.3, -1.4, -1.4, 5.5, 5.6])
>>> model.fit_predict(X)
0 1
1 3
dtype: int64
ilocs
0 1
1 3
"""

_tags = {
Expand All @@ -63,6 +63,7 @@ class BinarySegmentation(BaseDetector):
"univariate-only": True,
"task": "change_point_detection",
"learning_type": "unsupervised",
"X_inner_mtype": "pd.Series",
}

def __init__(self, threshold, min_cp_distance=0, max_iter=10000):
Expand Down Expand Up @@ -202,4 +203,6 @@ def get_test_params(cls, parameter_set="default"):
instance.
``create_test_instance`` uses the first (or only) dictionary in ``params``
"""
return {"threshold": 1}
params0 = {"threshold": 1}
params1 = {"threshold": 0.1, "min_cp_distance": 1, "max_iter": 100}
return [params0, params1]
5 changes: 0 additions & 5 deletions sktime/tests/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@
"test_transform_output_type",
"test_output_type",
],
"BinarySegmentation": [
"test_predict_segments",
"test_transform_output_type",
],
"GreedyGaussianSegmentation": [
"test_predict_points",
"test_predict_segments",
Expand All @@ -282,7 +278,6 @@
"Arsenal",
"BaggingForecaster",
"BOSSEnsemble",
"BinarySegmentation",
"CNTCClassifier",
"CNTCNetwork",
"CNTCRegressor",
Expand Down

0 comments on commit 381610c

Please sign in to comment.