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

Add LogScaler transformer #932

Closed
wants to merge 15 commits into from
Closed

Add LogScaler transformer #932

wants to merge 15 commits into from

Conversation

rwedge
Copy link
Contributor

@rwedge rwedge commented Jan 16, 2025

Implements #930

CU-86b3gbr2k

@sdv-team
Copy link
Contributor

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d6ea5d1) to head (9ab83b6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #932   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        18           
  Lines         2233      2277   +44     
=========================================
+ Hits          2233      2277   +44     
Flag Coverage Δ
integration 83.09% <91.11%> (+0.15%) ⬆️
unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rwedge rwedge force-pushed the issue-930-LogScaler branch from 53d70fe to f1dbfa5 Compare January 17, 2025 16:17
@rwedge rwedge marked this pull request as ready for review January 22, 2025 17:33
@rwedge rwedge requested a review from a team as a code owner January 22, 2025 17:33
@rwedge rwedge requested review from frances-h and fealho and removed request for a team January 22, 2025 17:33
Copy link
Member

@fealho fealho left a comment

Choose a reason for hiding this comment

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

Look great! I only left some minor comments.

value was missing. Then use it to recreate missing values.
* ``None``: Do nothing with the missing values on the reverse transform. Simply
pass whatever data we get through.
constant (float):
Copy link
Member

Choose a reason for hiding this comment

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

"Default to 0" -> "Defaults to 0".

Also, either add the `` quotation marks around the 0, False, True values here, or remove them from the other values in the docstring, so it's conistent.


class TestLogScaler:
def test___init__super_attrs(self):
"""super() arguments are properly passed and set as attributes."""
Copy link
Member

Choose a reason for hiding this comment

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

Missing "Test" at the start

data = super()._transform(data)

if data.ndim > 1:
self._validate_data(data[:, 0])
Copy link
Member

Choose a reason for hiding this comment

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

I would create a helper function for lines 711-715 like you did for _fit, so we don't repeat the code.

data = data.to_numpy()

if data.ndim > 1:
if self.invert:
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

invert: bool = False,
learn_rounding_scheme: bool = False,
):
self.constant = constant
Copy link
Member

Choose a reason for hiding this comment

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

Could we add validation to the constant/invert args?


class TestLogScaler:
def test_learn_rounding(self):
# Setup
Copy link
Member

Choose a reason for hiding this comment

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

Add short docstrings to these tests.

# Run
transformer.fit(data, 'test')
transformed = transformer.transform(data)
reversed = transformer.reverse_transform(transformed)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we update this to reversed_values or something similar since reversed is a Python keyword?

Copy link
Member

@fealho fealho left a comment

Choose a reason for hiding this comment

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

Left a couple of comments, outside of those it looks good to me.

invert: bool = False,
learn_rounding_scheme: bool = False,
):
self.constant = constant
self.invert = invert
if isinstance(constant, float):
Copy link
Member

Choose a reason for hiding this comment

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

Integers should probably be fine as well right?

@@ -704,36 +711,37 @@ def _fit(self, data):
else:
self._validate_data(data)

def _log_transform(self, data):
Copy link
Member

Choose a reason for hiding this comment

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

You can move self._validate_data here as well, no?

@rwedge
Copy link
Contributor Author

rwedge commented Jan 27, 2025

Closing in favor of #935

@rwedge rwedge closed this Jan 27, 2025
@rwedge rwedge mentioned this pull request Jan 27, 2025
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.

4 participants