Spaces:
Running
Running
Add app to fit PySR model
Browse files- gui/app.py +29 -0
gui/app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
st.title("Interactive PySR")
|
| 6 |
+
file_name = st.file_uploader(
|
| 7 |
+
"Upload a data file, with your output column labeled 'y'", type=["csv"]
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
if file_name is not None:
|
| 11 |
+
col1, col2 = st.columns(2)
|
| 12 |
+
|
| 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"])
|