Spaces:
Running
Running
MilesCranmer
commited on
Update to PySR 0.18.1
Browse files- gui/app.py +0 -2
- gui/install_pysr.sh +0 -14
- gui/requirements.txt +1 -1
- gui/run_pysr_and_save.py +17 -32
gui/app.py
CHANGED
@@ -11,8 +11,6 @@ empty_df = pd.DataFrame(
|
|
11 |
}
|
12 |
)
|
13 |
|
14 |
-
os.system("bash install_pysr.sh")
|
15 |
-
|
16 |
|
17 |
def greet(
|
18 |
file_obj: tempfile._TemporaryFileWrapper,
|
|
|
11 |
}
|
12 |
)
|
13 |
|
|
|
|
|
14 |
|
15 |
def greet(
|
16 |
file_obj: tempfile._TemporaryFileWrapper,
|
gui/install_pysr.sh
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
# Install Julia:
|
4 |
-
if [ ! -f "/home/user/.local/bin/julia" ]; then
|
5 |
-
wget https://raw.githubusercontent.com/abelsiqueira/jill/main/jill.sh
|
6 |
-
chmod a+x jill.sh
|
7 |
-
./jill.sh --version 1.8.2 -y
|
8 |
-
fi
|
9 |
-
|
10 |
-
# Need to install PySR in separate python instance:
|
11 |
-
if [ ! -d "/home/user/.julia/environments/pysr-0.11.9" ]; then
|
12 |
-
export PATH="$HOME/.local/bin:$PATH"
|
13 |
-
python -c 'import pysr; pysr.install()'
|
14 |
-
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gui/requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
pysr==0.
|
2 |
numpy
|
3 |
pandas
|
|
|
1 |
+
pysr==0.18.1
|
2 |
numpy
|
3 |
pandas
|
gui/run_pysr_and_save.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import pandas as pd
|
3 |
import traceback as tb
|
4 |
import numpy as np
|
|
|
5 |
from argparse import ArgumentParser
|
6 |
|
7 |
# Args:
|
@@ -34,37 +35,25 @@ if __name__ == "__main__":
|
|
34 |
filename = args.filename
|
35 |
maxsize = args.maxsize
|
36 |
|
37 |
-
os.environ["PATH"] += ":/home/user/.local/bin/"
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
df = pd.read_csv(filename)
|
51 |
-
y = np.array(df[col_to_fit])
|
52 |
-
X = df.drop([col_to_fit], axis=1)
|
53 |
-
|
54 |
-
model = PySRRegressor(
|
55 |
-
update=False,
|
56 |
-
progress=False,
|
57 |
-
maxsize=maxsize,
|
58 |
-
niterations=niterations,
|
59 |
-
binary_operators=binary_operators,
|
60 |
-
unary_operators=unary_operators,
|
61 |
-
)
|
62 |
-
model.fit(X, y)
|
63 |
-
|
64 |
-
df = model.equations_[["equation", "loss", "complexity"]]
|
65 |
-
# Convert all columns to string type:
|
66 |
-
df = df.astype(str)
|
67 |
-
error_message = (
|
68 |
"Success!\n"
|
69 |
f"You may run the model locally (faster) with "
|
70 |
f"the following parameters:"
|
@@ -76,10 +65,6 @@ model = PySRRegressor(
|
|
76 |
maxsize={maxsize},
|
77 |
)
|
78 |
model.fit(X, y)""")
|
79 |
-
except Exception as e:
|
80 |
-
error_message = tb.format_exc()
|
81 |
-
# Dump to file:
|
82 |
-
df = empty_df
|
83 |
|
84 |
df.to_csv("pysr_output.csv", index=False)
|
85 |
with open("error.log", "w") as f:
|
|
|
2 |
import pandas as pd
|
3 |
import traceback as tb
|
4 |
import numpy as np
|
5 |
+
from pysr import PySRRegressor
|
6 |
from argparse import ArgumentParser
|
7 |
|
8 |
# Args:
|
|
|
35 |
filename = args.filename
|
36 |
maxsize = args.maxsize
|
37 |
|
|
|
38 |
|
39 |
+
df = pd.read_csv(filename)
|
40 |
+
y = np.array(df[col_to_fit])
|
41 |
+
X = df.drop([col_to_fit], axis=1)
|
42 |
|
43 |
+
model = PySRRegressor(
|
44 |
+
progress=False,
|
45 |
+
verbosity=0,
|
46 |
+
maxsize=maxsize,
|
47 |
+
niterations=niterations,
|
48 |
+
binary_operators=binary_operators,
|
49 |
+
unary_operators=unary_operators,
|
50 |
+
)
|
51 |
+
model.fit(X, y)
|
52 |
|
53 |
+
df = model.equations_[["equation", "loss", "complexity"]]
|
54 |
+
# Convert all columns to string type:
|
55 |
+
df = df.astype(str)
|
56 |
+
error_message = (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
"Success!\n"
|
58 |
f"You may run the model locally (faster) with "
|
59 |
f"the following parameters:"
|
|
|
65 |
maxsize={maxsize},
|
66 |
)
|
67 |
model.fit(X, y)""")
|
|
|
|
|
|
|
|
|
68 |
|
69 |
df.to_csv("pysr_output.csv", index=False)
|
70 |
with open("error.log", "w") as f:
|