mlquantify 0.1.14__tar.gz → 0.1.16__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.
Files changed (61) hide show
  1. {mlquantify-0.1.14/mlquantify.egg-info → mlquantify-0.1.16}/PKG-INFO +1 -1
  2. mlquantify-0.1.16/VERSION.txt +1 -0
  3. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/adjust_counting/_adjustment.py +22 -15
  4. {mlquantify-0.1.14 → mlquantify-0.1.16/mlquantify.egg-info}/PKG-INFO +1 -1
  5. mlquantify-0.1.14/VERSION.txt +0 -1
  6. {mlquantify-0.1.14 → mlquantify-0.1.16}/MANIFEST.in +0 -0
  7. {mlquantify-0.1.14 → mlquantify-0.1.16}/README.md +0 -0
  8. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/__init__.py +0 -0
  9. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/adjust_counting/__init__.py +0 -0
  10. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/adjust_counting/_base.py +0 -0
  11. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/adjust_counting/_counting.py +0 -0
  12. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/adjust_counting/_utils.py +0 -0
  13. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/base.py +0 -0
  14. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/base_aggregative.py +0 -0
  15. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/calibration.py +0 -0
  16. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/confidence.py +0 -0
  17. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/likelihood/__init__.py +0 -0
  18. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/likelihood/_base.py +0 -0
  19. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/likelihood/_classes.py +0 -0
  20. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/meta/__init__.py +0 -0
  21. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/meta/_classes.py +0 -0
  22. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/metrics/__init__.py +0 -0
  23. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/metrics/_oq.py +0 -0
  24. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/metrics/_rq.py +0 -0
  25. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/metrics/_slq.py +0 -0
  26. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/mixture/__init__.py +0 -0
  27. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/mixture/_base.py +0 -0
  28. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/mixture/_classes.py +0 -0
  29. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/mixture/_utils.py +0 -0
  30. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/model_selection/__init__.py +0 -0
  31. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/model_selection/_protocol.py +0 -0
  32. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/model_selection/_search.py +0 -0
  33. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/model_selection/_split.py +0 -0
  34. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/multiclass.py +0 -0
  35. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/neighbors/__init__.py +0 -0
  36. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/neighbors/_base.py +0 -0
  37. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/neighbors/_classes.py +0 -0
  38. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/neighbors/_classification.py +0 -0
  39. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/neighbors/_kde.py +0 -0
  40. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/neighbors/_utils.py +0 -0
  41. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/neural/__init__.py +0 -0
  42. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/__init__.py +0 -0
  43. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_artificial.py +0 -0
  44. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_constraints.py +0 -0
  45. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_context.py +0 -0
  46. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_decorators.py +0 -0
  47. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_exceptions.py +0 -0
  48. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_get_scores.py +0 -0
  49. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_load.py +0 -0
  50. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_parallel.py +0 -0
  51. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_random.py +0 -0
  52. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_sampling.py +0 -0
  53. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_tags.py +0 -0
  54. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/_validation.py +0 -0
  55. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify/utils/prevalence.py +0 -0
  56. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify.egg-info/SOURCES.txt +0 -0
  57. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify.egg-info/dependency_links.txt +0 -0
  58. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify.egg-info/requires.txt +0 -0
  59. {mlquantify-0.1.14 → mlquantify-0.1.16}/mlquantify.egg-info/top_level.txt +0 -0
  60. {mlquantify-0.1.14 → mlquantify-0.1.16}/setup.cfg +0 -0
  61. {mlquantify-0.1.14 → mlquantify-0.1.16}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlquantify
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: Quantification Library
5
5
  Home-page: https://github.com/luizfernandolj/QuantifyML/tree/master
6
6
  Maintainer: Luiz Fernando Luth Junior
@@ -0,0 +1 @@
1
+ 0.1.16
@@ -2,6 +2,7 @@ import numpy as np
2
2
  from abc import abstractmethod
3
3
  from scipy.optimize import minimize
4
4
  import warnings
5
+ from sklearn.metrics import confusion_matrix
5
6
 
6
7
  from mlquantify.adjust_counting._base import BaseAdjustCount
7
8
  from mlquantify.adjust_counting._counting import CC, PCC
@@ -203,13 +204,13 @@ class MatrixAdjustment(BaseAdjustCount):
203
204
  self.CM = np.zeros((n_class, n_class))
204
205
 
205
206
  if self.solver == 'optim':
206
- priors = np.array(list(CC().aggregate(train_y_pred).values()))
207
+ priors = np.array(list(CC().aggregate(train_y_pred, train_y_values).values()))
207
208
  self.CM = self._compute_confusion_matrix(train_y_pred, train_y_values, priors)
208
- prevs_estim = self._get_estimations(predictions > priors)
209
+ prevs_estim = self._get_estimations(predictions > priors, train_y_values)
209
210
  prevalence = self._solve_optimization(prevs_estim, priors)
210
211
  else:
211
- self.CM = self._compute_confusion_matrix(train_y_pred)
212
- prevs_estim = self._get_estimations(predictions)
212
+ self.CM = self._compute_confusion_matrix(train_y_pred, train_y_values)
213
+ prevs_estim = self._get_estimations(predictions, train_y_values)
213
214
  prevalence = self._solve_linear(prevs_estim)
214
215
 
215
216
  return prevalence
@@ -260,11 +261,11 @@ class MatrixAdjustment(BaseAdjustCount):
260
261
  result = minimize(objective, init, constraints=constraints, bounds=bounds)
261
262
  return result.x if result.success else priors
262
263
 
263
- def _get_estimations(self, predictions):
264
+ def _get_estimations(self, predictions, train_y_values):
264
265
  """Return prevalence estimates using CC (crisp) or PCC (probabilistic)."""
265
266
  if uses_soft_predictions(self):
266
267
  return np.array(list(PCC().aggregate(predictions).values()))
267
- return np.array(list(CC().aggregate(predictions).values()))
268
+ return np.array(list(CC().aggregate(predictions, train_y_values).values()))
268
269
 
269
270
  @abstractmethod
270
271
  def _compute_confusion_matrix(self, predictions, *args):
@@ -389,8 +390,11 @@ class GAC(CrispLearnerQMixin, MatrixAdjustment):
389
390
  def __init__(self, learner=None):
390
391
  super().__init__(learner=learner, solver='linear')
391
392
 
392
- def _compute_confusion_matrix(self, predictions):
393
- prev_estim = self._get_estimations(predictions)
393
+ def _compute_confusion_matrix(self, predictions, y_values):
394
+ self.CM = confusion_matrix(y_values, predictions, labels=self.classes_).T
395
+ self.CM = self.CM.astype(float)
396
+ prev_estim = self.CM.sum(axis=0)
397
+
394
398
  for i, _ in enumerate(self.classes_):
395
399
  if prev_estim[i] == 0:
396
400
  self.CM[i, i] = 1
@@ -448,13 +452,16 @@ class GPAC(SoftLearnerQMixin, MatrixAdjustment):
448
452
  def __init__(self, learner=None):
449
453
  super().__init__(learner=learner, solver='linear')
450
454
 
451
- def _compute_confusion_matrix(self, posteriors):
452
- prev_estim = self._get_estimations(posteriors)
453
- for i, _ in enumerate(self.classes_):
454
- if prev_estim[i] == 0:
455
- self.CM[i, i] = 1
456
- else:
457
- self.CM[:, i] /= prev_estim[i]
455
+ def _compute_confusion_matrix(self, posteriors, y_values):
456
+ n_classes = len(self.classes_)
457
+ confusion = np.eye(n_classes)
458
+
459
+ for i, class_label in enumerate(self.classes_):
460
+ indices = (y_values == class_label)
461
+ if np.any(indices):
462
+ confusion[i] = posteriors[indices].mean(axis=0)
463
+
464
+ self.CM = confusion.T
458
465
  return self.CM
459
466
 
460
467
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlquantify
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: Quantification Library
5
5
  Home-page: https://github.com/luizfernandolj/QuantifyML/tree/master
6
6
  Maintainer: Luiz Fernando Luth Junior
@@ -1 +0,0 @@
1
- 0.1.14
File without changes
File without changes
File without changes
File without changes