pyeggp 1.0.1__cp39-cp39-macosx_14_0_x86_64.whl → 1.0.3__cp39-cp39-macosx_14_0_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyeggp/__init__.py +23 -0
- pyeggp/_binding.cpython-39-darwin.so +0 -0
- {pyeggp-1.0.1.dist-info → pyeggp-1.0.3.dist-info}/METADATA +1 -1
- {pyeggp-1.0.1.dist-info → pyeggp-1.0.3.dist-info}/RECORD +8 -8
- {pyeggp-1.0.1.dist-info → pyeggp-1.0.3.dist-info}/WHEEL +0 -0
- {pyeggp-1.0.1.dist-info → pyeggp-1.0.3.dist-info}/entry_points.txt +0 -0
- {pyeggp-1.0.1.dist-info → pyeggp-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {pyeggp-1.0.1.dist-info → pyeggp-1.0.3.dist-info}/top_level.txt +0 -0
pyeggp/__init__.py
CHANGED
@@ -2,6 +2,7 @@ import atexit
|
|
2
2
|
from contextlib import contextmanager
|
3
3
|
from threading import Lock
|
4
4
|
from typing import Iterator, List
|
5
|
+
import string
|
5
6
|
from io import StringIO
|
6
7
|
import tempfile
|
7
8
|
import csv
|
@@ -58,6 +59,11 @@ def pyeggp_run(dataset: str, gen: int, nPop: int, maxSize: int, nTournament: int
|
|
58
59
|
with hs_rts_init():
|
59
60
|
return unsafe_hs_pyeggp_run(dataset, gen, nPop, maxSize, nTournament, pc, pm, nonterminals, loss, optIter, optRepeat, nParams, split, simplify, dumpTo, loadFrom)
|
60
61
|
|
62
|
+
def make_function(expression):
|
63
|
+
def func(x, t):
|
64
|
+
return eval(expression)
|
65
|
+
return func
|
66
|
+
|
61
67
|
class PyEGGP(BaseEstimator, RegressorMixin):
|
62
68
|
def __init__(self, gen = 100, nPop = 100, maxSize = 15, nTournament = 3, pc = 0.9, pm = 0.3, nonterminals = "add,sub,mul,div", loss = "MSE", optIter = 50, optRepeat = 2, nParams = -1, split = 1, simplify = False, dumpTo = "", loadFrom = ""):
|
63
69
|
self.gen = gen
|
@@ -137,6 +143,7 @@ class PyEGGP(BaseEstimator, RegressorMixin):
|
|
137
143
|
best = self.results[self.results.id==ix].iloc[view]
|
138
144
|
t = np.array(list(map(float, best.theta.split(";"))))
|
139
145
|
return eval(best.Numpy)
|
146
|
+
|
140
147
|
def evaluate_model_view(self, x, ix, view):
|
141
148
|
if x.ndim == 1:
|
142
149
|
x = x.reshape(-1,1)
|
@@ -151,3 +158,19 @@ class PyEGGP(BaseEstimator, RegressorMixin):
|
|
151
158
|
def score(self, X, y):
|
152
159
|
ypred = self.evaluate_best_model(X)
|
153
160
|
return r2_score(y, ypred)
|
161
|
+
def get_model(self, idx):
|
162
|
+
alphabet = list(string.ascii_uppercase)
|
163
|
+
row = self.results[self.results['id']==idx].iloc[0]
|
164
|
+
visual_expression = row['Numpy']
|
165
|
+
model = make_function(visual_expression)
|
166
|
+
n_params_used = len(row['theta'].split(sep=';'))
|
167
|
+
|
168
|
+
# Works for solutions with less than 26 parameters
|
169
|
+
for i in range(n_params_used):
|
170
|
+
visual_expression = visual_expression.replace(f't[{i}]', alphabet[i])
|
171
|
+
|
172
|
+
# Works for data with less than 50 dimensions
|
173
|
+
for i in range(50):
|
174
|
+
visual_expression = visual_expression.replace(f'x[:, {i}]', f'X{i}')
|
175
|
+
|
176
|
+
return model, visual_expression
|
Binary file
|
@@ -1,14 +1,14 @@
|
|
1
|
-
pyeggp
|
2
|
-
pyeggp-1.0.1.dist-info/WHEEL,sha256=SY5k3lEzlF5bfpGBmmxcfZtVPJk-byPddM4TNHg-8Nw,108
|
3
|
-
pyeggp-1.0.1.dist-info/entry_points.txt,sha256=NJouaQ2UoCLBu7Toqer0FBvNSDYMawR_Wx9STMdopyY,48
|
4
|
-
pyeggp-1.0.1.dist-info/top_level.txt,sha256=iLrWfWZHh4NruYDgVyn2ntEB-uJ8fIs95nzNVLIhKE4,7
|
5
|
-
pyeggp-1.0.1.dist-info/METADATA,sha256=vbigkLKhJ_sSORsiKsZkFnU-Mjs8jOSN4Rj7gypQbtU,42220
|
6
|
-
pyeggp-1.0.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
7
|
-
pyeggp/__init__.py,sha256=rzgGMRTJwRU0BDhfUCcE1G0OvFwu3o0qcjTfTRV7q54,5774
|
1
|
+
pyeggp/__init__.py,sha256=pD4mYwe9-JQ7vmD5zGdC3EtGfyj7o1xmetYBHdTOB5Q,6572
|
8
2
|
pyeggp/_binding.pyi,sha256=TsI8Gar1wpDs3c8V26i3w_u1JjznlE5dReV59bbVUh0,460
|
9
|
-
pyeggp/_binding.cpython-39-darwin.so,sha256=
|
3
|
+
pyeggp/_binding.cpython-39-darwin.so,sha256=8-qCugl1wHf_hfJuzhHb6egOu0OpgoDxSDhmug1OxW0,55148144
|
10
4
|
pyeggp/binding.i,sha256=AdPEymjqByW6OhpJS08o2oTc7Go3-274JqRhbXoyDjg,1908
|
11
5
|
pyeggp/_binding.py,sha256=XImcPYlOIstr_dT9qMD68Ay7vPUB4mmduZ818hEKk3Q,579
|
12
6
|
pyeggp/typing.py,sha256=qr1vWstl5HiaUT5HGsQFHO4pRq4EhqEc4zG2mn9QHgc,517
|
13
7
|
pyeggp/__main__.py,sha256=dAMEebAw-mVcR5PUffuRsUDPFm6Vf4qvaam9TPSUs0I,155
|
14
8
|
pyeggp/.dylibs/libnlopt.1.0.0.dylib,sha256=KLCzh-73JgicfAN8r0WwrJmSXeKsu498GZ1uTQiUu6g,480064
|
9
|
+
pyeggp-1.0.3.dist-info/RECORD,,
|
10
|
+
pyeggp-1.0.3.dist-info/WHEEL,sha256=SY5k3lEzlF5bfpGBmmxcfZtVPJk-byPddM4TNHg-8Nw,108
|
11
|
+
pyeggp-1.0.3.dist-info/entry_points.txt,sha256=NJouaQ2UoCLBu7Toqer0FBvNSDYMawR_Wx9STMdopyY,48
|
12
|
+
pyeggp-1.0.3.dist-info/top_level.txt,sha256=iLrWfWZHh4NruYDgVyn2ntEB-uJ8fIs95nzNVLIhKE4,7
|
13
|
+
pyeggp-1.0.3.dist-info/METADATA,sha256=iubFYUSUPnA_cO2U9VqWB47FKamC7_WdTStNT67bl4o,42220
|
14
|
+
pyeggp-1.0.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|