Commit Graph

29 Commits

Author SHA1 Message Date
Alejandro Moreo Fernandez 89548d3a8b Add GMNet, a Gaussian-mixture neural quantifier
Ports GMNet (from https://github.com/pglez84/gmnet) into quapy/method/_gmnet.py,
mirroring how HistNetQ was ported: dropping that repo's quantificationlib-backed
bag generators in favor of QuaPy's own sampling protocols, and adding geotorch
(now a 'neural' extra dependency) to keep the Gaussian layers' covariance matrices
positive-definite during training.

- GMNet represents each bag instance by its likelihood under one or more learned
  mixtures of Gaussians ("GM branches"), mean-pools these representations over the
  bag, and predicts prevalence from the result. Supports multiple stacked GM
  branches with an optional CKA-regularization term encouraging their latent
  representations to be dissimilar.
- Fixes two aspects of the original architecture that assumed a fixed, training-time
  bag_size baked into the network (a reshape step, and forward-hook-based activation
  capture for CKA): both are now computed from the actual input shape/plain
  attributes at forward time, so the model also works on predict()'s arbitrary-sized
  test samples, not just same-size bags.
- Factors the bag-based training loop shared by HistNetQ and GMNet (bag generation,
  fit/fit_from_samples, early stopping, LR scheduling, checkpointing, predict) out of
  _histnet.py into a new BagTrainedQuantifier base class in
  quapy/method/_neural_bags.py; HistNetQ's public API and behavior are unchanged.
- Aliased in meta.py (torch/geotorch-optional, mirroring HistNetQ/QuaNet) and
  registered in META_METHODS.
- Adds test_gmnet covering single-branch and multi-branch+CKA (via
  fit_from_samples/mix_bags) variants.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-08 14:47:03 +02:00
Alejandro Moreo Fernandez d046681986 added bbse hard and soft and classifier adaptation wrapper 2026-08-26 18:08:37 +02:00
Alejandro Moreo Fernandez 24719ed0af Add HistNetQ, a differentiable-histogram neural quantifier
Ports the "hard" histogram variant of HistNetQ (from
https://github.com/pglez84/histnetq) into quapy/method/_histnet.py, dropping
that repo's quantificationlib-backed bag generators in favor of QuaPy's own
sampling protocols (UPP by default). Implemented as a BaseQuantifier,
alongside QuaNet, since it trains end-to-end on samples of known prevalence
rather than following the classify-then-aggregate pattern.

- HistNetQ.fit(X, y): resamples training/validation bags from a
  LabelledCollection via a configurable protocol (UPP by default; fresh
  random bags each training epoch, a fixed reproducible sequence for
  validation).
- HistNetQ.fit_from_samples(protocol, val_protocol=None, mix_bags=False):
  trains directly from a protocol that already yields bags (e.g. LeQua's
  SamplesFromDir), with an optional mixer to synthesize extra
  intermediate-prevalence bags from the given ones.
- Aliased in meta.py (torch-optional, mirroring the existing QuaNet guard)
  and registered in META_METHODS.
- Adds test_histnetq covering both entry points on binary and multiclass
  synthetic data.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-19 18:44:57 +02:00
Alejandro Moreo 8b0327f00a added EDx and improve doc 2026-07-07 15:46:45 +02:00
Alejandro Moreo 4bfa212459 adding EDy and improved manuals 2026-07-06 17:30:42 +02:00
Alejandro Moreo a1dff57db0 refactoring and cleaning up 2026-06-30 18:02:23 +02:00
Alejandro Moreo e44056d860 integrating bayesian methods and related functionality, plus unit test refactor 2026-06-05 14:08:06 +02:00
pglez82 3268e9fada PQ (precise quantifier) 2025-11-14 18:35:40 +01:00
Alejandro Moreo Fernandez 3847db3838 mergin and solving pytests 2025-10-06 12:03:31 +02:00
Alejandro Moreo Fernandez 24ab704661 all examples but 15 (qunfold) properly working 2025-10-01 17:41:36 +02:00
Alejandro Moreo Fernandez 8c01e0927f repair unittest 2024-11-29 18:21:29 +01:00
Alejandro Moreo Fernandez 2728dfbaa6 bayesian cc now inherits from the new abstract class WithConfidenceABC, just like AggregativeBootstrap 2024-11-29 18:15:09 +01:00
Alejandro Moreo Fernandez 561b672200 updated unit tests 2024-04-16 15:12:22 +02:00
Alejandro Moreo Fernandez 9207114cfa improving unit tests 2024-04-15 18:00:38 +02:00
Alejandro Moreo Fernandez 3921b8368e merging BayesianCC implemented by Pawel Czyz 2024-03-15 16:24:45 +01:00
Alejandro Moreo Fernandez 7ac834bd2c refactoring aggregation methods 2024-01-25 14:33:41 +01:00
Alejandro Moreo Fernandez daca2bd1cb added MedianEstimator quantifier 2023-11-09 14:20:41 +01:00
Alejandro Moreo Fernandez 505d2de823 elm examples 2023-02-13 12:01:52 +01:00
Pablo González c91961cff5 adding to __init__.py 2022-07-11 14:10:04 +02:00
Pablo González 46e294002f dys implementation 2022-07-11 12:21:49 +02:00
Alejandro Moreo Fernandez 4f07680381 adding Forman's methods 2021-06-16 12:03:37 +02:00
Andrea Esuli 70a3d4bd0f Tests for non aggregative and meta methods. 2021-05-04 12:14:14 +02:00
Alejandro Moreo Fernandez 5e64d2588a import fixes 2021-01-15 18:32:32 +01:00
Alejandro Moreo Fernandez d1b449d2e9 plot functionality added 2021-01-07 17:58:48 +01:00
Alejandro Moreo Fernandez 326a8ab803 added Ensemble methods (methods ALL, ACC, Ptr, DS from Pérez-Gallego et al 2017 and 2019) and some UCI ML datasets used in those articles (only 5 datasets out of 32 they used) 2021-01-06 14:58:29 +01:00
Alejandro Moreo Fernandez 71949e9a03 cleaning 2020-12-15 15:20:35 +01:00
Alejandro Moreo Fernandez c8a1a70c8a refactoring aggregative methods as methods that not only implement 'classify' and 'quantify', but that also implement 'aggregate' and that, by default, have a default implementation of 'quantify' as a pipeline of 'classify' and 'aggregate'; this helps speeding up evaluations A LOT, since the documents can be pre-classified and the samples are carried out across pre-classified values (labels, or posterior probabilities), and thus only aggregate is called many times within the artificial sampling protocol 2020-12-11 19:28:17 +01:00
Alejandro Moreo Fernandez 9bc3a9f28a evaluation by artificial prevalence sampling added. New methods added. New util functions added to quapy.functional and quapy.utils 2020-12-10 19:04:33 +01:00
Alejandro Moreo Fernandez a882424eeb many aggregative methods added 2020-12-03 18:12:28 +01:00