pyeggp 1.0.0__tar.gz → 1.0.2__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: pyeggp
3
- Version: 1.0.0
3
+ Version: 1.0.2
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 = "pyeggp"
15
- version = "1.0.0"
15
+ version = "1.0.2"
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"
@@ -96,14 +96,54 @@ class PyEGGP(BaseEstimator, RegressorMixin):
96
96
  self.is_fitted_ = True
97
97
  return self
98
98
 
99
+ def fit_mvsr(self, Xs, ys):
100
+ if Xs[0].ndim == 1:
101
+ Xs = [X.reshape(-1,1) for X in Xs]
102
+ ys = [y.reshape(-1, 1) for y in ys]
103
+ combineds = [np.hstack([X, y]) for X, y in zip(Xs, ys)]
104
+ header = [f"x{i}" for i in range(Xs[0].shape[1])] + ["y"]
105
+ datasets = []
106
+ for combined in combineds:
107
+ with tempfile.NamedTemporaryFile(mode='w+', newline='', delete=False, suffix='.csv') as temp_file:
108
+ writer = csv.writer(temp_file)
109
+ writer.writerow(header)
110
+ writer.writerows(combined)
111
+ datasets.append(temp_file.name)
112
+
113
+ csv_data = pyeggp_run(" ".join(datasets), self.gen, self.nPop, self.maxSize, self.nTournament, self.pc, self.pm, self.nonterminals, self.loss, self.optIter, self.optRepeat, self.nParams, self.split, self.simplify, self.dumpTo, self.loadFrom)
114
+ if len(csv_data) > 0:
115
+ csv_io = StringIO(csv_data.strip())
116
+ self.results = pd.read_csv(csv_io, header=0, dtype={'theta':str})
117
+ self.is_fitted_ = True
118
+ return self
119
+
99
120
  def predict(self, X):
100
121
  check_is_fitted(self)
101
- return self.evaluate_best_model(self.model_, X)
122
+ return self.evaluate_best_model(X)
123
+
124
+ def predict_mvsr(self, X, view):
125
+ check_is_fitted(self)
126
+ return self.evaluate_best_model_view(X, view)
127
+
102
128
  def evaluate_best_model(self, x):
103
129
  if x.ndim == 1:
104
130
  x = x.reshape(-1,1)
105
131
  t = np.array(list(map(float, self.results.iloc[-1].theta.split(";"))))
106
132
  return eval(self.results.iloc[-1].Numpy)
133
+ def evaluate_best_model_view(self, x, view):
134
+ if x.ndim == 1:
135
+ x = x.reshape(-1,1)
136
+ ix = self.results.iloc[-1].id
137
+ best = self.results[self.results.id==ix].iloc[view]
138
+ t = np.array(list(map(float, best.theta.split(";"))))
139
+ return eval(best.Numpy)
140
+
141
+ def evaluate_model_view(self, x, ix, view):
142
+ if x.ndim == 1:
143
+ x = x.reshape(-1,1)
144
+ best = self.results[self.results.id==ix].iloc[view]
145
+ t = np.array(list(map(float, best.theta.split(";"))))
146
+ return eval(best.Numpy)
107
147
  def evaluate_model(self, ix, x):
108
148
  if x.ndim == 1:
109
149
  x = x.reshape(-1,1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyeggp
3
- Version: 1.0.0
3
+ Version: 1.0.2
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
@@ -5,6 +5,10 @@ output = pyeggp_run("test/data.csv", 100, 100, 10, 3, 0.9, 0.3, "add,sub,mul,div
5
5
 
6
6
  print(output)
7
7
 
8
+ output = pyeggp_run("test/data.csv test/data2.csv", 100, 100, 10, 3, 0.9, 0.3, "add,sub,mul,div,log", "MSE", 50, 2, -1, 3, 0, "", "")
9
+
10
+ print(output)
11
+
8
12
  print("Check PyEGGP")
9
13
  df = pd.read_csv("test/data.csv")
10
14
  Z = df.values
@@ -14,3 +18,8 @@ y = Z[:,-1]
14
18
  reg = PyEGGP(100, 100, 10, 3, 0.9, 0.3, "add,sub,mul,div,log", "MSE", 50, 2, -1, 3, 0, "", "")
15
19
  reg.fit(X, y)
16
20
  print(reg.score(X, y))
21
+
22
+ reg.fit_mvsr([X,X],[y,y])
23
+ print(reg.predict_mvsr(X,0))
24
+ print(reg.predict_mvsr(X,1))
25
+ print(reg.results)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes