diff --git a/sklego/decomposition/pca_reconstruction.py b/sklego/decomposition/pca_reconstruction.py index e15c27af..3dcc51aa 100644 --- a/sklego/decomposition/pca_reconstruction.py +++ b/sklego/decomposition/pca_reconstruction.py @@ -36,6 +36,21 @@ class PCAOutlierDetection(BaseEstimator, OutlierMixin): The underlying PCA model. offset_ : float The offset used for the decision function. + + Examples + -------- + ```py + import numpy as np + from sklego.decomposition import PCAOutlierDetection + + X = np.array([[-1, -1, -1], [-2, -1, -2], [5, -1, 0], [1, 1, 1], [2, 1, 1], [3, 2, 3]]) + + pca_model = PCAOutlierDetection(n_components=2, threshold=0.05) + pca_model.fit(X) + pca_pred = pca_model.predict(X) + pca_pred + # [ 1 1 1 -1 -1 1] + ``` """ def __init__( diff --git a/sklego/decomposition/umap_reconstruction.py b/sklego/decomposition/umap_reconstruction.py index cab3b0a5..330fe8f8 100644 --- a/sklego/decomposition/umap_reconstruction.py +++ b/sklego/decomposition/umap_reconstruction.py @@ -43,6 +43,21 @@ class UMAPOutlierDetection(BaseEstimator, OutlierMixin): The underlying UMAP model. offset_ : float The offset used for the decision function. + + Examples + -------- + ```py + import numpy as np + from sklego.decomposition import UMAPOutlierDetection + + X = np.array([[-1, -1, -1], [-2, -1, -2], [5, -1, 0], [-1, -1, -1], [2, 1, 1], [3, 2, 3]]) + + umap_model = UMAPOutlierDetection(n_components=2, threshold=0.2, n_neighbors=5) + umap_model.fit(X) + umap_pred = umap_model.predict(X) + umap_pred + # [ 1 1 -1 1 -1 -1] + ``` """ def __init__(