Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
67c22c7
1
Parent(s):
4800983
Tweak PySR demo
Browse files- examples/pysr_demo.ipynb +11 -7
examples/pysr_demo.ipynb
CHANGED
@@ -990,6 +990,7 @@
|
|
990 |
]
|
991 |
},
|
992 |
{
|
|
|
993 |
"cell_type": "markdown",
|
994 |
"metadata": {
|
995 |
"id": "3hS2kTAbbDhL"
|
@@ -999,9 +1000,9 @@
|
|
999 |
"\n",
|
1000 |
"Let's consider a time series problem:\n",
|
1001 |
"\n",
|
1002 |
-
"$$ z = y^2,\\quad y = \\frac{1}{
|
1003 |
"\n",
|
1004 |
-
"Imagine our time series is
|
1005 |
"\n",
|
1006 |
"But, as in our paper, **we can break this problem down into parts with a neural network. Then approximate the neural network with the symbolic regression!**\n",
|
1007 |
"\n",
|
@@ -1018,7 +1019,7 @@
|
|
1018 |
"source": [
|
1019 |
"###### np.random.seed(0)\n",
|
1020 |
"N = 100000\n",
|
1021 |
-
"Nt =
|
1022 |
"X = 6 * np.random.rand(N, Nt, 5) - 3\n",
|
1023 |
"y_i = X[..., 0] ** 2 + 6 * np.cos(2 * X[..., 2])\n",
|
1024 |
"y = np.sum(y_i, axis=1) / y_i.shape[1]\n",
|
@@ -1299,6 +1300,7 @@
|
|
1299 |
]
|
1300 |
},
|
1301 |
{
|
|
|
1302 |
"cell_type": "markdown",
|
1303 |
"metadata": {
|
1304 |
"id": "6WuaeqyqbDhe"
|
@@ -1306,7 +1308,7 @@
|
|
1306 |
"source": [
|
1307 |
"Recall we are searching for $y_i$ above:\n",
|
1308 |
"\n",
|
1309 |
-
"$$ z = y^2,\\quad y = \\frac{1}{
|
1310 |
]
|
1311 |
},
|
1312 |
{
|
@@ -1373,11 +1375,13 @@
|
|
1373 |
},
|
1374 |
"gpuClass": "standard",
|
1375 |
"kernelspec": {
|
1376 |
-
"display_name": "Python
|
1377 |
-
"
|
|
|
1378 |
},
|
1379 |
"language_info": {
|
1380 |
-
"name": "python"
|
|
|
1381 |
}
|
1382 |
},
|
1383 |
"nbformat": 4,
|
|
|
990 |
]
|
991 |
},
|
992 |
{
|
993 |
+
"attachments": {},
|
994 |
"cell_type": "markdown",
|
995 |
"metadata": {
|
996 |
"id": "3hS2kTAbbDhL"
|
|
|
1000 |
"\n",
|
1001 |
"Let's consider a time series problem:\n",
|
1002 |
"\n",
|
1003 |
+
"$$ z = y^2,\\quad y = \\frac{1}{10} \\sum(y_i),\\quad y_i = x_{i0}^2 + 6 \\cos(2*x_{i2})$$\n",
|
1004 |
"\n",
|
1005 |
+
"Imagine our time series is 10 timesteps. That is very hard for symbolic regression, even if we impose the inductive bias of $$z=f(\\sum g(x_i))$$ - it is the square of the number of possible equations!\n",
|
1006 |
"\n",
|
1007 |
"But, as in our paper, **we can break this problem down into parts with a neural network. Then approximate the neural network with the symbolic regression!**\n",
|
1008 |
"\n",
|
|
|
1019 |
"source": [
|
1020 |
"###### np.random.seed(0)\n",
|
1021 |
"N = 100000\n",
|
1022 |
+
"Nt = 10\n",
|
1023 |
"X = 6 * np.random.rand(N, Nt, 5) - 3\n",
|
1024 |
"y_i = X[..., 0] ** 2 + 6 * np.cos(2 * X[..., 2])\n",
|
1025 |
"y = np.sum(y_i, axis=1) / y_i.shape[1]\n",
|
|
|
1300 |
]
|
1301 |
},
|
1302 |
{
|
1303 |
+
"attachments": {},
|
1304 |
"cell_type": "markdown",
|
1305 |
"metadata": {
|
1306 |
"id": "6WuaeqyqbDhe"
|
|
|
1308 |
"source": [
|
1309 |
"Recall we are searching for $y_i$ above:\n",
|
1310 |
"\n",
|
1311 |
+
"$$ z = y^2,\\quad y = \\frac{1}{10} \\sum(y_i),\\quad y_i = x_{i0}^2 + 6 \\cos(2 x_{i2})$$"
|
1312 |
]
|
1313 |
},
|
1314 |
{
|
|
|
1375 |
},
|
1376 |
"gpuClass": "standard",
|
1377 |
"kernelspec": {
|
1378 |
+
"display_name": "Python (main_ipynb)",
|
1379 |
+
"language": "python",
|
1380 |
+
"name": "main_ipynb"
|
1381 |
},
|
1382 |
"language_info": {
|
1383 |
+
"name": "python",
|
1384 |
+
"version": "3.10.9"
|
1385 |
}
|
1386 |
},
|
1387 |
"nbformat": 4,
|