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

Replace missing values with random values from dataset #715

Conversation

pvk-developer
Copy link
Member

Resolves #606

@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (c2c7064) 100.00% compared to head (f09ea8d) 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #715   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines         1791      1799    +8     
=========================================
+ Hits          1791      1799    +8     
Files Coverage Δ
rdt/transformers/boolean.py 100.00% <100.00%> (ø)
rdt/transformers/datetime.py 100.00% <100.00%> (ø)
rdt/transformers/null.py 100.00% <100.00%> (ø)
rdt/transformers/numerical.py 100.00% <100.00%> (ø)

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

@pvk-developer pvk-developer marked this pull request as ready for review October 2, 2023 14:48
@pvk-developer pvk-developer requested a review from a team as a code owner October 2, 2023 14:48
@pvk-developer pvk-developer requested review from fealho and R-Palazzo and removed request for a team October 2, 2023 14:48
@@ -1353,8 +1379,9 @@ def test_random_seed(self):

# Run
ht.fit(data)
transformed = ht.transform(data)
reversed1 = ht.reverse_transform(transformed)
ht.reset_randomization()
Copy link
Member Author

Choose a reason for hiding this comment

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

I think that this should be solved before going any further, this should be called after fit on the hypertransformer as per #716

Copy link
Contributor

@R-Palazzo R-Palazzo left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -73,7 +75,7 @@ def _get_missing_value_replacement(self, data):
if self._missing_value_replacement is None:
return None

if self._missing_value_replacement in {'mean', 'mode'} and pd.isna(data).all():
if self._missing_value_replacement in {'mean', 'mode', 'random'} and pd.isna(data).all():
Copy link
Contributor

Choose a reason for hiding this comment

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

Update docstring to include random l73, l21

rdt/transformers/null.py Show resolved Hide resolved
rdt/transformers/numerical.py Outdated Show resolved Hide resolved
@fealho fealho self-requested a review October 3, 2023 17:34
@amontanez24 amontanez24 self-requested a review October 4, 2023 19:56
Comment on lines 121 to 122
self._min_value = data.min()
self._max_value = data.max()
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of an edge case, but what happens if all the values are nan? I think the min and max would be set to nan as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

If all values are nan we do 0

        if self._missing_value_replacement in {'mean', 'mode', 'random'} and pd.isna(data).all():
            msg = (
                f"'missing_value_replacement' cannot be set to '{self._missing_value_replacement}'"
                ' when the provided data only contains NaNs. Using 0 instead.'
            )
            LOGGER.info(msg)
            return 0

rdt/transformers/null.py Outdated Show resolved Hide resolved
Copy link
Contributor

@R-Palazzo R-Palazzo left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@amontanez24 amontanez24 left a comment

Choose a reason for hiding this comment

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

:shipit:

@pvk-developer pvk-developer merged commit 6d19148 into main Oct 11, 2023
45 checks passed
@pvk-developer pvk-developer deleted the issue-606-replace-missing-values-with-random-values-from-dataset branch October 11, 2023 12:39
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.

Replace missing values with variable (random) values from the dataset
5 participants