The one downside of this change is I have to monkey patch scikit-learn at runtime, because their BaseEstimator class includes an explicit check that the input data does not include complex numbers. Until this issue: https://github.com/scikit-learn/scikit-learn/issues/25922 is fixed, this monkey patch is required. So, whenever you import pysr, know that other scikit-learn objects will also skip doing this complex number check.
This enables PySR to search for complex-valued expressions. Now, if you pass complex data, it will automatically search for complex expressions.
Specifying
precision=32
(default) will usecomplex64
andprecision=64
will usecomplex128
.For example:
we can look at the best expression with:
this gives me:
The one downside of this change is I have to monkey patch scikit-learn at runtime, because their
BaseEstimator
class includes an explicit check that the input data does not include complex numbers. Until this issue: https://github.com/scikit-learn/scikit-learn/issues/25922 is fixed, this monkey patch is required. So, whenever you importpysr
, know that other scikit-learn objects will also skip doing this complex number check.TODO: