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

MonotonicSplineTransformer #709

Merged
merged 21 commits into from
Nov 12, 2024
Merged

MonotonicSplineTransformer #709

merged 21 commits into from
Nov 12, 2024

Conversation

koaning
Copy link
Owner

@koaning koaning commented Oct 31, 2024

An implementation for #704

@koaning
Copy link
Owner Author

koaning commented Oct 31, 2024

@matekadlicsko will present this to the larger crowd tomorrow.

@matekadlicsko
Copy link
Contributor

I believe this implementation has an error. The cumsum should go over the columns instead of the rows, which in turn makes sorting obsolete as well. I can fix this.

@koaning
Copy link
Owner Author

koaning commented Nov 1, 2024

Feel free to put a PR on top of this one. In particular, if you could contribute a unit test that demonstrates when something breaks that would be stellar.

matekadlicsko and others added 2 commits November 6, 2024 15:25
* fix: fixed an error in the implementation

* feat: tests now directly test monotonicity and boundedness

---------

Co-authored-by: Mate Kadlicsko <[email protected]>
@koaning
Copy link
Owner Author

koaning commented Nov 6, 2024

Updated the docs. If tests pass the WIP status can be removed.

@koaning koaning requested a review from FBruzzesi November 6, 2024 14:46
@koaning
Copy link
Owner Author

koaning commented Nov 6, 2024

@FBruzzesi I think all the base tests pass, so this one might be green to go in.

@koaning
Copy link
Owner Author

koaning commented Nov 6, 2024

All 3.8 tests broke, but it is also end of life, so I removed those checks.

Copy link
Collaborator

@FBruzzesi FBruzzesi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @koaning, I left a bunch of comments, mostly for documenting and some other minor details.

For the algorithm itself I did not do my homework properly as I did not have the chance to watch last Friday live stream, yet I trust your and Mate Kadlicsko implementation and review.

docs/api/preprocessing.md Outdated Show resolved Hide resolved
docs/user-guide/preprocessing.md Outdated Show resolved Hide resolved
docs/_scripts/preprocessing.py Outdated Show resolved Hide resolved
docs/user-guide/preprocessing.md Outdated Show resolved Hide resolved
sklego/preprocessing/monotonicspline.py Outdated Show resolved Hide resolved
sklego/preprocessing/monotonicspline.py Outdated Show resolved Hide resolved
sklego/preprocessing/monotonicspline.py Show resolved Hide resolved
sklego/preprocessing/monotonicspline.py Show resolved Hide resolved
tests/test_preprocessing/test_monospline.py Outdated Show resolved Hide resolved
for col in range(X.shape[1]):
out.append(
np.cumsum(
self.spline_transformer_[col].transform(X[:, [col]])[:, ::-1],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may need to do a bit more reading on why there is an inversion here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direction in which you perform the cumsum on the columns will determine whether the output splines will be increasing or decreasing. However, now that you mention it, I'm pretty sure that

1 - np.cumsum(without inversion)

would achieve the same effect.

koaning and others added 2 commits November 7, 2024 10:50
Copy link
Collaborator

@FBruzzesi FBruzzesi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌🏼

@koaning koaning merged commit 1c66894 into main Nov 12, 2024
15 checks passed
@koaning koaning deleted the monotonicspline branch November 12, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants