Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
edbcfa6
1
Parent(s):
c6a43c4
Install PyCall.jl with other python instance
Browse files- gui/app.py +21 -8
gui/app.py
CHANGED
@@ -1,4 +1,16 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import numpy as np
|
3 |
import pandas as pd
|
4 |
|
@@ -13,17 +25,18 @@ if file_name is not None:
|
|
13 |
df = pd.read_csv(file_name)
|
14 |
y = np.array(df["y"])
|
15 |
X = df.drop(["y"], axis=1)
|
16 |
-
import pysr
|
17 |
-
|
18 |
-
pysr.install()
|
19 |
-
from pysr import PySRRegressor
|
20 |
|
21 |
-
model = PySRRegressor()
|
22 |
model.fit(X, y)
|
23 |
|
24 |
col1.header("Equation")
|
25 |
col2.header("Loss")
|
26 |
-
# model.equations_ is a pd.DataFrame
|
27 |
for i, row in model.equations_.iterrows():
|
28 |
-
col1.subheader(row["equation"])
|
29 |
-
col2.subheader(row["loss"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import os
|
3 |
+
|
4 |
+
# Need to install PySR in separate python instance:
|
5 |
+
os.system(
|
6 |
+
"""
|
7 |
+
if [ ! -d "$HOME/.julia/environments/pysr-0.9.1" ]; then
|
8 |
+
python -c 'import pysr; pysr.install()'
|
9 |
+
fi
|
10 |
+
"""
|
11 |
+
)
|
12 |
+
import pysr
|
13 |
+
from pysr import PySRRegressor
|
14 |
import numpy as np
|
15 |
import pandas as pd
|
16 |
|
|
|
25 |
df = pd.read_csv(file_name)
|
26 |
y = np.array(df["y"])
|
27 |
X = df.drop(["y"], axis=1)
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
model = PySRRegressor(update=False)
|
30 |
model.fit(X, y)
|
31 |
|
32 |
col1.header("Equation")
|
33 |
col2.header("Loss")
|
|
|
34 |
for i, row in model.equations_.iterrows():
|
35 |
+
col1.subheader(str(row["equation"]))
|
36 |
+
col2.subheader(str(row["loss"]))
|
37 |
+
|
38 |
+
model = None
|
39 |
+
|
40 |
+
Main = None
|
41 |
+
pysr.sr.Main = None
|
42 |
+
pysr.sr.already_ran = False
|