MilesCranmer / PySR

High-Performance Symbolic Regression in Python and Julia
https://ai.damtp.cam.ac.uk/pysr
Apache License 2.0
2.42k stars 215 forks source link

Solver convergence #62

Open Rdfing opened 3 years ago

Rdfing commented 3 years ago

Hi Miles,

Thanks for sharing your code. I was trying the example case with some different solver configurations. The calculation is terminated after few 2 iterations. Is this because the calculation is converged? Or am I misunderstanding some of the solver's arguments?

equations = pysr(
    X,
    y,
    procs = 7,
    niterations=1000000,
    populations = 100,
    binary_operators=["+", "*", "/","^"],
    unary_operators=[
        "cos",
        "exp",
        "sin",  # Pre-defined library of operators (see docs)
        "inv(x) = 1/x",  # Define your own operator! (Julia syntax)
    ],
)

print(best(equations))


Running on julia -O3 /tmp/tmp1fl_c9ut/runfile.jl Activating environment on workers. Importing installed module on workers...Finished! Copying definition of inv to workers...Finished! Testing module on workers...Finished! Testing entire pipeline on workers...Finished! Started!

Cycles per second: 3.560e+02 Head worker occupation: 3.7% Progress: 1 / 100000000 total iterations (0.000%)

Hall of Fame:

Complexity Loss Score Equation 1 2.476e+01 5.960e-08 1.5915705 3 5.484e+00 7.536e-01 pow(x0, 2.002539) 5 1.902e+00 5.296e-01 (-2.0208373 + pow(x0, 2.0489082)) 11 1.791e+00 1.001e-02 ((1.2358671 + pow(x0, 2.002539)) + (-1.6340058 pow(x3, 0.9758236))) 12 2.172e-02 4.412e+00 ((-1.8855495 + pow(x0, 2.002539)) + (-2.0073733 sin(-1.6345752 + x3))) 19 8.701e-03 1.307e-01 (((pow(x0 / 1.0015011, 2.002539) + -0.91348684) + ((-0.53229153 + inv(-0.67792857)) * sin(-1.6345752 + x3))) + -1.0524741)

==============================

Cycles per second: 1.130e+03 Head worker occupation: 3.2% Progress: 2 / 100000000 total iterations (0.000%)

Hall of Fame:

Complexity Loss Score Equation 1 2.476e+01 5.960e-08 1.5917339 2 2.399e+01 3.134e-02 cos(x3) 3 1.265e+01 6.405e-01 pow(x0, 1.2735958) 4 5.174e+00 8.937e-01 pow(inv(x0), -1.9202919) 5 1.902e+00 1.001e+00 (-2.021261 + pow(x0, 2.0489275)) 11 1.878e+00 2.049e-03 (-2.2773557 + (pow(x0, 1.2649873) (0.22078495 + pow(x0, 0.7385057)))) 12 2.172e-02 4.460e+00 ((-1.8855495 + pow(x0, 2.002539)) + (-2.0073733 sin(-1.6345752 + x3))) 19 8.701e-03 1.307e-01 (((pow(x0 / 1.0015011, 2.002539) + -0.91348684) + ((-0.53229153 + inv(-0.67792857)) * sin(-1.6345752 + x3))) + -1.0524741)

============================== -2.0073733*sin(x3 - 1.6345752) + Abs(x0)**2.002539 - 1.8855495

MilesCranmer commented 3 years ago

Hi @Rdfing,

Sorry I missed this. This looks like your execution might have crashed? There's no internal mechanism (yet) for early stopping.

Cheers, Miles

Rdfing commented 3 years ago

@MilesCranmer,

I will play with the code more and report if the issue persists.

Thanks, Haochen