MilesCranmer commited on
Commit
cda5da4
1 Parent(s): bed9af6

Update PySR examples with PySRRegressor

Browse files
Files changed (1) hide show
  1. docs/examples.md +10 -19
docs/examples.md CHANGED
@@ -71,36 +71,27 @@ 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/`.
74
-
75
- For now, let's consider the expressions for output 0:
76
- ```python
77
- expressions = expressions[0]
78
- ```
79
- This is a pandas table, which we can filter:
80
  ```python
81
- best_expression = expressions.iloc[expressions.MSE.argmin()]
82
  ```
 
 
83
  We can see the LaTeX version of this with:
84
  ```python
85
- import sympy
86
- sympy.latex(best_expression.sympy_format)
87
  ```
88
-
89
- We can access the numpy version with:
90
  ```python
91
- f = best_expression.lambda_format
92
- print(f)
93
  ```
94
 
95
- Which shows a PySR object on numpy code:
96
- ```
97
- >> PySRFunction(X=>1/x0)
98
- ```
99
 
100
- Let's plot this against the truth:
101
  ```python
102
  from matplotlib import pyplot as plt
103
- plt.scatter(y[:, 0], f(X))
104
  plt.xlabel('Truth')
105
  plt.ylabel('Prediction')
106
  plt.show()
 
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/`.
74
+ We can again look at the equation chosen:
 
 
 
 
 
75
  ```python
76
+ print(model)
77
  ```
78
+
79
+ For now, let's consider the expressions for output 0.
80
  We can see the LaTeX version of this with:
81
  ```python
82
+ model.latex()[0]
 
83
  ```
84
+ or output 1 with `model.latex()[1]`.
85
+ and the sympy version with:
86
  ```python
87
+ model.sympy()[0]
 
88
  ```
89
 
 
 
 
 
90
 
91
+ Let's plot the prediction against the truth:
92
  ```python
93
  from matplotlib import pyplot as plt
94
+ plt.scatter(y[:, 0], model(X)[:, 0])
95
  plt.xlabel('Truth')
96
  plt.ylabel('Prediction')
97
  plt.show()