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

Change log(x+1) to log1p(x) in LogTransformer #178

Merged
merged 6 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Subsections for each version can be one of the following;

Each individual change should have a link to the pull request after the description of the change.

1.2.2 (2024-02-15)
------------------
Changed
^^^^^^^
- Changed LogTransformer to use log1p(x) instead of log(x+1) `#178 <https://github.com/lvgig/tubular/pull/178>`_
- Changed unit tests using log(x+1) to log1p(x) `#178 <https://github.com/lvgig/tubular/pull/178>`_
ChaitanMohr marked this conversation as resolved.
Show resolved Hide resolved

ChaitanMohr marked this conversation as resolved.
Show resolved Hide resolved
1.2.0 (2024-02-06)
------------------
Added
Expand Down
8 changes: 4 additions & 4 deletions tests/numeric/test_LogTransformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def expected_df_2():
"""Expected output of test_expected_output_2."""
df = d.create_df_3()

df["a_new_col"] = np.log(df["a"] + 1)
df["b_new_col"] = np.log(df["b"] + 1)
df["a_new_col"] = np.log1p(df["a"])
df["b_new_col"] = np.log1p(df["b"])

return df.drop(columns=["a", "b"])

Expand All @@ -114,8 +114,8 @@ def expected_df_4():
"""Expected output of test_expected_output_4."""
df = d.create_df_3()

df["a_new_col"] = np.log(df["a"] + 1)
df["b_new_col"] = np.log(df["b"] + 1)
df["a_new_col"] = np.log1p(df["a"])
df["b_new_col"] = np.log1p(df["b"])

return df

Expand Down
2 changes: 1 addition & 1 deletion tubular/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.0"
__version__ = "1.2.2"
4 changes: 2 additions & 2 deletions tubular/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def transform(self, X: pd.DataFrame) -> pd.DataFrame:
raise ValueError(msg)

if self.base is None:
X[new_column_names] = np.log(X[self.columns] + 1)
X[new_column_names] = np.log1p(X[self.columns])

else:
X[new_column_names] = np.log(X[self.columns] + 1) / np.log(self.base)
X[new_column_names] = np.log1p(X[self.columns]) / np.log(self.base)

else:
if (X[self.columns] <= 0).sum().sum() > 0:
Expand Down