Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
a8ee367
1
Parent(s):
68df0bb
Improve docstrings for post-hoc analysis
Browse files- pydoc-markdown.yml +1 -1
- pysr/sr.py +15 -5
pydoc-markdown.yml
CHANGED
@@ -40,7 +40,7 @@ renderer:
|
|
40 |
name: getting-started
|
41 |
source: docs/start.md
|
42 |
preamble: {weight: 1}
|
43 |
-
- title: Options
|
44 |
name: options
|
45 |
source: docs/options.md
|
46 |
preamble: {weight: 2}
|
|
|
40 |
name: getting-started
|
41 |
source: docs/start.md
|
42 |
preamble: {weight: 1}
|
43 |
+
- title: Features and Options
|
44 |
name: options
|
45 |
source: docs/options.md
|
46 |
preamble: {weight: 2}
|
pysr/sr.py
CHANGED
@@ -404,31 +404,41 @@ def get_hof(equation_file=None, n_features=None, variable_names=None, extra_symp
|
|
404 |
return output[['Complexity', 'MSE', 'score', 'Equation', 'sympy_format', 'lambda_format']]
|
405 |
|
406 |
def best_row(equations=None):
|
407 |
-
"""Return the best
|
|
|
|
|
408 |
if equations is None: equations = get_hof()
|
409 |
best_idx = np.argmax(equations['score'])
|
410 |
return equations.iloc[best_idx]
|
411 |
|
412 |
def best_tex(equations=None):
|
413 |
-
"""Return the equation with the best score, in latex format
|
|
|
|
|
414 |
if equations is None: equations = get_hof()
|
415 |
best_sympy = best_row(equations)['sympy_format']
|
416 |
return sympy.latex(best_sympy.simplify())
|
417 |
|
418 |
def best(equations=None):
|
419 |
-
"""Return the equation with the best score, in latex format
|
|
|
|
|
420 |
if equations is None: equations = get_hof()
|
421 |
best_sympy = best_row(equations)['sympy_format']
|
422 |
return best_sympy.simplify()
|
423 |
|
424 |
def best_tex(equations=None):
|
425 |
-
"""Return the equation with the best score, in latex format
|
|
|
|
|
426 |
if equations is None: equations = get_hof()
|
427 |
best_sympy = best_row(equations)['sympy_format']
|
428 |
return sympy.latex(best_sympy.simplify())
|
429 |
|
430 |
def best_callable(equations=None):
|
431 |
-
"""Return the equation with the best score, in callable format
|
|
|
|
|
432 |
if equations is None: equations = get_hof()
|
433 |
return best_row(equations)['lambda_format']
|
434 |
|
|
|
404 |
return output[['Complexity', 'MSE', 'score', 'Equation', 'sympy_format', 'lambda_format']]
|
405 |
|
406 |
def best_row(equations=None):
|
407 |
+
"""Return the best row of a hall of fame file using the score column.
|
408 |
+
By default this uses the last equation file.
|
409 |
+
"""
|
410 |
if equations is None: equations = get_hof()
|
411 |
best_idx = np.argmax(equations['score'])
|
412 |
return equations.iloc[best_idx]
|
413 |
|
414 |
def best_tex(equations=None):
|
415 |
+
"""Return the equation with the best score, in latex format
|
416 |
+
By default this uses the last equation file.
|
417 |
+
"""
|
418 |
if equations is None: equations = get_hof()
|
419 |
best_sympy = best_row(equations)['sympy_format']
|
420 |
return sympy.latex(best_sympy.simplify())
|
421 |
|
422 |
def best(equations=None):
|
423 |
+
"""Return the equation with the best score, in latex format
|
424 |
+
By default this uses the last equation file.
|
425 |
+
"""
|
426 |
if equations is None: equations = get_hof()
|
427 |
best_sympy = best_row(equations)['sympy_format']
|
428 |
return best_sympy.simplify()
|
429 |
|
430 |
def best_tex(equations=None):
|
431 |
+
"""Return the equation with the best score, in latex format
|
432 |
+
By default this uses the last equation file.
|
433 |
+
"""
|
434 |
if equations is None: equations = get_hof()
|
435 |
best_sympy = best_row(equations)['sympy_format']
|
436 |
return sympy.latex(best_sympy.simplify())
|
437 |
|
438 |
def best_callable(equations=None):
|
439 |
+
"""Return the equation with the best score, in callable format
|
440 |
+
By default this uses the last equation file.
|
441 |
+
"""
|
442 |
if equations is None: equations = get_hof()
|
443 |
return best_row(equations)['lambda_format']
|
444 |
|