MilesCranmer commited on
Commit
d8f5888
1 Parent(s): f8bd450

Improve documentation

Browse files
Files changed (2) hide show
  1. README.md +6 -12
  2. eureqa.py +2 -2
README.md CHANGED
@@ -5,7 +5,7 @@ Uses regularized evolution and simulated annealing.
5
 
6
  ## Running:
7
 
8
- You can either call the program using `eureqa` from `eureqa.py`,
9
  or execute the program from the command line with, for example:
10
  ```bash
11
  python eureqa.py --threads 8 --binary-operators plus mult pow --npop 200
@@ -76,18 +76,12 @@ optional arguments:
76
 
77
  You can add more operators in `operators.jl`, or use default
78
  Julia ones. Make sure all operators are defined for scalar `Float32`.
79
- Then just call the operator in your call to `eureqa`.
 
 
80
 
81
- You can change the dataset in `eureqa.py` here:
82
- ```julia
83
- const X = convert(Array{Float32, 2}, randn(100, 5)*2)
84
- # Here is the function we want to learn (x2^2 + cos(x3) - 5)
85
- const y = convert(Array{Float32, 1}, ((cx,)->cx^2).(X[:, 2]) + cos.(X[:, 3]) .- 5)
86
- ```
87
- by either loading in a dataset, or modifying the definition of `y`.
88
- (The `.` are are used for vectorization of a scalar function)
89
-
90
- One can also adjust the relative probabilities of each operation here:
91
  ```julia
92
  weights = [8, 1, 1, 1, 0.1, 0.5, 2]
93
  ```
 
5
 
6
  ## Running:
7
 
8
+ You can either call the program by calling the `eureqa` function from `eureqa.py`,
9
  or execute the program from the command line with, for example:
10
  ```bash
11
  python eureqa.py --threads 8 --binary-operators plus mult pow --npop 200
 
76
 
77
  You can add more operators in `operators.jl`, or use default
78
  Julia ones. Make sure all operators are defined for scalar `Float32`.
79
+ Then just specify the operator names in your call, as above.
80
+ You can also change the dataset learned on by passing in `X` and `y` as
81
+ numpy arrays to `eureqa(...)`.
82
 
83
+ One can also adjust the relative probabilities of each operation here,
84
+ inside `eureqa.jl`:
 
 
 
 
 
 
 
 
85
  ```julia
86
  weights = [8, 1, 1, 1, 0.1, 0.5, 2]
87
  ```
eureqa.py CHANGED
@@ -67,7 +67,7 @@ def eureqa(X=None, y=None, threads=4, parsimony=1e-3, alpha=10,
67
  if test == 'simple1':
68
  eval_str = "X[:, 2]**2 + np.cos(X[:, 3]) - 5"
69
  elif test == 'simple2':
70
- eval_str = "X[:, 2]**3.5 + 1/abs(X[:, 0])"
71
 
72
  X = np.random.randn(100, 5)*3
73
  y = eval(eval_str)
@@ -151,7 +151,7 @@ if __name__ == "__main__":
151
  "--binary-operators", type=str, nargs="+", default=["plus", "mul"],
152
  help="Binary operators. Make sure they are defined in operators.jl")
153
  parser.add_argument(
154
- "--unary-operators", type=str, default=["exp", "sin", "cos"],
155
  help="Unary operators. Make sure they are defined in operators.jl")
156
  args = vars(parser.parse_args()) #dict
157
 
 
67
  if test == 'simple1':
68
  eval_str = "X[:, 2]**2 + np.cos(X[:, 3]) - 5"
69
  elif test == 'simple2':
70
+ eval_str = "np.sign(X[:, 2])*np.abs(X[:, 2])**3.5 + 1/np.abs(X[:, 0])"
71
 
72
  X = np.random.randn(100, 5)*3
73
  y = eval(eval_str)
 
151
  "--binary-operators", type=str, nargs="+", default=["plus", "mul"],
152
  help="Binary operators. Make sure they are defined in operators.jl")
153
  parser.add_argument(
154
+ "--unary-operators", type=str, nargs="+", default=["exp", "sin", "cos"],
155
  help="Unary operators. Make sure they are defined in operators.jl")
156
  args = vars(parser.parse_args()) #dict
157