Skip to content

Commit

Permalink
[DOC ] Added examples to docstrings for K-Means and K-Medoids (#4736)
Browse files Browse the repository at this point in the history
Adds to #4264. 

Added usage examples to `k_means` and `k_medoids`.
  • Loading branch information
CTFallon committed Jun 25, 2023
1 parent a0d0ebb commit 826b228
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Expand Up @@ -2190,6 +2190,15 @@
"contributions": [
"code"
]
},
{
"login": "CTFallon",
"name": "Colin Fallon",
"avatar_url": "https://avatars.githubusercontent.com/u/19725980?v=4",
"profile": "https://github.com/CTFallon",
"contributions": [
"doc"
]
}
]
}
11 changes: 11 additions & 0 deletions sktime/clustering/k_means.py
Expand Up @@ -63,6 +63,17 @@ class TimeSeriesKMeans(TimeSeriesLloyds):
the sample weights if provided.
n_iter_: int
Number of iterations run.
Examples
--------
>>> from sktime.datasets import load_arrow_head
>>> from sktime.clustering.k_means import TimeSeriesKMeans
>>> X_train, y_train = load_arrow_head(split="train")
>>> X_test, y_test = load_arrow_head(split="test")
>>> clusterer = TimeSeriesKMeans(n_clusters=3) # doctest: +SKIP
>>> clusterer.fit(X_train) # doctest: +SKIP
TimeSeriesKMeans(n_clusters=3)
>>> y_pred = clusterer.predict(X_test) # doctest: +SKIP
"""

_tags = {"python_dependencies": "numba"}
Expand Down
11 changes: 11 additions & 0 deletions sktime/clustering/k_medoids.py
Expand Up @@ -57,6 +57,17 @@ class TimeSeriesKMedoids(TimeSeriesLloyds):
the sample weights if provided.
n_iter_: int
Number of iterations run.
Examples
--------
>>> from sktime.datasets import load_arrow_head
>>> from sktime.clustering.k_medoids import TimeSeriesKMedoids
>>> X_train, y_train = load_arrow_head(split="train")
>>> X_test, y_test = load_arrow_head(split="test")
>>> clusterer = TimeSeriesKMedoids(n_clusters=3) # doctest: +SKIP
>>> clusterer.fit(X_train) # doctest: +SKIP
TimeSeriesKMedoids(n_clusters=3)
>>> y_pred = clusterer.predict(X_test) # doctest: +SKIP
"""

_tags = {"python_dependencies": "numba"}
Expand Down

0 comments on commit 826b228

Please sign in to comment.