changing the way the file is loaded

This commit is contained in:
pglez82 2025-11-15 16:51:48 +01:00
parent 3268e9fada
commit e4c07e1835
3 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,7 @@
Utility functions for `Bayesian quantification <https://arxiv.org/abs/2302.09159>`_ methods.
"""
import numpy as np
import importlib.resources
try:
import jax
@ -82,6 +83,9 @@ def sample_posterior(
def load_stan_file():
return importlib.resources.files('quapy.method').joinpath('stan/pq.stan').read_text(encoding='utf-8')
def pq_stan(stan_code, n_bins, pos_hist, neg_hist, test_hist, number_of_samples, num_warmup, stan_seed):
"""
Perform Bayesian prevalence estimation using a Stan model for probabilistic quantification.

View File

@ -624,8 +624,7 @@ class PQ(AggregativeSoftQuantifier, BinaryAggregativeQuantifier):
self.num_samples = num_samples
self.region = region
self.stan_seed = stan_seed
with open('quapy/method/stan/pq.stan', 'r') as f:
self.stan_code = str(f.read())
self.stan_code = _bayesian.load_stan_file()
def aggregation_fit(self, classif_predictions, labels):
y_pred = classif_predictions[:, self.pos_label]

View File

@ -124,7 +124,7 @@ setup(
# Similar to `install_requires` above, these must be valid existing
# projects.
extras_require={ # Optional
'bayes': ['jax', 'jaxlib', 'numpyro'],
'bayes': ['jax', 'jaxlib', 'numpyro', 'pystan'],
'neural': ['torch'],
'tests': ['certifi'],
'docs' : ['sphinx-rtd-theme', 'myst-parser'],