MilesCranmer commited on
Commit
90d24f5
1 Parent(s): 555ddd0

Update more parts of docs

Browse files
Files changed (1) hide show
  1. docs/examples.md +11 -11
docs/examples.md CHANGED
@@ -23,8 +23,9 @@ find the expression `2 cos(x3) + x0^2 - 2`.
23
  ```python
24
  X = 2 * np.random.randn(100, 5)
25
  y = 2 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 2
26
- expressions = pysr(X, y, binary_operators=["+", "-", "*", "/"], **kwargs)
27
- print(best(expressions))
 
28
  ```
29
 
30
  ## 2. Custom operator
@@ -34,14 +35,13 @@ Here, we define a custom operator and use it to find an expression:
34
  ```python
35
  X = 2 * np.random.randn(100, 5)
36
  y = 1 / X[:, 0]
37
- expressions = pysr(
38
- X,
39
- y,
40
  binary_operators=["plus", "mult"],
41
  unary_operators=["inv(x) = 1/x"],
42
  **kwargs
43
  )
44
- print(best(expressions))
 
45
  ```
46
 
47
  ## 3. Multiple outputs
@@ -51,23 +51,23 @@ each requiring a different feature.
51
  ```python
52
  X = 2 * np.random.randn(100, 5)
53
  y = 1 / X[:, [0, 1, 2]]
54
- expressions = pysr(
55
- X,
56
- y,
57
  binary_operators=["plus", "mult"],
58
  unary_operators=["inv(x) = 1/x"],
59
  **kwargs
60
  )
 
61
  ```
62
 
63
  ## 4. Plotting an expression
64
 
65
  Here, let's use the same equations, but get a format we can actually
66
- use and test. We can add this option after a search via the `get_hof`
67
  function:
68
 
69
  ```python
70
- expressions = get_hof(extra_sympy_mappings={"inv": lambda x: 1/x})
 
71
  ```
72
  If you look at the lists of expressions before and after, you will
73
  see that the sympy format now has replaced `inv` with `1/`.
 
23
  ```python
24
  X = 2 * np.random.randn(100, 5)
25
  y = 2 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 2
26
+ model = PySRRegressor(binary_operators=["+", "-", "*", "/"], **kwargs)
27
+ model.fit(X, y)
28
+ print(model)
29
  ```
30
 
31
  ## 2. Custom operator
 
35
  ```python
36
  X = 2 * np.random.randn(100, 5)
37
  y = 1 / X[:, 0]
38
+ model = PySRRegressor(
 
 
39
  binary_operators=["plus", "mult"],
40
  unary_operators=["inv(x) = 1/x"],
41
  **kwargs
42
  )
43
+ model.fit(X, y)
44
+ print(model)
45
  ```
46
 
47
  ## 3. Multiple outputs
 
51
  ```python
52
  X = 2 * np.random.randn(100, 5)
53
  y = 1 / X[:, [0, 1, 2]]
54
+ model = PySRRegressor(
 
 
55
  binary_operators=["plus", "mult"],
56
  unary_operators=["inv(x) = 1/x"],
57
  **kwargs
58
  )
59
+ model.fit(X, y)
60
  ```
61
 
62
  ## 4. Plotting an expression
63
 
64
  Here, let's use the same equations, but get a format we can actually
65
+ use and test. We can add this option after a search via the `set_params`
66
  function:
67
 
68
  ```python
69
+ model.set_params(extra_sympy_mappings={"inv": lambda x: 1/x})
70
+ model.sympy()
71
  ```
72
  If you look at the lists of expressions before and after, you will
73
  see that the sympy format now has replaced `inv` with `1/`.