Spaces:
Sleeping
Sleeping
Commit
·
e6db1f3
1
Parent(s):
b66d8de
Fix out-of-path functionality
Browse files
eureqa.py
CHANGED
|
@@ -106,6 +106,11 @@ def eureqa(X=None, y=None, threads=4, parsimony=1e-3, alpha=10,
|
|
| 106 |
const y = convert(Array{Float32, 1}, """f"{y_str})""""
|
| 107 |
"""
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
with open('.hyperparams.jl', 'w') as f:
|
| 110 |
print(def_hyperparams, file=f)
|
| 111 |
|
|
@@ -113,21 +118,16 @@ def eureqa(X=None, y=None, threads=4, parsimony=1e-3, alpha=10,
|
|
| 113 |
print(def_datasets, file=f)
|
| 114 |
|
| 115 |
command = [
|
| 116 |
-
f'cd {pathlib.Path(__file__).parent.absolute()}', #Move to filepath of code
|
| 117 |
-
'&&',
|
| 118 |
'julia -O3',
|
| 119 |
f'--threads {threads}',
|
| 120 |
'-e',
|
| 121 |
f'\'include("eureqa.jl"); fullRun({niterations:d}, npop={npop:d}, annealing={"true" if annealing else "false"}, ncyclesperiteration={ncyclesperiteration:d}, fractionReplaced={fractionReplaced:f}f0, verbosity=round(Int32, 1e9), topn={topn:d})\'',
|
| 122 |
-
'&&',
|
| 123 |
-
f'cd {pathlib.Path().absolute()}',
|
| 124 |
]
|
| 125 |
-
|
| 126 |
-
cur_cmd = ' '.join(command[:-2])
|
| 127 |
print("Running on", cur_cmd)
|
| 128 |
os.system(cur_cmd)
|
| 129 |
output = pd.read_csv(equation_file, sep="|")
|
| 130 |
-
os.system(
|
| 131 |
return output
|
| 132 |
|
| 133 |
|
|
|
|
| 106 |
const y = convert(Array{Float32, 1}, """f"{y_str})""""
|
| 107 |
"""
|
| 108 |
|
| 109 |
+
starting_path = f'cd {pathlib.Path().absolute()}'
|
| 110 |
+
code_path = f'cd {pathlib.Path(__file__).parent.absolute()}' #Move to filepath of code
|
| 111 |
+
|
| 112 |
+
os.system(code_path)
|
| 113 |
+
|
| 114 |
with open('.hyperparams.jl', 'w') as f:
|
| 115 |
print(def_hyperparams, file=f)
|
| 116 |
|
|
|
|
| 118 |
print(def_datasets, file=f)
|
| 119 |
|
| 120 |
command = [
|
|
|
|
|
|
|
| 121 |
'julia -O3',
|
| 122 |
f'--threads {threads}',
|
| 123 |
'-e',
|
| 124 |
f'\'include("eureqa.jl"); fullRun({niterations:d}, npop={npop:d}, annealing={"true" if annealing else "false"}, ncyclesperiteration={ncyclesperiteration:d}, fractionReplaced={fractionReplaced:f}f0, verbosity=round(Int32, 1e9), topn={topn:d})\'',
|
|
|
|
|
|
|
| 125 |
]
|
| 126 |
+
cur_cmd = ' '.join(command)
|
|
|
|
| 127 |
print("Running on", cur_cmd)
|
| 128 |
os.system(cur_cmd)
|
| 129 |
output = pd.read_csv(equation_file, sep="|")
|
| 130 |
+
os.system(starting_path)
|
| 131 |
return output
|
| 132 |
|
| 133 |
|