Skip to content

Commit

Permalink
Tweak PySR demo
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Feb 9, 2023
1 parent 4800983 commit 67c22c7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions examples/pysr_demo.ipynb
Expand Up @@ -990,6 +990,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "3hS2kTAbbDhL"
Expand All @@ -999,9 +1000,9 @@
"\n",
"Let's consider a time series problem:\n",
"\n",
"$$ z = y^2,\\quad y = \\frac{1}{100} \\sum(y_i),\\quad y_i = x_{i0}^2 + 6 \\cos(2*x_{i2})$$\n",
"$$ z = y^2,\\quad y = \\frac{1}{10} \\sum(y_i),\\quad y_i = x_{i0}^2 + 6 \\cos(2*x_{i2})$$\n",
"\n",
"Imagine our time series is 100 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",
"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",
"\n",
"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",
"\n",
Expand All @@ -1018,7 +1019,7 @@
"source": [
"###### np.random.seed(0)\n",
"N = 100000\n",
"Nt = 100\n",
"Nt = 10\n",
"X = 6 * np.random.rand(N, Nt, 5) - 3\n",
"y_i = X[..., 0] ** 2 + 6 * np.cos(2 * X[..., 2])\n",
"y = np.sum(y_i, axis=1) / y_i.shape[1]\n",
Expand Down Expand Up @@ -1299,14 +1300,15 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "6WuaeqyqbDhe"
},
"source": [
"Recall we are searching for $y_i$ above:\n",
"\n",
"$$ z = y^2,\\quad y = \\frac{1}{100} \\sum(y_i),\\quad y_i = x_{i0}^2 + 6 \\cos(2 x_{i2})$$"
"$$ z = y^2,\\quad y = \\frac{1}{10} \\sum(y_i),\\quad y_i = x_{i0}^2 + 6 \\cos(2 x_{i2})$$"
]
},
{
Expand Down Expand Up @@ -1373,11 +1375,13 @@
},
"gpuClass": "standard",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
"display_name": "Python (main_ipynb)",
"language": "python",
"name": "main_ipynb"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 67c22c7

Please sign in to comment.