MilesCranmer commited on
Commit
9ae2825
1 Parent(s): 955078f

Update examples.md

Browse files
Files changed (1) hide show
  1. docs/examples.md +6 -4
docs/examples.md CHANGED
@@ -249,9 +249,11 @@ Next, let's use this list of primes to create a dataset of $x, y$ pairs:
249
  import numpy as np
250
 
251
  X = np.random.randint(0, 100, 100)[:, None]
252
- y = [primes[3*X[i, 0] + 1] - 5 for i in range(100)]
253
  ```
254
 
 
 
255
  Finally, let's create a PySR model, and pass the custom operator. We also need to define the sympy equivalent, which we can leave as a placeholder for now:
256
 
257
  ```python
@@ -264,7 +266,7 @@ class sympy_p(sympy.Function):
264
  model = PySRRegressor(
265
  binary_operators=["+", "-", "*", "/"],
266
  unary_operators=["p"],
267
- niterations=1000,
268
  extra_sympy_mappings={"p": sympy_p}
269
  )
270
  ```
@@ -276,10 +278,10 @@ model.fit(X, y)
276
  ```
277
 
278
  if all works out, you should be able to see the true relation (note that the constant offset might not be exactly 1, since it is allowed to round to the nearest integer).
279
- You can get the sympy version of the last row with:
280
 
281
  ```python
282
- model.sympy(index=-1)
283
  ```
284
 
285
  ## 8. Additional features
 
249
  import numpy as np
250
 
251
  X = np.random.randint(0, 100, 100)[:, None]
252
+ y = [primes[3*X[i, 0] + 1] - 5 + np.random.randn()*0.001 for i in range(100)]
253
  ```
254
 
255
+ Note that we have also added a tiny bit of noise to the dataset.
256
+
257
  Finally, let's create a PySR model, and pass the custom operator. We also need to define the sympy equivalent, which we can leave as a placeholder for now:
258
 
259
  ```python
 
266
  model = PySRRegressor(
267
  binary_operators=["+", "-", "*", "/"],
268
  unary_operators=["p"],
269
+ niterations=100,
270
  extra_sympy_mappings={"p": sympy_p}
271
  )
272
  ```
 
278
  ```
279
 
280
  if all works out, you should be able to see the true relation (note that the constant offset might not be exactly 1, since it is allowed to round to the nearest integer).
281
+ You can get the sympy version of the best equation with:
282
 
283
  ```python
284
+ model.sympy()
285
  ```
286
 
287
  ## 8. Additional features