PySR icon indicating copy to clipboard operation
PySR copied to clipboard

Update the method run_on_problem() in FeynmanProblems.py to use the new PySRRegressor Interface

Open dbl001 opened this issue 3 years ago • 2 comments

Currently, run_on_problem() uses the deprectated pysr() interface and pysr.best() does not work. Upgrade run_on_problem() to use the PySRRegressor Interface, model.fit() and get_best() function.

dbl001 avatar Feb 04 '23 17:02 dbl001

Hey @dbl001, I was actually thinking about deleting the feynman problems as I didn't think anybody was using it (including myself). Has it been useful for you? If so you happen to have some time to upgrade it to the new PySRRegressor interface? Best, Miles

MilesCranmer avatar Feb 04 '23 20:02 MilesCranmer

I just started using it. I got this working...

 def run_on_problem(problem, verbosity=0, multiprocessing=True):
    """
    Takes in a problem and returns a tuple: (equations, best predicted equation, actual equation)
    """
    from time import time

    starting = time()
    model = PySRRegressor()
    model.fit(problem.X, problem.y)
    timing = time() - starting
    others = {"time": timing, "problem": problem}
    if not multiprocessing: 
        others["equations"] = model.equations_
    return str(PySRRegressor.get_best(model)), problem.form, others

dbl001 avatar Feb 04 '23 20:02 dbl001