PySR icon indicating copy to clipboard operation
PySR copied to clipboard

RuntimeError: Couldn't find equation file! The equation search likely exited before a single iteration completed.

Open aforsythe opened this issue 4 years ago • 6 comments

Not sure what happened. I was running this code fine, although the regression was not producing the ground truth result.

import numpy as np
from pysr import pysr, best

Y = np.random.rand(1000,1) * 100
L = 116 * (Y / 100)**(1/3) - 16

# Learn equations
equations = pysr(
    Y,
    L,
    niterations=25,
    binary_operators=["+","-", "*", "/","pow"],
    variable_names =['Y'],
)  # Define your own operator! (Julia syntax)

...  # (you can use ctl-c to exit early)

print(best(equations))

Modified it to be niterations=50 and got the following RuntimeError: Couldn't find equation file! The equation search likely exited before a single iteration completed.

Modified it back to niterations=25 but I still get the error

Traceback is

FileNotFoundError                         Traceback (most recent call last)
/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pysr/sr.py in get_hof(equation_file, n_features, variable_names, output_jax_format, output_torch_format, selection, extra_sympy_mappings, extra_jax_mappings, extra_torch_mappings, multioutput, nout, **kwargs)
   1000         else:
-> 1001             all_outputs = [pd.read_csv(str(equation_file) + ".bkup", sep="|")]
   1002     except FileNotFoundError:

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/io/parsers.py in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
    609 
--> 610     return _read(filepath_or_buffer, kwds)
    611 

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
    461     # Create the parser.
--> 462     parser = TextFileReader(filepath_or_buffer, **kwds)
    463 

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
    818 
--> 819         self._engine = self._make_engine(self.engine)
    820 

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
   1049         # error: Too many arguments for "ParserBase"
-> 1050         return mapping[engine](self.f, **self.options)  # type: ignore[call-arg]
   1051 

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
   1866         # open handles
-> 1867         self._open_handles(src, kwds)
   1868         assert self.handles is not None

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/io/parsers.py in _open_handles(self, src, kwds)
   1361         """
-> 1362         self.handles = get_handle(
   1363             src,

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
    641             # Encoding
--> 642             handle = open(
    643                 handle,

FileNotFoundError: [Errno 2] No such file or directory: 'hall_of_fame_2021-11-12_131554.354.csv.bkup'

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
<ipython-input-1-975c7ae50776> in <module>
      6 
      7 # Learn equations
----> 8 equations = pysr(
      9     Y,
     10     L,

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pysr/sr.py in pysr(X, y, weights, binary_operators, unary_operators, procs, loss, populations, niterations, ncyclesperiteration, alpha, annealing, fractionReplaced, fractionReplacedHof, npop, parsimony, migration, hofMigration, shouldOptimizeConstants, topn, weightAddNode, weightInsertNode, weightDeleteNode, weightDoNothing, weightMutateConstant, weightMutateOperator, weightRandomize, weightSimplify, perturbationFactor, timeout, extra_sympy_mappings, extra_torch_mappings, extra_jax_mappings, equation_file, verbosity, progress, maxsize, fast_cycle, maxdepth, variable_names, batching, batchSize, select_k_features, warmupMaxsizeBy, constraints, useFrequency, tempdir, delete_tempfiles, julia_optimization, julia_project, user_input, update, temp_equation_file, output_jax_format, output_torch_format, optimizer_algorithm, optimizer_nrestarts, optimize_probability, optimizer_iterations, tournament_selection_n, tournament_selection_p, denoise, Xresampled, precision, multithreading)
    476     _set_globals(**kwargs)
    477 
--> 478     equations = get_hof(**kwargs)
    479 
    480     if delete_tempfiles:

/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/pysr/sr.py in get_hof(equation_file, n_features, variable_names, output_jax_format, output_torch_format, selection, extra_sympy_mappings, extra_jax_mappings, extra_torch_mappings, multioutput, nout, **kwargs)
   1001             all_outputs = [pd.read_csv(str(equation_file) + ".bkup", sep="|")]
   1002     except FileNotFoundError:
-> 1003         raise RuntimeError(
   1004             "Couldn't find equation file! The equation search likely exited before a single iteration completed."
   1005         )

aforsythe avatar Nov 12 '21 21:11 aforsythe

Hey @aforsythe, sorry for the late response. Am at the end of my internship and in a bit of crunch time.

So, this error just indicates that the python frontend couldn't find the output of the backend. This likely means the Julia backend crashed. What was the other output? The julia output will help me debug this. Thanks! -Miles

MilesCranmer avatar Nov 19 '21 20:11 MilesCranmer

how to solve this problem ?

liuzd2017 avatar Dec 31 '21 07:12 liuzd2017

Hi! @MilesCranmer, I think the output of Julia is the following:

ERROR: LoadError: InexactError: trunc(Int32, 4.1416199449e10)
Stacktrace:

jzsmoreno avatar Jan 05 '22 21:01 jzsmoreno

@jzsmoreno do you have a script where I can reproduce this?

MilesCranmer avatar Jan 07 '22 01:01 MilesCranmer

Hi @MilesCranmer

I run the example.py I don't know if you remember me, but I already have an issue with PySR. I updated the version and I updated Julia packages. Also I have to install in Julia SymbolycRegression. I erase the folder General and I update again. So the previous error that I have, is already solved. But now I have this error. That's why I commented this.

jzsmoreno avatar Jan 07 '22 02:01 jzsmoreno

Hi @jzsmoreno, Right, I see that the issue is unresolved now, sorry. Let's move back to that one (#67). Cheers, Miles

MilesCranmer avatar Jan 10 '22 18:01 MilesCranmer