eggp 2.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eggp
3
- Version: 2.2.0
3
+ Version: 2.2.1
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
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "eggp"
15
- version = "2.2.0"
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"
@@ -50,7 +50,7 @@ def _get_hs_eggp_run_data():
50
50
  _hs_eggp_run_data = lib.hs_eggp_run_data
51
51
  return _hs_eggp_run_data
52
52
 
53
- VERSION: str = "2.2.0"
53
+ VERSION: str = "2.2.1"
54
54
 
55
55
 
56
56
  _hs_rts_init: bool = False
@@ -486,14 +486,20 @@ class EGGP(BaseEstimator, RegressorMixin):
486
486
 
487
487
  if x.ndim == 1:
488
488
  x = x.reshape(-1,1)
489
- tStr = self.results.iloc[-1].theta.split(";")
489
+ best = self._best_row()
490
+ tStr = best.theta.split(";")
490
491
  t = np.array(list(map(float, tStr))) if len(tStr[0]) > 0 else np.array([])
491
- y = eval(self.results.iloc[-1].Numpy)
492
+ y = eval(best.Numpy)
492
493
  if self.loss == "Bernoulli":
493
494
  return 1/(1 + np.exp(-y))
494
495
  elif self.loss == "Poisson":
495
496
  return np.exp(y)
496
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
+
497
503
  def evaluate_best_model_view(self, x, view):
498
504
  if view not in np.unique(self.results.view.values):
499
505
  raise ValueError("Invalid view index")
@@ -501,8 +507,8 @@ class EGGP(BaseEstimator, RegressorMixin):
501
507
  x = x.to_numpy()
502
508
  if x.ndim == 1:
503
509
  x = x.reshape(-1,1)
504
- ix = self.results.iloc[-1].id
505
- best = self.results[self.results.id==ix].iloc[view]
510
+ ix = self._best_row().id
511
+ best = self.results[(self.results.id==ix) & (self.results.view==view)].iloc[0]
506
512
  t = np.array(list(map(float, best.theta.split(";")))) if len(best.theta) > 0 else np.array([])
507
513
  y = eval(best.Numpy)
508
514
  if self.loss == "Bernoulli":
@@ -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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eggp
3
- Version: 2.2.0
3
+ Version: 2.2.1
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
@@ -6,6 +6,7 @@ src/eggp/__init__.py
6
6
  src/eggp/__main__.py
7
7
  src/eggp/_binding.pyi
8
8
  src/eggp/binding.i
9
+ src/eggp/binding.py
9
10
  src/eggp/typing.py
10
11
  src/eggp.egg-info/PKG-INFO
11
12
  src/eggp.egg-info/SOURCES.txt
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