MilesCranmer commited on
Commit
9ab2202
1 Parent(s): fee76f1

Update examples.md

Browse files
Files changed (1) hide show
  1. docs/examples.md +10 -13
docs/examples.md CHANGED
@@ -180,13 +180,13 @@ as its search backend. This is a pure Julia package, and so can interface easily
180
  Julia package.
181
  For some tasks, it may be necessary to load such a package.
182
 
183
- For example, let's consider an example where we wish to find the following relationship:
184
 
185
  $$ y = p_{3x + 1} - 5, $$
186
 
187
  where $p_i$ is the $i$th prime number, and $x$ is the input feature.
188
 
189
- Let's see if we can discover this relationship between $x$ and $y$, using
190
  the [Primes.jl](https://github.com/JuliaMath/Primes.jl) package.
191
 
192
  First, let's manually initialize the Julia backend
@@ -212,14 +212,11 @@ Pkg.add("Primes")
212
  This imports the Julia package manager, and uses it to install
213
  `Primes.jl`. Now let's import `Primes.jl`:
214
 
215
- Now, let's import it
216
-
217
  ```python
218
  jl.eval("import Primes")
219
  ```
220
 
221
- Now, let's define a custom operator. We can then pass this
222
- to PySR later on.
223
 
224
  ```python
225
  jl.eval("""
@@ -233,20 +230,20 @@ end
233
  """)
234
  ```
235
 
236
- We have created a custom operator `p`, which takes an arbitrary number as input.
237
- It then checks whether the input is between 0.5 and 1000.
238
  If out-of-bounds, it returns `NaN`.
239
- If in-bounds, it rounds it to the nearest integer, and returns the corresponding prime number, mapped to the same type as input.
 
240
 
241
- Now, let's generate some test data, using the first 100 primes.
242
- Since we are using PyJulia, we can pass data back and forth
243
- to our custom Julia operator:
244
 
245
  ```python
246
  primes = {i: jl.p(i*1.0) for i in range(1, 999)}
247
  ```
248
 
249
- And let's create a dataset:
250
 
251
  ```python
252
  import numpy as np
 
180
  Julia package.
181
  For some tasks, it may be necessary to load such a package.
182
 
183
+ For example, let's say we wish to discovery the following relationship:
184
 
185
  $$ y = p_{3x + 1} - 5, $$
186
 
187
  where $p_i$ is the $i$th prime number, and $x$ is the input feature.
188
 
189
+ Let's see if we can discover this using
190
  the [Primes.jl](https://github.com/JuliaMath/Primes.jl) package.
191
 
192
  First, let's manually initialize the Julia backend
 
212
  This imports the Julia package manager, and uses it to install
213
  `Primes.jl`. Now let's import `Primes.jl`:
214
 
 
 
215
  ```python
216
  jl.eval("import Primes")
217
  ```
218
 
219
+ Now, we define a custom operator:
 
220
 
221
  ```python
222
  jl.eval("""
 
230
  """)
231
  ```
232
 
233
+ We have created a a function `p`, which takes an arbitrary number as input.
234
+ `p` first checks whether the input is between 0.5 and 1000.
235
  If out-of-bounds, it returns `NaN`.
236
+ If in-bounds, it rounds it to the nearest integer, compures the corresponding prime number, and then
237
+ converts it to the same type as input.
238
 
239
+ Next, let's generate a list of primes for our test dataset.
240
+ Since we are using PyJulia, we can just call `p` directly to do this:
 
241
 
242
  ```python
243
  primes = {i: jl.p(i*1.0) for i in range(1, 999)}
244
  ```
245
 
246
+ Next, let's use this list of primes to create a dataset of $x, y$ pairs:
247
 
248
  ```python
249
  import numpy as np