Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
3dbb2ea
1
Parent(s):
022f0e5
Create function that generates LaTeX table
Browse files- pysr/sr.py +43 -0
pysr/sr.py
CHANGED
@@ -1988,6 +1988,49 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
1988 |
return ret_outputs
|
1989 |
return ret_outputs[0]
|
1990 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1991 |
|
1992 |
def _denoise(X, y, Xresampled=None, random_state=None):
|
1993 |
"""Denoise the dataset using a Gaussian process"""
|
|
|
1988 |
return ret_outputs
|
1989 |
return ret_outputs[0]
|
1990 |
|
1991 |
+
def latex_table(self, indices=None):
|
1992 |
+
"""Create a LaTeX/booktabs table for all, or some, of the equations.
|
1993 |
+
|
1994 |
+
Parameters
|
1995 |
+
----------
|
1996 |
+
indices : list[int], default=None
|
1997 |
+
If you wish to select a particular subset of equations from
|
1998 |
+
`self.equations_`, give the row numbers here. By default,
|
1999 |
+
all equations will be used.
|
2000 |
+
|
2001 |
+
Returns
|
2002 |
+
-------
|
2003 |
+
latex_table_string : str
|
2004 |
+
A string that will render a table in LaTeX of the equations.
|
2005 |
+
"""
|
2006 |
+
if indices is None:
|
2007 |
+
indices = range(len(self.equations_))
|
2008 |
+
latex_table_pieces = [
|
2009 |
+
r"\begin{table}[h]",
|
2010 |
+
r"\centering",
|
2011 |
+
r"\caption{}",
|
2012 |
+
r"\label{}",
|
2013 |
+
r"\begin{tabular}{@{}lcc@{}}",
|
2014 |
+
r"\toprule",
|
2015 |
+
r"Equation & Complexity & Loss \\",
|
2016 |
+
r"\midrule",
|
2017 |
+
]
|
2018 |
+
for i in indices:
|
2019 |
+
row_pieces = [
|
2020 |
+
"$" + self.latex(i) + "$",
|
2021 |
+
str(self.equations_.iloc[i]["complexity"]),
|
2022 |
+
str(self.equations_.iloc[i]["loss"]),
|
2023 |
+
]
|
2024 |
+
latex_table_pieces += [
|
2025 |
+
" & ".join(row_pieces) + r" \\",
|
2026 |
+
]
|
2027 |
+
latex_table_pieces += [
|
2028 |
+
r"\bottomrule",
|
2029 |
+
r"\end{tabular}",
|
2030 |
+
r"\end{table}",
|
2031 |
+
]
|
2032 |
+
return "\n".join(latex_table_pieces)
|
2033 |
+
|
2034 |
|
2035 |
def _denoise(X, y, Xresampled=None, random_state=None):
|
2036 |
"""Denoise the dataset using a Gaussian process"""
|