pyeggp 1.0.2__cp310-cp310-manylinux_2_28_aarch64.whl → 1.0.3__cp310-cp310-manylinux_2_28_aarch64.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 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
@@ -152,3 +158,19 @@ class PyEGGP(BaseEstimator, RegressorMixin):
152
158
  def score(self, X, y):
153
159
  ypred = self.evaluate_best_model(X)
154
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyeggp
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Python Wheels for eggp algorithm.
5
5
  Author-email: Fabricio Olivetti <folivetti@users.noreply.github.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,6 +1,6 @@
1
- pyeggp/__init__.py,sha256=ag29g10K_goyZDXVPc-QeT5M332KN1mddYZ-FaEGlgQ,5775
1
+ pyeggp/__init__.py,sha256=pD4mYwe9-JQ7vmD5zGdC3EtGfyj7o1xmetYBHdTOB5Q,6572
2
2
  pyeggp/__main__.py,sha256=dAMEebAw-mVcR5PUffuRsUDPFm6Vf4qvaam9TPSUs0I,155
3
- pyeggp/_binding.cpython-310-aarch64-linux-gnu.so,sha256=k15K_l1rO5R97zst-4cazmG1aSyMFVeBI6LHvH9-qG8,1016193
3
+ pyeggp/_binding.cpython-310-aarch64-linux-gnu.so,sha256=qftUCZQJ1dKkgRYVk28bxpfUfYcaXY1MYEuDjOh-Joc,1016193
4
4
  pyeggp/_binding.py,sha256=nTO9o8SQC3SXK4zF3df5aBOQ4ktn2a-3P8gQTnMrNIQ,591
5
5
  pyeggp/_binding.pyi,sha256=TsI8Gar1wpDs3c8V26i3w_u1JjznlE5dReV59bbVUh0,460
6
6
  pyeggp/binding.i,sha256=AdPEymjqByW6OhpJS08o2oTc7Go3-274JqRhbXoyDjg,1908
@@ -119,9 +119,9 @@ pyeggp./libHSzlib-0-48ee1f9e.7.1.0-5585aebc199b08d8e21b5678c0fd28335affe6252f546
119
119
  pyeggp./libffi-c0132414.so.8,sha256=oTvjWevsiUzLHfgJ-ZZLqC1CD1h0cC6biH2mE8iWFuE,132737
120
120
  pyeggp./libgmp-6d1678ee.so.10.3.2,sha256=K-WFYhW6C3Z3ecUJJps22sV11vBCXEVqIP5tzap4xyg,605705
121
121
  pyeggp./libnlopt-38a103cb.so.0,sha256=SoGgo4hNv89sqJRH5RWvp21cEoJFfQCkLSkVTBynEp8,738297
122
- pyeggp-1.0.2.dist-info/METADATA,sha256=ezRmsnPEc0Uc8Coi_5xX08en30lyJdV0PKk8gT2njvc,42220
123
- pyeggp-1.0.2.dist-info/WHEEL,sha256=eDp1bqKv1fOPqy6hq3cz1RoeS_CSkkWg6r1puEBnKq4,114
124
- pyeggp-1.0.2.dist-info/entry_points.txt,sha256=NJouaQ2UoCLBu7Toqer0FBvNSDYMawR_Wx9STMdopyY,48
125
- pyeggp-1.0.2.dist-info/top_level.txt,sha256=iLrWfWZHh4NruYDgVyn2ntEB-uJ8fIs95nzNVLIhKE4,7
126
- pyeggp-1.0.2.dist-info/RECORD,,
127
- pyeggp-1.0.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
122
+ pyeggp-1.0.3.dist-info/METADATA,sha256=iubFYUSUPnA_cO2U9VqWB47FKamC7_WdTStNT67bl4o,42220
123
+ pyeggp-1.0.3.dist-info/WHEEL,sha256=eDp1bqKv1fOPqy6hq3cz1RoeS_CSkkWg6r1puEBnKq4,114
124
+ pyeggp-1.0.3.dist-info/entry_points.txt,sha256=NJouaQ2UoCLBu7Toqer0FBvNSDYMawR_Wx9STMdopyY,48
125
+ pyeggp-1.0.3.dist-info/top_level.txt,sha256=iLrWfWZHh4NruYDgVyn2ntEB-uJ8fIs95nzNVLIhKE4,7
126
+ pyeggp-1.0.3.dist-info/RECORD,,
127
+ pyeggp-1.0.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
File without changes