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 support for transforming numeric predictions that were normalized #1015

Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fc55d36
feat: add support for transforming numeric predictions
jimthompson5802 Nov 19, 2020
e96fcd2
feat: add log1p normalization for numerical feature
jimthompson5802 Nov 20, 2020
5e076bb
refactor: incorporate reviewer comments
jimthompson5802 Nov 20, 2020
43f7261
doc: incorporated reviewer comments re: error message
jimthompson5802 Nov 20, 2020
358302f
refactor: incorporated reviewer comments for improved abstraction
jimthompson5802 Nov 21, 2020
d0d62ed
refactor: add fit_transform_params method
jimthompson5802 Nov 21, 2020
388ca52
doc: fix error message text
jimthompson5802 Nov 21, 2020
6f446ea
refactor: incorporated reviewer comments
jimthompson5802 Nov 23, 2020
29fc97b
refactor: old code clean-up
jimthompson5802 Nov 23, 2020
d6a65cb
refactor: marked static methods in numeric transformers
jimthompson5802 Nov 23, 2020
3eb5837
refactor: incorporated reviewer comments
jimthompson5802 Nov 23, 2020
ba184fe
refactor: cache checksum test internal names
jimthompson5802 Nov 23, 2020
dad61db
feat: add unit test for numeric transformers
jimthompson5802 Nov 23, 2020
9cb59fe
Merge remote-tracking branch 'upstream/master' into feature_numeric_p…
jimthompson5802 Nov 29, 2020
40be903
fix: error retrieving backend df_engine compute
jimthompson5802 Nov 29, 2020
5bcb7e2
fix: error preprocessing numeric feature
jimthompson5802 Nov 29, 2020
f2535a6
refactor: incorporate new backend design
jimthompson5802 Nov 29, 2020
59fd83b
refactor: incorporate new backend design to unit test
jimthompson5802 Nov 29, 2020
630ef2b
doc: incorporated reviewer comments
jimthompson5802 Nov 29, 2020
09eacaf
Merge remote-tracking branch 'upstream/master' into feature_numeric_p…
jimthompson5802 Dec 4, 2020
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
12 changes: 8 additions & 4 deletions ludwig/features/numerical_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,17 @@ class Log1pTransformer:
def __init__(self, **kwargs: dict):
pass

def transform(self, x: np.ndarray) -> np.ndarray:
@staticmethod
jimthompson5802 marked this conversation as resolved.
Show resolved Hide resolved
def transform(x: np.ndarray) -> np.ndarray:
if np.any(x <= 0):
raise ValueError(
'One or more values are non-positive. '
'log1p normalization is defined only for positive values.'
)
return np.log1p(x)

def inverse_transform(self, x: np.ndarray) -> np.ndarray:
@staticmethod
def inverse_transform(x: np.ndarray) -> np.ndarray:
return np.expm1(x)

@staticmethod
Expand All @@ -377,10 +379,12 @@ class IdentityTransformer:
def __init__(self, **kwargs):
pass

def transform(self, x: np.ndarray) -> np.ndarray:
@staticmethod
def transform(x: np.ndarray) -> np.ndarray:
return x

def inverse_transform(self, x: np.ndarray) -> np.ndarray:
@staticmethod
def inverse_transform(x: np.ndarray) -> np.ndarray:
return x

@staticmethod
Expand Down