[MNT] migrate scaling module to narwhals - #979
Conversation
* update dataframe checks * update dataframe checks take 2 * update dataframe checks take 3 * update docstrings * refactor dataframe checks * fix mypy error * add missing type hints * add missing matching error syntax * finalise tests for df checks'
Use narwhals for MeanNormalisationScaler fit/transform/inverse_transform math so the scaler can work with any dataframe backend narwhals supports. Pandas unit tests continue to pass; polars auto variable-selection still depends on upcoming variable_handling updates. Co-authored-by: Cursor <cursoragent@cursor.com>
8fe8359 to
ea95750
Compare
0ef7acb to
ff5d212
Compare
|
Hi @ojassharma7 Sorry that it took me so long to come back to you. I've just merged 2 fundamental updates to the branch narwhals-migration that will now allow you to update this class if you are still interested. It would be great if you could. Basically, you need to make a new branch from narhwals-migration and then make your updates there, and make a new PR, or alternatively, somehow bring the changes from narwhals-migration to this branch first, and then add the changes, if you want to continue working on this PR. An agent will probably know what the best way is. While you are at it, we are making part of the migration an improvement in how the classes run (in speed), so it might be worth examining whether the logic should be implemented in numpy (if relevant). Thanks a lot! |
Summary
Migrates
feature_engine/scaling(MeanNormalisationScaler) sofit/transform/inverse_transformuse narwhals for the mean / range / scaling math, returning a native dataframe of the same type as the input.Context
Part of #965. @solegalli suggested
scalingas a good first module. Variable selection (find_numerical_variables/ friends) is still pandas-backed on this branch — as noted, pandas tests should pass; full polars support waits on the variable-handling work Sole is doing.Test plan
pytest tests/test_scaling/(pandas) — 8 passed locallynarwhals-migration