Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
koaning committed Oct 31, 2024
1 parent b60b95e commit dce95e7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/api/preprocessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@
options:
show_root_full_path: true
show_root_heading: true

:::sklego.preprocessing.monotonicspline.MonotonicSplineTransformer
options:
show_root_full_path: true
show_root_heading: true
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Here's a list of features that this library currently offers:
- `sklego.preprocessing.RepeatingBasisFunction` repeating feature engineering, useful for timeseries
- `sklego.preprocessing.DictMapper` assign numeric values on categorical columns
- `sklego.preprocessing.OutlierRemover` experimental method to remove outliers during training
- `sklego.preprocessing.MonotonicSplineTransformer` re-uses `SplineTransformer` in an attempt to make monotonic features
- `sklego.model_selection.GroupTimeSeriesSplit` timeseries Kfold for groups with different amount of observations per group
- `sklego.model_selection.KlusterFoldValidation` experimental feature that does K folds based on clustering
- `sklego.model_selection.TimeGapSplit` timeseries Kfold with a gap between train/test
Expand Down
20 changes: 20 additions & 0 deletions tests/test_preprocessing/test_monospline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import numpy as np
import pytest

from sklego.preprocessing import MonotonicSplineTransformer


@pytest.mark.parametrize("n_knots", [3, 5])
@pytest.mark.parametrize("degree", [3, 5])
@pytest.mark.parametrize("knots", ["uniform", "quantile"])
def test_monotonic_spline_transformer(n_knots, degree, knots):
X = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
transformer = MonotonicSplineTransformer(n_knots=n_knots, degree=degree, knots=knots)
transformer.fit(X)
out = transformer.transform(X)
# Check each column is monotonically increasing
for col in range(out.shape[1]):
col_values = out[:, col]
# numpy diff returns positive values if array is increasing
differences = np.diff(col_values)
assert np.all(differences >= 0), f"Column {col} is not monotonically increasing"

0 comments on commit dce95e7

Please sign in to comment.