Commit Graph

627 Commits

Author SHA1 Message Date
Alejandro Moreo Fernandez 229bf4c6aa Merge branch 'devel'
# Conflicts:
#	README.md
2026-10-05 14:49:26 +02:00
Alejandro Moreo Fernandez 5d3c2bef16 histnet and gmnet manuals update 2026-10-05 14:46:51 +02:00
Alejandro Moreo Fernandez e428250261 GMNet added 2026-10-05 14:43:20 +02:00
Alejandro Moreo Fernandez 790299b9bb liep draft removed 2026-10-05 13:52:29 +02:00
Alejandro Moreo Fernandez 3ecbadb921 adding liep 2026-09-18 11:54:50 +02:00
Alejandro Moreo Fernandez cb73c78cf3 Add manual entry for GMNet
Documents GMNet in docs/source/manuals/methods.md, mirroring the existing
HistNetQ entry: paper reference, torch/geotorch requirement, a basic usage
example, and a second example showing multi-branch + CKA regularization.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 11:40:12 +02:00
Alejandro Moreo Fernandez 2a50fe902c Fix broken imports left over from the BBSE/LEIP commit
quapy/classification/__init__.py imported a labelshift module that doesn't exist
anywhere in the repo (and nothing else references it), breaking `import quapy`
entirely; the import is removed.

quapy/method/aggregative.py imported a nonexistent `_liep` module instead of the
actual file, _liep_draft.py, which itself never got a LEIP class added (only
helper functions such as leip()). Guards the import so LEIP degrades to an
"not available" placeholder, like the other optional neural methods, instead of
crashing the whole package. test_leip/test_leip_fixed_tau still fail as a result;
finishing LEIP is left for a follow-up.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-08 14:47:13 +02:00
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 d6fbd13ecd updated todo 2026-09-08 14:18:41 +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 fdf3963d15
Update README with new image datasets
Added image datasets (MNIST, FashionMNIST, CIFAR10, CIFAR100, SVHN) to the README.
2026-08-21 11:32:27 +02:00
Alejandro Moreo Fernandez 7390c27a46
Update CHANGE_LOG.txt 2026-08-21 11:29:56 +02:00
Alejandro Moreo Fernandez c7b4bbf332 readme version fix 2026-08-20 18:22:01 +02:00
Alejandro Moreo Fernandez 3d8a1c1816 merge from devel 2026-08-20 18:12:19 +02:00
Alejandro Moreo Fernandez eeaa6776b1 updated manuals 2026-08-20 18:11:07 +02:00
Alejandro Moreo Fernandez d5610c7821 adding histnet 2026-08-20 11:40:55 +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 Fernandez c7b4712506 Merge branch 'devel' 2026-08-17 15:10:53 +02:00
Alejandro Moreo Fernandez 34ab4d854d
Update version to 0.2.1.post1 2026-08-17 15:06:30 +02:00
Alejandro Moreo Fernandez 15511c0292 downgrade missing-bayes-deps notice to debug level
Not having jax/numpyro/pystan installed is the expected, common case
for a plain `pip install quapy`; warning about it every import just
nags users who never asked for the bayes extra. Kept at debug level
so it's still available to diagnose a broken/partial bayes install.
2026-07-20 12:14:31 +02:00
Alejandro Moreo Fernandez a387ede701 remove distributing_samples.py and ensembles.py examples from master
Same experimental/stable split as experimental_non_aggregative; these
stay available on devel.
2026-07-20 11:39:01 +02:00
Alejandro Moreo Fernandez e6323bcd0b Merge remote-tracking branch 'github/master' 2026-07-20 11:33:13 +02:00
Alejandro Moreo Fernandez b3d5be0ac2 remove experimental_non_aggregative from master
This is exploratory code not ready for a stable branch; it stays
available on devel.
2026-07-20 11:32:29 +02:00
Alejandro Moreo Fernandez e0269ac625
Remove manuals link from README
Removed link to manuals from the README.
2026-07-20 11:26:29 +02:00
Alejandro Moreo Fernandez d904c2ce24 add random_state to calibration classes, fix flaky calibration test
fit_tr_val's train_test_split had no random_state, so val_split=float
picked a different split every run; occasionally the split produced a
posterior distribution that made abstention's temperature-scaling
L-BFGS optimizer diverge to NaN. Threaded random_state through the
base class and all four calibrator subclasses, and pinned the test to
a seed confirmed stable across repeated runs.
2026-07-20 11:16:43 +02:00
Alejandro Moreo Fernandez ad32c6f677 add random_state to calibration classes, fix flaky calibration test
fit_tr_val's train_test_split had no random_state, so val_split=float
picked a different split every run; occasionally the split produced a
posterior distribution that made abstention's temperature-scaling
L-BFGS optimizer diverge to NaN. Threaded random_state through the
base class and all four calibrator subclasses, and pinned the test to
a seed confirmed stable across repeated runs.
2026-07-20 11:16:25 +02:00
Alejandro Moreo Fernandez 03163f38cf add missing sphinx_design and pydata-sphinx-theme to docs extra
Same fix as master (63075e4): conf.py uses pydata_sphinx_theme and
sphinx_design, but the docs extra never listed them, so pip install
.[docs] couldn't build the docs.
2026-07-20 11:06:34 +02:00
Alejandro Moreo Fernandez 63075e4b8a add missing sphinx_design and pydata-sphinx-theme to docs extra
conf.py switched to the pydata_sphinx_theme and added the sphinx_design
extension, but the docs extra in setup.py was never updated to match,
so a fresh `pip install .[docs]` (as CI does) couldn't build the docs.
2026-07-20 11:06:15 +02:00
Alejandro Moreo Fernandez 7fe3cfcdee Merge branch 'devel'
# Conflicts:
#	CHANGE_LOG.txt
#	TODO.txt
2026-07-20 10:58:51 +02:00
Alejandro Moreo Fernandez ee803a339b silence pystan's repeated pkg_resources deprecation warning
stan.plugins.get_plugins() calls pkg_resources.iter_entry_points()
from several call sites during model building, each re-emitting
setuptools' deprecation notice since Python's default warning dedup
is keyed per call site, not per message. Not actionable upstream
noise, so filter it by message instead.
2026-07-17 17:43:41 +02:00
Alejandro Moreo Fernandez 125d4bd756 pin setuptools<82 in bayes extra
setuptools 82 removed pkg_resources entirely, which httpstan still
imports at runtime; CI's prior `pip install --upgrade setuptools`
step grabs the latest, so an unpinned setuptools didn't help.
2026-07-17 17:39:33 +02:00
Alejandro Moreo Fernandez 0965d99135 add setuptools to bayes extra
httpstan imports pkg_resources at runtime, which modern pip/venvs no
longer bootstrap by default, breaking the bayes extra in fresh CI envs.
2026-07-17 17:17:20 +02:00
Alejandro Moreo Fernandez 6e83bbef67 log the underlying ImportError when bayesian deps fail to import
Swallowing the exception made it impossible to tell which of
jax/numpyro/stan actually failed in CI.
2026-07-17 17:06:33 +02:00
Alejandro Moreo Fernandez 48a5240a6e import fix 2026-07-17 16:53:27 +02:00
Alejandro Moreo Fernandez 195552ef55 update docs 2026-07-17 16:45:12 +02:00
Alejandro Moreo 2cc2237165 EDy and EDx as separate methods with shared backbone functionals 2026-07-10 16:14:45 +02:00
Alejandro Moreo 8b0327f00a added EDx and improve doc 2026-07-07 15:46:45 +02:00
Alejandro Moreo 24a971304d improved evaluation manual 2026-07-06 17:45:08 +02:00
Alejandro Moreo 4bfa212459 adding EDy and improved manuals 2026-07-06 17:30:42 +02:00
Alejandro Moreo 574fc61032 improving doc manuals and added bonferroni parameter to interval construction 2026-07-06 12:11:24 +02:00
Alejandro Moreo Fernandez fd6373651e added methods to doc 2026-07-05 23:20:56 +02:00
Alejandro Moreo Fernandez c59ee76d9d added new changes to log 2026-07-04 19:20:21 +02:00
Alejandro Moreo Fernandez ed02be2c8d Add smoke tests for previously-untested modules, fix wasteful svmperf tmpdir creation
- Add smoke tests covering data/reader.py, method/_threshold_optim.py,
  classification/calibration.py, method/confidence.py, and the pure-numpy
  helpers in method/_bayesian.py (skipping the jax/stan-dependent model
  code itself, consistent with how the aggregative-method registry already
  treats it as optional)
- SVMperf: stop creating a tempfile.TemporaryDirectory() just to discard it
  immediately for its .name; generate the path directly instead of doing a
  pointless create/delete/recreate cycle (cleanup already happens via the
  class's own __del__)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 19:05:06 +02:00
Alejandro Moreo Fernandez b29966797a Fix 10 correctness bugs and clean up warnings/logging in core library
Correctness:
- OneVsAllAggregative.aggregation_fit: fix undefined variable and call to
  the nonexistent aggregate_fit (should be aggregation_fit)
- solve_adjustment: stop mutating the caller's fitted arrays in place for
  method='invariant-ratio'
- LabelledCollection.join(): fix classes always being None due to
  ndarray.sort() returning None; now unions each collection's own classes_
  so a class absent from a particular join is kept at zero prevalence
- Rename the duplicate newSVMKLD (nkld variant) to newSVMNKLD so both loss
  variants are reachable
- EMQ/DyS/DMy: resolve n_jobs via qp._get_njobs() like the other methods,
  so qp.environ['N_JOBS'] is respected
- AggregativeMedianEstimator: drop backend='threading' (global np.random
  state mutated via temp_seed is not thread-safe); use the safe process
  based default instead
- NeuralClassifier: default device now 'cpu', matching its own docstring
- ConfidenceEllipseSimplex: narrow bare except to np.linalg.LinAlgError
- SVMperf: stop merging stderr into stdout so failures report the actual
  subprocess error instead of crashing with AttributeError
- ConfidenceRegionABC: replace @lru_cache on bound methods (leaked every
  instance for the process lifetime) with per-instance caching

Style/quality:
- Replace print() with warnings.warn()/logging across aggregative.py,
  base.py, meta.py, model_selection.py, classification/neural.py,
  method/_neural.py, classification/svmperf.py, data/reader.py,
  data/datasets.py; also fixes a `raise RuntimeWarning(...)` in EMQ that
  would have crashed instead of warning
- Remove dead duplicate class MedianEstimator2 in meta.py
- Rename misleading _compute_tpr(TP, FP) parameter to FN, matching what
  callers actually pass
- Replace argparse.ArgumentError misuse with ValueError
- Remove commented-out dead code in protocol.py
- _lequa.py: fix CSV-parse failure raising an unrelated UnboundLocalError
  instead of a clear ValueError

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 18:49:44 +02:00
Alejandro Moreo f6c822ca8f improving docs and new example for image datasets 2026-07-03 17:07:02 +02:00
Alejandro Moreo 4916919833 added dataset for images 2026-07-02 18:21:35 +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
Alejandro Moreo Fernandez 1907c040ad added total to lequa protocols for bag iteration 2026-03-03 10:06:08 +01:00
Andrea Esuli 5374ef3cae
Merge pull request #52 from aesuli/read_csv
Fix regex for whitespace delimiter in CSV reads
2026-02-23 09:32:53 +01:00