[BUG] min binary function raises errors during prediction
See original GitHub issueDescribe 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:
- Created a year ago
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for the amazing package by the way !
Thanks for the thourough answer. Yes, sure for the PR !