Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] BinarySegmentation fixes for new detection interface #7504

Merged
merged 5 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading