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

Defining a transformation without bounds on a target should fail validation #449

Closed
monken opened this issue Dec 9, 2024 · 2 comments · Fixed by #451
Closed

Defining a transformation without bounds on a target should fail validation #449

monken opened this issue Dec 9, 2024 · 2 comments · Fixed by #451
Assignees
Labels
bug Something isn't working

Comments

@monken
Copy link

monken commented Dec 9, 2024

The NumericalTarget constructor will happily accept a transformation without any bounds. This causes the call to target.transform() to turn the dataframe into NaNs.

from baybe.targets import NumericalTarget, TargetMode, TargetTransformation

# should fail, no bounds defined
target = NumericalTarget(
    name="Target_1",
    mode=TargetMode.MIN,
    transformation=TargetTransformation.LINEAR,
)

import pandas as pd

# RuntimeWarning: invalid value encountered in divide
#   res = (upper - arr) / (upper - lower)
print(target.transform(pd.DataFrame([1, 2, 3])))
    0
0 NaN
1 NaN
2 NaN
@AVHopp
Copy link
Collaborator

AVHopp commented Dec 10, 2024

Thanks for reporting, will have a look into this!

@AVHopp
Copy link
Collaborator

AVHopp commented Dec 10, 2024

PR (#451 ) is up :)

@AVHopp AVHopp added the bug Something isn't working label Dec 10, 2024
@AVHopp AVHopp closed this as completed in 6d3a6fc Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants