Instruct the user how to install qunfold in the case of an unsuccessful import

This commit is contained in:
Mirko Bunse 2024-09-17 10:48:53 +02:00
parent 9be729386a
commit db8a870495
1 changed files with 51 additions and 39 deletions

View File

@ -1,9 +1,19 @@
"""This module allows the composition of quantification methods from loss functions and feature transformations. This functionality is realized through an integration of the qunfold package: https://github.com/mirkobunse/qunfold.""" """This module allows the composition of quantification methods from loss functions and feature transformations. This functionality is realized through an integration of the qunfold package: https://github.com/mirkobunse/qunfold."""
import qunfold _import_error_message = """qunfold, the back-end of quapy.method.composable, is not properly installed.
from qunfold.quapy import QuaPyWrapper
from qunfold.sklearn import CVClassifier To fix this error, call:
from qunfold import (
pip install --upgrade pip setuptools wheel
pip install "jax[cpu]"
pip install "qunfold @ git+https://github.com/mirkobunse/qunfold@v0.1.4"
"""
try:
import qunfold
from qunfold.quapy import QuaPyWrapper
from qunfold.sklearn import CVClassifier
from qunfold import (
LeastSquaresLoss, # losses LeastSquaresLoss, # losses
BlobelLoss, BlobelLoss,
EnergyLoss, EnergyLoss,
@ -19,9 +29,9 @@ from qunfold import (
LaplacianKernelTransformer, LaplacianKernelTransformer,
GaussianKernelTransformer, GaussianKernelTransformer,
GaussianRFFKernelTransformer, GaussianRFFKernelTransformer,
) )
__all__ = [ # control public members, e.g., for auto-documentation in sphinx; omit QuaPyWrapper __all__ = [ # control public members, e.g., for auto-documentation in sphinx; omit QuaPyWrapper
"ComposableQuantifier", "ComposableQuantifier",
"CVClassifier", "CVClassifier",
"LeastSquaresLoss", "LeastSquaresLoss",
@ -39,7 +49,9 @@ __all__ = [ # control public members, e.g., for auto-documentation in sphinx; om
"LaplacianKernelTransformer", "LaplacianKernelTransformer",
"GaussianKernelTransformer", "GaussianKernelTransformer",
"GaussianRFFKernelTransformer", "GaussianRFFKernelTransformer",
] ]
except ImportError as e:
raise ImportError(_import_error_message) from e
def ComposableQuantifier(loss, transformer, **kwargs): def ComposableQuantifier(loss, transformer, **kwargs):
"""A generic quantification / unfolding method that solves a linear system of equations. """A generic quantification / unfolding method that solves a linear system of equations.