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

Clean up hyperparameter file

Browse files
Files changed (1) hide show
  1. eureqa.py +0 -22
eureqa.py CHANGED
@@ -75,35 +75,17 @@ def eureqa(X=None, y=None, threads=4, parsimony=1e-3, alpha=10,
75
 
76
  def_hyperparams = f"""
77
  include("operators.jl")
78
- ##########################
79
- # # Allowed operators
80
- # (Apparently using const for globals helps speed)
81
  const binops = {'[' + ', '.join(binary_operators) + ']'}
82
  const unaops = {'[' + ', '.join(unary_operators) + ']'}
83
- ##########################
84
-
85
- # How many equations to search when replacing
86
  const ns=10;
87
-
88
- ##################
89
- # Hyperparameters
90
- # How much to punish complexity
91
  const parsimony = {parsimony:f}f0
92
- # How much to scale temperature by (T between 0 and 1)
93
  const alpha = {alpha:f}f0
94
- # Max size of an equation (too large will slow program down)
95
  const maxsize = {maxsize:d}
96
- # Whether to migrate between threads (you should)
97
  const migration = {'true' if migration else 'false'}
98
- # Whether to re-introduce best examples seen (helps a lot)
99
  const hofMigration = {'true' if hofMigration else 'false'}
100
- # Fraction of population to replace with hall of fame
101
  const fractionReplacedHof = {fractionReplacedHof}f0
102
- # Optimize constants
103
  const shouldOptimizeConstants = {'true' if shouldOptimizeConstants else 'false'}
104
- # File to put operators
105
  const hofFile = "{equation_file}"
106
- ##################
107
  """
108
 
109
  assert len(X.shape) == 2
@@ -113,12 +95,8 @@ def eureqa(X=None, y=None, threads=4, parsimony=1e-3, alpha=10,
113
  y_str = str(y.tolist())
114
 
115
  def_datasets = """
116
- # Here is the function we want to learn (x2^2 + cos(x3) + 5)
117
- ##########################
118
- # # Dataset to learn
119
  const X = convert(Array{Float32, 2}, """f"{X_str})""""
120
  const y = convert(Array{Float32, 1}, """f"{y_str})""""
121
- ##########################
122
  """
123
 
124
  with open('.hyperparams.jl', 'w') as f:
 
75
 
76
  def_hyperparams = f"""
77
  include("operators.jl")
 
 
 
78
  const binops = {'[' + ', '.join(binary_operators) + ']'}
79
  const unaops = {'[' + ', '.join(unary_operators) + ']'}
 
 
 
80
  const ns=10;
 
 
 
 
81
  const parsimony = {parsimony:f}f0
 
82
  const alpha = {alpha:f}f0
 
83
  const maxsize = {maxsize:d}
 
84
  const migration = {'true' if migration else 'false'}
 
85
  const hofMigration = {'true' if hofMigration else 'false'}
 
86
  const fractionReplacedHof = {fractionReplacedHof}f0
 
87
  const shouldOptimizeConstants = {'true' if shouldOptimizeConstants else 'false'}
 
88
  const hofFile = "{equation_file}"
 
89
  """
90
 
91
  assert len(X.shape) == 2
 
95
  y_str = str(y.tolist())
96
 
97
  def_datasets = """
 
 
 
98
  const X = convert(Array{Float32, 2}, """f"{X_str})""""
99
  const y = convert(Array{Float32, 1}, """f"{y_str})""""
 
100
  """
101
 
102
  with open('.hyperparams.jl', 'w') as f: