question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] min binary function raises errors during prediction

See original GitHub issue

Describe the bug When I use “min” and “max” in my binary operators, fitting goes well but prediction raises an error.

Version (please include the following information):

  • OS: ubuntu 20.04
  • Julia version 1.8.0
  • Python version 3.8
  • PySR version 0.10.1
  • Does the bug still appear with the latest version of PySR? Yes

Configuration

import numpy as np
from pysr import PySRRegressor

data_x = np.random.randint(-100, 100, (200, 2))
data_y = np.minimum(data_x[:,0], 8)

model = PySRRegressor(
    model_selection="best",  # Result is mix of simplicity+accuracy
    niterations=40,
    binary_operators=[
        "min", "max"
    ],
    unary_operators=[
    ],
    extra_sympy_mappings={
    },
    # ^ Define operator for SymPy as well
    loss="loss(x, y) = (x - y)^2",
    warm_start=False,
)
print('Fitting data')
model.fit(data_x, data_y)
print(model)
print(model.get_best())

print(model.predict(data_x))

Error message ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Happens in predict() call. The fit result is correct.

Additional context I tried adding {‘min’: np.minimum}, or {‘min’: min}, or {‘min’: sympy.Min} to extra_sympy_mappings. None worked.

I found a workaround :

for row in data_x: 
    model.predict(row)

Not very satisfying though.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gdelabcommented, Aug 31, 2022

Thanks for the amazing package by the way !

0reactions
gdelabcommented, Sep 1, 2022

Thanks for the thourough answer. Yes, sure for the PR !

Read more comments on GitHub >

github_iconTop Results From Across the Web

24 Evaluation Metrics for Binary Classification (And When to ...
Classification metrics let you assess the performance of machine learning models but there are so many of them, each one has its own...
Read more >
An automatically created novel bug dataset and its validation ...
Proposing a novel kind of bug dataset that captures before- and after-fix states. •. Predicting faults at method level is more accurate than...
Read more >
A Universal Error Measure for Input Predictions Applied to ...
Abstract: We introduce a novel measure for quantifying the error in input predictions. The error is based on a minimum-cost hyperedge cover ...
Read more >
Non-numeric Argument to Binary Operator Error in R
Anyone know why I am receiving this error? Error in CurrentDay - MA : non-numeric argument to binary operator. r.
Read more >
Performance and Prediction — H2O 3.38.0.3 documentation
For binary classification problems, H2O uses the model along with the given dataset to ... The mean absolute error is an average of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found