eggp 2.1.1__tar.gz → 2.2.1__tar.gz
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.
- {eggp-2.1.1 → eggp-2.2.1}/PKG-INFO +1 -1
- {eggp-2.1.1 → eggp-2.2.1}/pyproject.toml +1 -1
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp/__init__.py +20 -13
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp/binding.i +3 -3
- eggp-2.2.1/src/eggp/binding.py +66 -0
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp/typing.py +1 -1
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp.egg-info/PKG-INFO +1 -1
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp.egg-info/SOURCES.txt +1 -0
- {eggp-2.1.1 → eggp-2.2.1}/LICENSE +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/README.md +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/setup.cfg +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/setup.py +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp/__main__.py +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp/_binding.pyi +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp.egg-info/dependency_links.txt +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp.egg-info/entry_points.txt +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp.egg-info/requires.txt +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/src/eggp.egg-info/top_level.txt +0 -0
- {eggp-2.1.1 → eggp-2.2.1}/test/test_pyeggp.py +0 -0
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "eggp"
|
|
15
|
-
version = "2.
|
|
15
|
+
version = "2.2.1"
|
|
16
16
|
authors = [{ name = "Fabricio Olivetti", email = "folivetti@users.noreply.github.com" }]
|
|
17
17
|
description = "Python Wheels for eggp algorithm."
|
|
18
18
|
readme = "README.md"
|
|
@@ -44,13 +44,13 @@ def _get_hs_eggp_run_data():
|
|
|
44
44
|
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
|
|
45
45
|
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
|
|
46
46
|
ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int,
|
|
47
|
-
ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ctypes.c_int,
|
|
47
|
+
ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ctypes.c_int,
|
|
48
48
|
]
|
|
49
49
|
lib.hs_eggp_run_data.restype = ctypes.c_char_p
|
|
50
50
|
_hs_eggp_run_data = lib.hs_eggp_run_data
|
|
51
51
|
return _hs_eggp_run_data
|
|
52
52
|
|
|
53
|
-
VERSION: str = "2.
|
|
53
|
+
VERSION: str = "2.2.1"
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
_hs_rts_init: bool = False
|
|
@@ -88,11 +88,11 @@ def main(args: List[str] = []) -> int:
|
|
|
88
88
|
with hs_rts_init(rts_args + cli_args):
|
|
89
89
|
return unsafe_hs_eggp_main()
|
|
90
90
|
|
|
91
|
-
def eggp_run(dataset: str, gen: int, nPop: int, maxSize: int, nTournament: int, pc: float, pm: float, nonterminals: str, loss: str, optIter: int, optRepeat: int, nParams: int, split: int, max_time : int, simplify: int, trace : int, generational : int, dumpTo: str, loadFrom: str, varnames : str, useFracBayes: int, dbFile: str = "", dbDataset: str = "", dbCacheSize: int = 100000, dbFlushEvery: int = 0) -> str:
|
|
91
|
+
def eggp_run(dataset: str, gen: int, nPop: int, maxSize: int, nTournament: int, pc: float, pm: float, nonterminals: str, loss: str, optIter: int, optRepeat: int, nParams: int, split: int, max_time : int, simplify: int, trace : int, generational : int, dumpTo: str, loadFrom: str, varnames : str, useFracBayes: int, dbFile: str = "", dbFitFile: str = "", dbDataset: str = "", dbCacheSize: int = 100000, dbFlushEvery: int = 0) -> str:
|
|
92
92
|
with hs_rts_init():
|
|
93
|
-
return unsafe_hs_eggp_run(dataset, gen, nPop, maxSize, nTournament, pc, pm, nonterminals, loss, optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo, loadFrom, varnames, useFracBayes, dbFile, dbDataset, dbCacheSize, dbFlushEvery)
|
|
93
|
+
return unsafe_hs_eggp_run(dataset, gen, nPop, maxSize, nTournament, pc, pm, nonterminals, loss, optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo, loadFrom, varnames, useFracBayes, dbFile, dbFitFile, dbDataset, dbCacheSize, dbFlushEvery)
|
|
94
94
|
|
|
95
|
-
def eggp_run_data(data: np.ndarray, nrows: List[int], header: str, params: str, gen: int, nPop: int, maxSize: int, nTournament: int, pc: float, pm: float, nonterminals: str, loss: str, optIter: int, optRepeat: int, nParams: int, split: int, max_time : int, simplify: int, trace : int, generational : int, dumpTo: str, loadFrom: str, varnames : str, useFracBayes: int, dbFile: str = "", dbDataset: str = "", dbCacheSize: int = 100000, dbFlushEvery: int = 0) -> str:
|
|
95
|
+
def eggp_run_data(data: np.ndarray, nrows: List[int], header: str, params: str, gen: int, nPop: int, maxSize: int, nTournament: int, pc: float, pm: float, nonterminals: str, loss: str, optIter: int, optRepeat: int, nParams: int, split: int, max_time : int, simplify: int, trace : int, generational : int, dumpTo: str, loadFrom: str, varnames : str, useFracBayes: int, dbFile: str = "", dbFitFile: str = "", dbDataset: str = "", dbCacheSize: int = 100000, dbFlushEvery: int = 0) -> str:
|
|
96
96
|
''' Runs eggp with the dataset passed directly as a contiguous double
|
|
97
97
|
array, bypassing the temp-CSV round trip.
|
|
98
98
|
|
|
@@ -113,7 +113,7 @@ def eggp_run_data(data: np.ndarray, nrows: List[int], header: str, params: str,
|
|
|
113
113
|
cdata = data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))
|
|
114
114
|
cnrows = (ctypes.c_int * len(nrows))(*nrows)
|
|
115
115
|
with hs_rts_init():
|
|
116
|
-
out = _get_hs_eggp_run_data()(cdata, cnrows, len(nrows), data.shape[1], header.encode(), params.encode(), gen, nPop, maxSize, nTournament, pc, pm, nonterminals.encode(), loss.encode(), optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo.encode(), loadFrom.encode(), varnames.encode(), useFracBayes, dbFile.encode(), dbDataset.encode(), dbCacheSize, dbFlushEvery)
|
|
116
|
+
out = _get_hs_eggp_run_data()(cdata, cnrows, len(nrows), data.shape[1], header.encode(), params.encode(), gen, nPop, maxSize, nTournament, pc, pm, nonterminals.encode(), loss.encode(), optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo.encode(), loadFrom.encode(), varnames.encode(), useFracBayes, dbFile.encode(), dbFitFile.encode(), dbDataset.encode(), dbCacheSize, dbFlushEvery)
|
|
117
117
|
return out.decode("utf-8") if out is not None else ""
|
|
118
118
|
|
|
119
119
|
def make_function(expression, loss="MSE"):
|
|
@@ -233,7 +233,7 @@ class EGGP(BaseEstimator, RegressorMixin):
|
|
|
233
233
|
>>> estimator = EGGP(loss="Bernoulli")
|
|
234
234
|
>>> estimator.fit(X, y)
|
|
235
235
|
"""
|
|
236
|
-
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, folds = 1, max_time = -1, simplify = False, trace = False, generational = False, dumpTo = "", loadFrom = "", useFracBayes = False, pinball_tau = 0.5, dbFile = "", dbDataset = "", dbCacheSize = 100000, dbFlushEvery = 0):
|
|
236
|
+
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, folds = 1, max_time = -1, simplify = False, trace = False, generational = False, dumpTo = "", loadFrom = "", useFracBayes = False, pinball_tau = 0.5, dbFile = "", dbFitFile = "", dbDataset = "", dbCacheSize = 100000, dbFlushEvery = 0):
|
|
237
237
|
nts = "add,sub,mul,div,power,powerabs,\
|
|
238
238
|
aq,abs,sin,cos,tan,sinh,cosh,tanh,\
|
|
239
239
|
asin,acos,atan,asinh,acosh,atanh,sqrt,\
|
|
@@ -297,6 +297,7 @@ class EGGP(BaseEstimator, RegressorMixin):
|
|
|
297
297
|
self.useFracBayes = int(useFracBayes)
|
|
298
298
|
self.pinball_tau = pinball_tau
|
|
299
299
|
self.dbFile = dbFile
|
|
300
|
+
self.dbFitFile = dbFitFile
|
|
300
301
|
self.dbDataset = dbDataset
|
|
301
302
|
self.dbCacheSize = dbCacheSize
|
|
302
303
|
self.dbFlushEvery = dbFlushEvery
|
|
@@ -389,7 +390,7 @@ class EGGP(BaseEstimator, RegressorMixin):
|
|
|
389
390
|
|
|
390
391
|
dname = self.get_fname("", header)
|
|
391
392
|
|
|
392
|
-
csv_data = eggp_run_data(combined, [combined.shape[0]], ",".join(header), dname, self.gen, self.nPop, self.maxSize, self.nTournament, self.pc, self.pm, self.nonterminals, self.loss_arg, self.optIter, self.optRepeat, self.nParams, self.folds, self.max_time, self.simplify, self.trace, self.generational, self.dumpTo, self.loadFrom, varnames, self.useFracBayes, self.dbFile, self.dbDataset, self.dbCacheSize, self.dbFlushEvery)
|
|
393
|
+
csv_data = eggp_run_data(combined, [combined.shape[0]], ",".join(header), dname, self.gen, self.nPop, self.maxSize, self.nTournament, self.pc, self.pm, self.nonterminals, self.loss_arg, self.optIter, self.optRepeat, self.nParams, self.folds, self.max_time, self.simplify, self.trace, self.generational, self.dumpTo, self.loadFrom, varnames, self.useFracBayes, self.dbFile, self.dbFitFile, self.dbDataset, self.dbCacheSize, self.dbFlushEvery)
|
|
393
394
|
|
|
394
395
|
if len(csv_data) > 0:
|
|
395
396
|
csv_io = StringIO(csv_data.strip())
|
|
@@ -424,7 +425,7 @@ class EGGP(BaseEstimator, RegressorMixin):
|
|
|
424
425
|
dname = self.get_fname("", header)
|
|
425
426
|
|
|
426
427
|
csv_data = eggp_run_data(data, nrows, ",".join(header), dname, self.gen, self.nPop, self.maxSize, self.nTournament, self.pc, self.pm,
|
|
427
|
-
self.nonterminals, self.loss_arg, self.optIter, self.optRepeat, self.nParams, self.folds, self.max_time, self.simplify, self.trace, self.generational, self.dumpTo, self.loadFrom, varnames, self.useFracBayes, self.dbFile, self.dbDataset, self.dbCacheSize, self.dbFlushEvery)
|
|
428
|
+
self.nonterminals, self.loss_arg, self.optIter, self.optRepeat, self.nParams, self.folds, self.max_time, self.simplify, self.trace, self.generational, self.dumpTo, self.loadFrom, varnames, self.useFracBayes, self.dbFile, self.dbFitFile, self.dbDataset, self.dbCacheSize, self.dbFlushEvery)
|
|
428
429
|
|
|
429
430
|
if len(csv_data) > 0:
|
|
430
431
|
csv_io = StringIO(csv_data.strip())
|
|
@@ -485,14 +486,20 @@ class EGGP(BaseEstimator, RegressorMixin):
|
|
|
485
486
|
|
|
486
487
|
if x.ndim == 1:
|
|
487
488
|
x = x.reshape(-1,1)
|
|
488
|
-
|
|
489
|
+
best = self._best_row()
|
|
490
|
+
tStr = best.theta.split(";")
|
|
489
491
|
t = np.array(list(map(float, tStr))) if len(tStr[0]) > 0 else np.array([])
|
|
490
|
-
y = eval(
|
|
492
|
+
y = eval(best.Numpy)
|
|
491
493
|
if self.loss == "Bernoulli":
|
|
492
494
|
return 1/(1 + np.exp(-y))
|
|
493
495
|
elif self.loss == "Poisson":
|
|
494
496
|
return np.exp(y)
|
|
495
497
|
return y
|
|
498
|
+
def _best_row(self):
|
|
499
|
+
"""Select the best model (lowest training loss)."""
|
|
500
|
+
lt = pd.to_numeric(self.results["loss_train"], errors="coerce")
|
|
501
|
+
return self.results.loc[lt.idxmin()]
|
|
502
|
+
|
|
496
503
|
def evaluate_best_model_view(self, x, view):
|
|
497
504
|
if view not in np.unique(self.results.view.values):
|
|
498
505
|
raise ValueError("Invalid view index")
|
|
@@ -500,8 +507,8 @@ class EGGP(BaseEstimator, RegressorMixin):
|
|
|
500
507
|
x = x.to_numpy()
|
|
501
508
|
if x.ndim == 1:
|
|
502
509
|
x = x.reshape(-1,1)
|
|
503
|
-
ix = self.
|
|
504
|
-
best = self.results[self.results.id==ix].iloc[
|
|
510
|
+
ix = self._best_row().id
|
|
511
|
+
best = self.results[(self.results.id==ix) & (self.results.view==view)].iloc[0]
|
|
505
512
|
t = np.array(list(map(float, best.theta.split(";")))) if len(best.theta) > 0 else np.array([])
|
|
506
513
|
y = eval(best.Numpy)
|
|
507
514
|
if self.loss == "Bernoulli":
|
|
@@ -10,8 +10,8 @@ int unsafe_hs_eggp_main() {
|
|
|
10
10
|
return hs_eggp_main();
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
char * unsafe_hs_eggp_run( char *dataset, int gens, int nPop, int maxSize, int nTournament, double pc, double pm, char *nonterminals, char *loss, int optIter, int optRepeat, int nParams, int split, int max_time, int simplify, int trace, int generational, char *dumpTo, char *loadFrom, char *varnames, int useFracBayes, char *dbFile, char *dbDataset, int dbCacheSize, int dbFlushEvery ) {
|
|
14
|
-
return hs_eggp_run(dataset, gens, nPop, maxSize, nTournament, pc, pm, nonterminals, loss, optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo, loadFrom, varnames, useFracBayes, dbFile, dbDataset, dbCacheSize, dbFlushEvery);
|
|
13
|
+
char * unsafe_hs_eggp_run( char *dataset, int gens, int nPop, int maxSize, int nTournament, double pc, double pm, char *nonterminals, char *loss, int optIter, int optRepeat, int nParams, int split, int max_time, int simplify, int trace, int generational, char *dumpTo, char *loadFrom, char *varnames, int useFracBayes, char *dbFile, char *dbFitFile, char *dbDataset, int dbCacheSize, int dbFlushEvery ) {
|
|
14
|
+
return hs_eggp_run(dataset, gens, nPop, maxSize, nTournament, pc, pm, nonterminals, loss, optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo, loadFrom, varnames, useFracBayes, dbFile, dbFitFile, dbDataset, dbCacheSize, dbFlushEvery);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
void unsafe_hs_eggp_init(int argc, char **argv) {
|
|
@@ -59,6 +59,6 @@ void unsafe_py_write_stderr( char * str) {
|
|
|
59
59
|
|
|
60
60
|
char * unsafe_hs_eggp_version();
|
|
61
61
|
int unsafe_hs_eggp_main();
|
|
62
|
-
char * unsafe_hs_eggp_run( char *dataset, int gens, int nPop, int maxSize, int nTournament, double p, double pm, char *nonterminals, char *loss, int optIter, int optRepeat, int nParams, int split, int max_time, int simplify, int trace, int generational, char *dumpTo, char *loadFrom, char *varnames, int useFracBayes, char *dbFile, char *dbDataset, int dbCacheSize, int dbFlushEvery);
|
|
62
|
+
char * unsafe_hs_eggp_run( char *dataset, int gens, int nPop, int maxSize, int nTournament, double p, double pm, char *nonterminals, char *loss, int optIter, int optRepeat, int nParams, int split, int max_time, int simplify, int trace, int generational, char *dumpTo, char *loadFrom, char *varnames, int useFracBayes, char *dbFile, char *dbFitFile, char *dbDataset, int dbCacheSize, int dbFlushEvery);
|
|
63
63
|
void unsafe_hs_eggp_init(int argc, char **argv);
|
|
64
64
|
void unsafe_hs_eggp_exit();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
|
2
|
+
# Version 4.5.0
|
|
3
|
+
#
|
|
4
|
+
# Do not make changes to this file unless you know what you are doing - modify
|
|
5
|
+
# the SWIG interface file instead.
|
|
6
|
+
|
|
7
|
+
import typing
|
|
8
|
+
# Import the low-level C/C++ module
|
|
9
|
+
if getattr(globals().get("__spec__"), "parent", None) or __package__ or "." in __name__:
|
|
10
|
+
from . import _binding
|
|
11
|
+
else:
|
|
12
|
+
import _binding
|
|
13
|
+
|
|
14
|
+
import builtins as __builtin__
|
|
15
|
+
|
|
16
|
+
def _swig_repr(self):
|
|
17
|
+
try:
|
|
18
|
+
strthis = "proxy of " + self.this.__repr__()
|
|
19
|
+
except __builtin__.Exception:
|
|
20
|
+
strthis = ""
|
|
21
|
+
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _swig_setattr_nondynamic_instance_variable(set):
|
|
25
|
+
def set_instance_attr(self, name, value):
|
|
26
|
+
if name == "this":
|
|
27
|
+
set(self, name, value)
|
|
28
|
+
elif name == "thisown":
|
|
29
|
+
self.this.own(value)
|
|
30
|
+
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
|
|
31
|
+
set(self, name, value)
|
|
32
|
+
else:
|
|
33
|
+
raise AttributeError("You cannot add instance attributes to %s" % self)
|
|
34
|
+
return set_instance_attr
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _swig_setattr_nondynamic_class_variable(set):
|
|
38
|
+
def set_class_attr(cls, name, value):
|
|
39
|
+
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
|
|
40
|
+
set(cls, name, value)
|
|
41
|
+
else:
|
|
42
|
+
raise AttributeError("You cannot add class attributes to %s" % cls)
|
|
43
|
+
return set_class_attr
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class _SwigNonDynamicMeta(type):
|
|
47
|
+
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
|
|
48
|
+
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def unsafe_hs_eggp_version():
|
|
53
|
+
return _binding.unsafe_hs_eggp_version()
|
|
54
|
+
|
|
55
|
+
def unsafe_hs_eggp_main():
|
|
56
|
+
return _binding.unsafe_hs_eggp_main()
|
|
57
|
+
|
|
58
|
+
def unsafe_hs_eggp_run(dataset, gens, nPop, maxSize, nTournament, p, pm, nonterminals, loss, optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo, loadFrom, varnames, useFracBayes, dbFile, dbFitFile, dbDataset, dbCacheSize, dbFlushEvery):
|
|
59
|
+
return _binding.unsafe_hs_eggp_run(dataset, gens, nPop, maxSize, nTournament, p, pm, nonterminals, loss, optIter, optRepeat, nParams, split, max_time, simplify, trace, generational, dumpTo, loadFrom, varnames, useFracBayes, dbFile, dbFitFile, dbDataset, dbCacheSize, dbFlushEvery)
|
|
60
|
+
|
|
61
|
+
def unsafe_hs_eggp_init(argc):
|
|
62
|
+
return _binding.unsafe_hs_eggp_init(argc)
|
|
63
|
+
|
|
64
|
+
def unsafe_hs_eggp_exit():
|
|
65
|
+
return _binding.unsafe_hs_eggp_exit()
|
|
66
|
+
|
|
@@ -11,4 +11,4 @@ else:
|
|
|
11
11
|
class Session(Protocol):
|
|
12
12
|
def version(self) -> str: ...
|
|
13
13
|
def main(self, args: List[str] = []) -> int: ...
|
|
14
|
-
def eggp_run(self, dataset: str, gen: int, nPop: int, maxSize: int, nTournament: int, pc: float, pm: float, nonterminals: str, loss: str, optIter: int, optRepeat: int, nParams: int, split: int, max_time: int, simplify: int, trace : int, generational : int, dumpTo: str, loadFrom: str, varnames: str, useFracBayes: int, dbFile: str = "", dbDataset: str = "", dbCacheSize: int = 100000, dbFlushEvery: int = 0) -> str: ...
|
|
14
|
+
def eggp_run(self, dataset: str, gen: int, nPop: int, maxSize: int, nTournament: int, pc: float, pm: float, nonterminals: str, loss: str, optIter: int, optRepeat: int, nParams: int, split: int, max_time: int, simplify: int, trace : int, generational : int, dumpTo: str, loadFrom: str, varnames: str, useFracBayes: int, dbFile: str = "", dbFitFile: str = "", dbDataset: str = "", dbCacheSize: int = 100000, dbFlushEvery: int = 0) -> str: ...
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|