MilesCranmer commited on
Commit
bc63109
1 Parent(s): 79a7cfe

Bump version with precision parameter

Browse files
Files changed (3) hide show
  1. Project.toml +1 -1
  2. pysr/sr.py +17 -4
  3. setup.py +1 -1
Project.toml CHANGED
@@ -2,5 +2,5 @@
2
  SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
3
 
4
  [compat]
5
- SymbolicRegression = "0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9"
6
  julia = "1.5"
 
2
  SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
3
 
4
  [compat]
5
+ SymbolicRegression = "0.6.9"
6
  julia = "1.5"
pysr/sr.py CHANGED
@@ -133,6 +133,7 @@ def pysr(
133
  denoise=False,
134
  Xresampled=None,
135
  precision=32,
 
136
  ):
137
  """Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
138
  Note: most default parameters have been tuned over several example
@@ -253,6 +254,8 @@ def pysr(
253
  :type denoise: bool
254
  :param precision: What precision to use for the data. By default this is 32 (float32), but you can select 64 or 16 as well.
255
  :type precision: int
 
 
256
  :returns: Results dataframe, giving complexity, MSE, and equations (as strings), as well as functional forms. If list, each element corresponds to a dataframe of equations for each output.
257
  :type: pd.DataFrame/list
258
  """
@@ -431,6 +434,7 @@ def pysr(
431
  tournament_selection_p=tournament_selection_p,
432
  denoise=denoise,
433
  precision=precision,
 
434
  )
435
 
436
  kwargs = {**_set_paths(tempdir), **kwargs}
@@ -488,12 +492,19 @@ def _set_globals(X, **kwargs):
488
  global_state[key] = value
489
 
490
 
491
- def _final_pysr_process(julia_optimization, runfile_filename, timeout, **kwargs):
 
 
492
  command = [
493
  "julia",
494
  f"-O{julia_optimization:d}",
495
- str(runfile_filename),
496
  ]
 
 
 
 
 
 
497
  if timeout is not None:
498
  command = ["timeout", f"{timeout}"] + command
499
  _cmd_runner(command, **kwargs)
@@ -544,6 +555,7 @@ def _create_julia_files(
544
  pkg_directory,
545
  need_install,
546
  update,
 
547
  **kwargs,
548
  ):
549
  with open(hyperparam_filename, "w") as f:
@@ -573,14 +585,15 @@ def _create_julia_files(
573
  "[" + ",".join(['"' + vname + '"' for vname in variable_names]) + "]"
574
  )
575
 
 
576
  if weights is not None:
577
  print(
578
- f"EquationSearch(X, y, weights=weights, niterations={niterations:d}, varMap={varMap}, options=options, numprocs={procs})",
579
  file=f,
580
  )
581
  else:
582
  print(
583
- f"EquationSearch(X, y, niterations={niterations:d}, varMap={varMap}, options=options, numprocs={procs})",
584
  file=f,
585
  )
586
 
 
133
  denoise=False,
134
  Xresampled=None,
135
  precision=32,
136
+ multithreading=False,
137
  ):
138
  """Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
139
  Note: most default parameters have been tuned over several example
 
254
  :type denoise: bool
255
  :param precision: What precision to use for the data. By default this is 32 (float32), but you can select 64 or 16 as well.
256
  :type precision: int
257
+ :param multithreading: Use multithreading instead of distributed
258
+ :type multithreading: bool
259
  :returns: Results dataframe, giving complexity, MSE, and equations (as strings), as well as functional forms. If list, each element corresponds to a dataframe of equations for each output.
260
  :type: pd.DataFrame/list
261
  """
 
434
  tournament_selection_p=tournament_selection_p,
435
  denoise=denoise,
436
  precision=precision,
437
+ multithreading=multithreading,
438
  )
439
 
440
  kwargs = {**_set_paths(tempdir), **kwargs}
 
492
  global_state[key] = value
493
 
494
 
495
+ def _final_pysr_process(
496
+ julia_optimization, runfile_filename, timeout, multithreading, procs, **kwargs
497
+ ):
498
  command = [
499
  "julia",
500
  f"-O{julia_optimization:d}",
 
501
  ]
502
+
503
+ if multithreading:
504
+ command.append("--threads")
505
+ command.append(f"{procs}")
506
+
507
+ command.append(str(runfile_filename))
508
  if timeout is not None:
509
  command = ["timeout", f"{timeout}"] + command
510
  _cmd_runner(command, **kwargs)
 
555
  pkg_directory,
556
  need_install,
557
  update,
558
+ multithreading,
559
  **kwargs,
560
  ):
561
  with open(hyperparam_filename, "w") as f:
 
585
  "[" + ",".join(['"' + vname + '"' for vname in variable_names]) + "]"
586
  )
587
 
588
+ cprocs = 0 if multithreading else procs
589
  if weights is not None:
590
  print(
591
+ f"EquationSearch(X, y, weights=weights, niterations={niterations:d}, varMap={varMap}, options=options, numprocs={cprocs}, multithreading={'true' if multithreading else 'false'})",
592
  file=f,
593
  )
594
  else:
595
  print(
596
+ f"EquationSearch(X, y, niterations={niterations:d}, varMap={varMap}, options=options, numprocs={cprocs})",
597
  file=f,
598
  )
599
 
setup.py CHANGED
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
 
6
  setuptools.setup(
7
  name="pysr",
8
- version="0.6.9",
9
  author="Miles Cranmer",
10
  author_email="[email protected]",
11
  description="Simple and efficient symbolic regression",
 
5
 
6
  setuptools.setup(
7
  name="pysr",
8
+ version="0.6.10",
9
  author="Miles Cranmer",
10
  author_email="[email protected]",
11
  description="Simple and efficient symbolic regression",