MilesCranmer commited on
Commit
ecc127c
1 Parent(s): 012bfcc

Give quick start example

Browse files
Files changed (1) hide show
  1. README.md +41 -3
README.md CHANGED
@@ -11,10 +11,40 @@ For python, you need to have Python 3, numpy, and pandas installed.
11
 
12
  ## Running:
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  What follows is the API reference for running the numpy interface.
15
- Note that nearly all parameters here
16
  have been tuned with ~1000 trials over several example
17
- equations. However, you should adjust `threads`, `niterations`,
 
18
  `binary_operators`, `unary_operators` to your requirements.
19
 
20
  The program will output a pandas DataFrame containing the equations,
@@ -30,7 +60,15 @@ You can also change the dataset learned on by passing in `X` and `y` as
30
  numpy arrays to `eureqa(...)`.
31
 
32
  ```python
33
- eureqa(X=None, y=None, threads=4, niterations=20, ncyclesperiteration=int(default_ncyclesperiteration), binary_operators=["plus", "mult"], unary_operators=["cos", "exp", "sin"], alpha=default_alpha, annealing=True, fractionReplaced=default_fractionReplaced, fractionReplacedHof=default_fractionReplacedHof, npop=int(default_npop), parsimony=default_parsimony, migration=True, hofMigration=True, shouldOptimizeConstants=True, topn=int(default_topn), weightAddNode=default_weightAddNode, weightDeleteNode=default_weightDeleteNode, weightDoNothing=default_weightDoNothing, weightMutateConstant=default_weightMutateConstant, weightMutateOperator=default_weightMutateOperator, weightRandomize=default_weightRandomize, weightSimplify=default_weightSimplify, timeout=None, equation_file='hall_of_fame.csv', test='simple1', maxsize=20)
 
 
 
 
 
 
 
 
34
  ```
35
 
36
  Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
 
11
 
12
  ## Running:
13
 
14
+ ### Quickstart
15
+
16
+ ```python
17
+ import numpy as np
18
+ from eureqa import eureqa
19
+
20
+ # Dataset
21
+ X = 2*np.random.randn(100, 5)
22
+ y = 2*np.cos(X[:, 3]) + X[:, 0]**2 - 2
23
+
24
+ # Learn equations
25
+ equations = eureqa(X, y, niterations=5)
26
+
27
+ ...
28
+
29
+ print(equations)
30
+ ```
31
+
32
+ which gives:
33
+
34
+ ```
35
+ Complexity MSE Equation
36
+ 0 5 1.947431 plus(-1.7420927, mult(x0, x0))
37
+ 1 8 0.486858 plus(-1.8710494, plus(cos(x3), mult(x0, x0)))
38
+ 2 11 0.000000 plus(plus(mult(x0, x0), cos(x3)), plus(-2.0, cos(x3)))
39
+ ```
40
+
41
+ ### API
42
+
43
  What follows is the API reference for running the numpy interface.
44
+ Note that most parameters here
45
  have been tuned with ~1000 trials over several example
46
+ equations, so you don't need to tune them yourself.
47
+ However, you should adjust `threads`, `niterations`,
48
  `binary_operators`, `unary_operators` to your requirements.
49
 
50
  The program will output a pandas DataFrame containing the equations,
 
60
  numpy arrays to `eureqa(...)`.
61
 
62
  ```python
63
+ eureqa(X=None, y=None, threads=4, niterations=20, ncyclesperiteration=int(default_ncyclesperiteration),
64
+ binary_operators=["plus", "mult"], unary_operators=["cos", "exp", "sin"], alpha=default_alpha,
65
+ annealing=True, fractionReplaced=default_fractionReplaced, fractionReplacedHof=default_fractionReplacedHof,
66
+ npop=int(default_npop), parsimony=default_parsimony, migration=True, hofMigration=True
67
+ shouldOptimizeConstants=True, topn=int(default_topn), weightAddNode=default_weightAddNode,
68
+ weightDeleteNode=default_weightDeleteNode, weightDoNothing=default_weightDoNothing,
69
+ weightMutateConstant=default_weightMutateConstant, weightMutateOperator=default_weightMutateOperator,
70
+ weightRandomize=default_weightRandomize, weightSimplify=default_weightSimplify, timeout=None,
71
+ equation_file='hall_of_fame.csv', test='simple1', maxsize=20)
72
  ```
73
 
74
  Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.