psyke 0.7.5.dev8__py3-none-any.whl → 0.7.6__py3-none-any.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.

Potentially problematic release.


This version of psyke might be problematic. Click here for more details.

@@ -3,7 +3,7 @@ import pandas as pd
3
3
  from sklearn.linear_model import LinearRegression
4
4
 
5
5
  from psyke import get_default_random_seed, Target
6
- from psyke.extraction.hypercubic import Grid, HyperCube, GenericCube, ClassificationCube
6
+ from psyke.extraction.hypercubic import Grid, HyperCube, GenericCube, ClassificationCube, RegressionCube
7
7
  from psyke.extraction.hypercubic.gridex import GridEx
8
8
 
9
9
 
@@ -29,19 +29,16 @@ class HEx(GridEx):
29
29
  def _gain(self, parent_cube: GenericCube, new_cube: GenericCube) -> float:
30
30
  if isinstance(parent_cube, ClassificationCube):
31
31
  return parent_cube.output != new_cube.output
32
- return parent_cube.diversity - new_cube.diversity > self.threshold / 3.0
32
+ return parent_cube.error - new_cube.error > self.threshold
33
33
 
34
34
  def _iterate(self, surrounding: HyperCube, dataframe: pd.DataFrame):
35
35
  fake = dataframe.copy()
36
36
  surrounding.update(dataframe, self.predictor)
37
37
  prev = [surrounding]
38
- next_iteration = []
39
38
 
40
39
  for iteration in self.grid.iterate():
41
40
  next_iteration = []
42
41
  for cube in prev:
43
- # subcubes =
44
- # [c for c in self._merge(self._cubes_to_split(cube, iteration, dataframe, fake, True), fake)]
45
42
  subcubes, fake = self._cubes_to_split(cube, surrounding, iteration, dataframe, fake, True)
46
43
  cleaned = [c for c in subcubes if c.count(dataframe) > 0 and self._gain(cube, c)]
47
44
  if len(subcubes) > len(cleaned):
@@ -51,4 +48,4 @@ class HEx(GridEx):
51
48
  self._hypercubes = [cube] + self._hypercubes
52
49
  next_iteration += self._merge(cleaned, fake)
53
50
  prev = next_iteration.copy()
54
- self._hypercubes = [cube for cube in next_iteration] + self._hypercubes
51
+ self._hypercubes = [cube for cube in prev] + self._hypercubes
@@ -70,6 +70,7 @@ class HyperCube:
70
70
  self._limits = limits if limits is not None else set()
71
71
  self._output = output
72
72
  self._diversity = 0.0
73
+ self._error = 0.0
73
74
  self._barycenter = Point([], [])
74
75
 
75
76
  def __contains__(self, point: dict[str, float]) -> bool:
@@ -115,6 +116,10 @@ class HyperCube:
115
116
  def diversity(self) -> float:
116
117
  return self._diversity
117
118
 
119
+ @property
120
+ def error(self) -> float:
121
+ return self._error
122
+
118
123
  @property
119
124
  def barycenter(self) -> Point:
120
125
  return self._barycenter
@@ -369,6 +374,7 @@ class HyperCube:
369
374
  predictions = predictor.predict(filtered)
370
375
  self._output = np.mean(predictions)
371
376
  self._diversity = np.std(predictions)
377
+ self._error = (abs(predictions - self._output)).mean()
372
378
  means = filtered.describe().loc['mean']
373
379
  self._barycenter = Point(means.index.values, means.values)
374
380
 
@@ -386,7 +392,7 @@ class RegressionCube(HyperCube):
386
392
  if len(filtered > 0):
387
393
  predictions = predictor.predict(filtered)
388
394
  self._output.fit(filtered, predictions)
389
- self._diversity = (abs(self._output.predict(filtered) - predictions)).mean()
395
+ self._diversity = self._error = (abs(self._output.predict(filtered) - predictions)).mean()
390
396
  means = filtered.describe().loc['mean']
391
397
  self._barycenter = Point(means.index.values, means.values)
392
398
 
@@ -415,7 +421,7 @@ class ClassificationCube(HyperCube):
415
421
  if len(filtered > 0):
416
422
  predictions = predictor.predict(filtered)
417
423
  self._output = mode(predictions)
418
- self._diversity = 1 - sum(prediction == self.output for prediction in predictions) / len(filtered)
424
+ self._diversity = self._error = 1 - sum(p == self.output for p in predictions) / len(predictions)
419
425
  means = filtered.describe().loc['mean']
420
426
  self._barycenter = Point(means.index.values, means.values)
421
427
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: psyke
3
- Version: 0.7.5.dev8
3
+ Version: 0.7.6
4
4
  Summary: Python-based implementation of PSyKE, i.e. a Platform for Symbolic Knowledge Extraction
5
5
  Home-page: https://github.com/psykei/psyke-python
6
6
  Author: Matteo Magnini
@@ -8,7 +8,7 @@ psyke/extraction/__init__.py,sha256=Zmq83HqmmDVyw-4KsaEVm52h8T2_Hy-lYSHF75hDIL8,
8
8
  psyke/extraction/cart/__init__.py,sha256=IilEP4DxSAK9_x5ehPTvopuwlQqBMpGMiNRo-f90rqQ,4179
9
9
  psyke/extraction/cart/predictor.py,sha256=2-2mv5fI0lTwwfTaEonxKh0ZUdhxuIEE6OP_rJxgmqc,3019
10
10
  psyke/extraction/hypercubic/__init__.py,sha256=0XUHTtUCClMBdyA0cLIq9D5gHfqqFiSVt3DsHDQy94M,6786
11
- psyke/extraction/hypercubic/hypercube.py,sha256=QqQdaelyrvv79r_rNErkeTCVPHVPahUe9KCrhAs_3HI,19849
11
+ psyke/extraction/hypercubic/hypercube.py,sha256=TS-Iwd45my-mQmmg4L_1JarGHnTxvqlM1-x3FrunB-Q,20023
12
12
  psyke/extraction/hypercubic/strategy.py,sha256=X-roIsfcpJyMdo2px5JtbhP7-XE-zUNkaEK7XGXoWA8,1636
13
13
  psyke/extraction/hypercubic/utils.py,sha256=D2FN5CCm_T3h23DmLFoTnIcFo7LvIq__ktl4hjUqkcA,1525
14
14
  psyke/extraction/hypercubic/cosmik/__init__.py,sha256=OIfAZFFZVXKdvQvOut6NfUbey3TClR-W76DrlQH8LrM,1937
@@ -16,7 +16,7 @@ psyke/extraction/hypercubic/creepy/__init__.py,sha256=QcYGm3OHzUxutuuQ159oUNwr-4
16
16
  psyke/extraction/hypercubic/divine/__init__.py,sha256=qWoOeTNwNRD8VHZQLqVuv8Jfr4X2sGaQOylm8fw0m9g,3619
17
17
  psyke/extraction/hypercubic/gridex/__init__.py,sha256=QWgfIDojpb38DC7Z49KyyPCHqb2-3GIkBWa2ApjMNl4,5688
18
18
  psyke/extraction/hypercubic/gridrex/__init__.py,sha256=h9usK5tFqd6ngBmRydsgkfQ1jlcQKj2uG72Tr1puFHk,595
19
- psyke/extraction/hypercubic/hex/__init__.py,sha256=uLO8geJ1BjWPkhhjXkhDafx8rlNGSWI5Z-jEL3SN41o,2641
19
+ psyke/extraction/hypercubic/hex/__init__.py,sha256=pAog2-sRbhLJSbOHcJs-6WV9SFYTRDJawNfyTVGhw1c,2465
20
20
  psyke/extraction/hypercubic/iter/__init__.py,sha256=E_Z8KLTei71n_Hd4p7eXvR8tjRoLdVBWLh-ph7x0JSs,10141
21
21
  psyke/extraction/real/__init__.py,sha256=DN9z51QdldUh1g9rzh7H8bgvZJZ-qOKpTQvHKR8NkAI,6417
22
22
  psyke/extraction/real/utils.py,sha256=eHGU-Y0inn_8jrk9lMcuRUKXpsTkI-s_myXSWz4bALQ,2190
@@ -33,8 +33,8 @@ psyke/utils/logic.py,sha256=7bbW6qcKof5PlqoQ0n5Kt3Obcot-KqGAvpE8rMXvEPE,12419
33
33
  psyke/utils/metrics.py,sha256=Oo5BOonOSfo0qYsXWT5dmypZ7jiStByFC2MKEU0uMHg,2250
34
34
  psyke/utils/plot.py,sha256=dE8JJ6tQ0Ezosid-r2jqAisREjFe5LqExRzsVi5Ns-c,7785
35
35
  psyke/utils/sorted.py,sha256=C3CPW2JisND30BRk5c1sAAHs3Lb_wsRB2qZrYFuRnfM,678
36
- psyke-0.7.5.dev8.dist-info/LICENSE,sha256=KP9K6Hgezf_xdMFW7ORyKz9uA8Y8k52YJn292wcP-_E,11354
37
- psyke-0.7.5.dev8.dist-info/METADATA,sha256=d-cxB_aCypHW4ZoYKYDmXX9q4KydZEHSmCDEQKAC_ac,8107
38
- psyke-0.7.5.dev8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
- psyke-0.7.5.dev8.dist-info/top_level.txt,sha256=q1HglxOqqoIRukFtyis_ZNHczZg4gANRUPWkD7HAUTU,6
40
- psyke-0.7.5.dev8.dist-info/RECORD,,
36
+ psyke-0.7.6.dist-info/LICENSE,sha256=KP9K6Hgezf_xdMFW7ORyKz9uA8Y8k52YJn292wcP-_E,11354
37
+ psyke-0.7.6.dist-info/METADATA,sha256=ZYT-3xeCAaJG5rXimqM726Y06stZ-O858gf8LmRrM_U,8102
38
+ psyke-0.7.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
+ psyke-0.7.6.dist-info/top_level.txt,sha256=q1HglxOqqoIRukFtyis_ZNHczZg4gANRUPWkD7HAUTU,6
40
+ psyke-0.7.6.dist-info/RECORD,,