mlquantify 0.1.11__tar.gz → 0.1.13__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.11/mlquantify.egg-info → mlquantify-0.1.13}/PKG-INFO +1 -1
  2. mlquantify-0.1.13/VERSION.txt +1 -0
  3. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/adjust_counting/_adjustment.py +6 -1
  4. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/adjust_counting/_base.py +4 -1
  5. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/meta/_classes.py +27 -17
  6. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/mixture/_classes.py +4 -2
  7. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/multiclass.py +1 -1
  8. {mlquantify-0.1.11 → mlquantify-0.1.13/mlquantify.egg-info}/PKG-INFO +1 -1
  9. mlquantify-0.1.11/VERSION.txt +0 -1
  10. {mlquantify-0.1.11 → mlquantify-0.1.13}/MANIFEST.in +0 -0
  11. {mlquantify-0.1.11 → mlquantify-0.1.13}/README.md +0 -0
  12. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/__init__.py +0 -0
  13. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/adjust_counting/__init__.py +0 -0
  14. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/adjust_counting/_counting.py +0 -0
  15. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/adjust_counting/_utils.py +0 -0
  16. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/base.py +0 -0
  17. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/base_aggregative.py +0 -0
  18. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/calibration.py +0 -0
  19. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/confidence.py +0 -0
  20. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/likelihood/__init__.py +0 -0
  21. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/likelihood/_base.py +0 -0
  22. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/likelihood/_classes.py +0 -0
  23. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/meta/__init__.py +0 -0
  24. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/metrics/__init__.py +0 -0
  25. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/metrics/_oq.py +0 -0
  26. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/metrics/_rq.py +0 -0
  27. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/metrics/_slq.py +0 -0
  28. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/mixture/__init__.py +0 -0
  29. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/mixture/_base.py +0 -0
  30. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/mixture/_utils.py +0 -0
  31. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/model_selection/__init__.py +0 -0
  32. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/model_selection/_protocol.py +0 -0
  33. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/model_selection/_search.py +0 -0
  34. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/model_selection/_split.py +0 -0
  35. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/neighbors/__init__.py +0 -0
  36. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/neighbors/_base.py +0 -0
  37. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/neighbors/_classes.py +0 -0
  38. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/neighbors/_classification.py +0 -0
  39. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/neighbors/_kde.py +0 -0
  40. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/neighbors/_utils.py +0 -0
  41. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/neural/__init__.py +0 -0
  42. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/__init__.py +0 -0
  43. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_artificial.py +0 -0
  44. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_constraints.py +0 -0
  45. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_context.py +0 -0
  46. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_decorators.py +0 -0
  47. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_exceptions.py +0 -0
  48. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_get_scores.py +0 -0
  49. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_load.py +0 -0
  50. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_parallel.py +0 -0
  51. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_random.py +0 -0
  52. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_sampling.py +0 -0
  53. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_tags.py +0 -0
  54. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/_validation.py +0 -0
  55. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify/utils/prevalence.py +0 -0
  56. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify.egg-info/SOURCES.txt +0 -0
  57. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify.egg-info/dependency_links.txt +0 -0
  58. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify.egg-info/requires.txt +0 -0
  59. {mlquantify-0.1.11 → mlquantify-0.1.13}/mlquantify.egg-info/top_level.txt +0 -0
  60. {mlquantify-0.1.11 → mlquantify-0.1.13}/setup.cfg +0 -0
  61. {mlquantify-0.1.11 → mlquantify-0.1.13}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlquantify
3
- Version: 0.1.11
3
+ Version: 0.1.13
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.13
@@ -603,7 +603,12 @@ class MS(ThresholdAdjustment):
603
603
  for thr, tpr, fpr in zip(thresholds, tprs, fprs):
604
604
  cc_predictions = CC(thr).aggregate(predictions)
605
605
  cc_predictions = cc_predictions[1]
606
- prevalence = cc_predictions if tpr - fpr == 0 else (cc_predictions - fpr) / (tpr - fpr)
606
+
607
+ if tpr - fpr == 0:
608
+ prevalence = cc_predictions
609
+ else:
610
+ prevalence = np.clip((cc_predictions - fpr) / (tpr - fpr), 0, 1)
611
+
607
612
  prevs.append(prevalence)
608
613
  prevalence = np.median(prevs)
609
614
  return np.asarray([1 - prevalence, prevalence])
@@ -239,7 +239,10 @@ class BaseAdjustCount(AggregationMixin, BaseQuantifier):
239
239
  def aggregate(self, predictions, train_predictions, y_train_values):
240
240
  """Aggregate predictions and apply matrix- or rate-based bias correction."""
241
241
  self.classes_ = check_classes_attribute(self, np.unique(y_train_values))
242
- predictions = validate_predictions(self, train_predictions)
242
+
243
+ predictions = validate_predictions(self, predictions)
244
+ train_predictions = validate_predictions(self, train_predictions)
245
+
243
246
  prevalences = self._adjust(predictions, train_predictions, y_train_values)
244
247
  prevalences = validate_prevalences(self, prevalences, self.classes_)
245
248
  return prevalences
@@ -661,7 +661,7 @@ class QuaDapt(MetaquantifierMixin, BaseQuantifier):
661
661
  def __init__(self,
662
662
  quantifier,
663
663
  measure="topsoe",
664
- merging_factors=(0.1, 1.0, 0.2)):
664
+ merging_factors=np.arange(0.1, 1.0, 0.2)):
665
665
  self.quantifier = quantifier
666
666
  self.measure = measure
667
667
  self.merging_factors = merging_factors
@@ -701,10 +701,7 @@ class QuaDapt(MetaquantifierMixin, BaseQuantifier):
701
701
 
702
702
  self.classes = self.classes if hasattr(self, 'classes') else np.unique(train_y_values)
703
703
 
704
- moss = QuaDapt.MoSS(1000, 0.5, m)
705
-
706
- moss_scores = moss[:, :2]
707
- moss_labels = moss[:, 2]
704
+ moss_scores, moss_labels = self.MoSS(1000, 0.5, m)
708
705
 
709
706
  prevalences = self.quantifier.aggregate(predictions,
710
707
  moss_scores,
@@ -721,9 +718,9 @@ class QuaDapt(MetaquantifierMixin, BaseQuantifier):
721
718
  distances = []
722
719
 
723
720
  for mf in MF:
724
- scores = QuaDapt.MoSS(1000, 0.5, mf)
725
- pos_scores = scores[scores[:, 2] == 1][:, :2]
726
- neg_scores = scores[scores[:, 2] == 0][:, :2]
721
+ scores, labels = self.MoSS(1000, 0.5, mf)
722
+ pos_scores = scores[labels == 1][:, 1]
723
+ neg_scores = scores[labels == 0][:, 1]
727
724
 
728
725
  best_distance = self._get_best_distance(predictions, pos_scores, neg_scores)
729
726
 
@@ -772,14 +769,27 @@ class QuaDapt(MetaquantifierMixin, BaseQuantifier):
772
769
  .. [1] Maletzke, A., Reis, D. dos, Hassan, W., & Batista, G. (2021).
773
770
  Accurately Quantifying under Score Variability. 2021 IEEE International Conference on Data Mining (ICDM), 1228-1233. https://doi.org/10.1109/ICDM51629.2021.00149
774
771
  """
775
- p_score = np.random.uniform(size=int(n * alpha)) ** m
776
- n_score = 1 - (np.random.uniform(size=int(round(n * (1 - alpha), 0))) ** m)
777
- scores = np.column_stack(
778
- (np.concatenate((p_score, n_score)),
779
- np.concatenate((p_score, n_score)),
780
- np.concatenate((
781
- np.ones(len(p_score)),
782
- np.full(len(n_score), 0))))
772
+ if isinstance(alpha, list):
773
+ alpha = float(alpha[1])
774
+
775
+ n_pos = int(n * alpha)
776
+ n_neg = n - n_pos
777
+
778
+ # Scores positivos
779
+ p_score = np.random.uniform(size=n_pos) ** merging_factor
780
+ # Scores negativos
781
+ n_score = 1 - (np.random.uniform(size=n_neg) ** merging_factor)
782
+
783
+ # Construção dos arrays de features (duas colunas iguais)
784
+ moss = np.column_stack(
785
+ (
786
+ 1 - np.concatenate((p_score, n_score)),
787
+ np.concatenate((p_score, n_score)),
788
+ np.int16(np.concatenate((np.ones(len(p_score)), np.full(len(n_score), 0))))
789
+ )
783
790
  )
784
- return scores
791
+
792
+ scores = moss[:, :2]
793
+ labels = moss[:, 2].astype(np.int16)
794
+ return scores, labels
785
795
 
@@ -308,8 +308,10 @@ class SMM(AggregativeMixture):
308
308
  mean_pos = np.mean(pos_scores)
309
309
  mean_neg = np.mean(neg_scores)
310
310
  mean_test = np.mean(predictions)
311
-
312
- alpha = (mean_test - mean_neg) / (mean_pos - mean_neg)
311
+ if mean_pos - mean_neg == 0:
312
+ alpha = mean_test
313
+ else:
314
+ alpha = np.clip((mean_test - mean_neg) / (mean_pos - mean_neg), 0, 1)
313
315
  return alpha, None
314
316
 
315
317
 
@@ -337,7 +337,7 @@ class BinaryQuantifier(MetaquantifierMixin, BaseQuantifier):
337
337
  classes = np.unique(args_dict["y_train"])
338
338
  qtf.strategy = getattr(qtf, "strategy", "ovr")
339
339
 
340
- if hasattr(qtf, "binary") and qtf.binary:
340
+ if (hasattr(qtf, "binary") and qtf.binary) or len(classes) <= 2:
341
341
  return qtf._original_aggregate(*args_dict.values())
342
342
 
343
343
  if qtf.strategy == "ovr":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlquantify
3
- Version: 0.1.11
3
+ Version: 0.1.13
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.11
File without changes
File without changes
File without changes
File without changes