Instruct the user how to install qunfold in the case of an unsuccessful import
This commit is contained in:
parent
9be729386a
commit
db8a870495
|
@ -1,45 +1,57 @@
|
||||||
"""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
|
|
||||||
from qunfold import (
|
|
||||||
LeastSquaresLoss, # losses
|
|
||||||
BlobelLoss,
|
|
||||||
EnergyLoss,
|
|
||||||
HellingerSurrogateLoss,
|
|
||||||
CombinedLoss,
|
|
||||||
TikhonovRegularization,
|
|
||||||
TikhonovRegularized,
|
|
||||||
ClassTransformer, # transformers
|
|
||||||
HistogramTransformer,
|
|
||||||
DistanceTransformer,
|
|
||||||
KernelTransformer,
|
|
||||||
EnergyKernelTransformer,
|
|
||||||
LaplacianKernelTransformer,
|
|
||||||
GaussianKernelTransformer,
|
|
||||||
GaussianRFFKernelTransformer,
|
|
||||||
)
|
|
||||||
|
|
||||||
__all__ = [ # control public members, e.g., for auto-documentation in sphinx; omit QuaPyWrapper
|
To fix this error, call:
|
||||||
"ComposableQuantifier",
|
|
||||||
"CVClassifier",
|
pip install --upgrade pip setuptools wheel
|
||||||
"LeastSquaresLoss",
|
pip install "jax[cpu]"
|
||||||
"BlobelLoss",
|
pip install "qunfold @ git+https://github.com/mirkobunse/qunfold@v0.1.4"
|
||||||
"EnergyLoss",
|
"""
|
||||||
"HellingerSurrogateLoss",
|
|
||||||
"CombinedLoss",
|
try:
|
||||||
"TikhonovRegularization",
|
import qunfold
|
||||||
"TikhonovRegularized",
|
from qunfold.quapy import QuaPyWrapper
|
||||||
"ClassTransformer",
|
from qunfold.sklearn import CVClassifier
|
||||||
"HistogramTransformer",
|
from qunfold import (
|
||||||
"DistanceTransformer",
|
LeastSquaresLoss, # losses
|
||||||
"KernelTransformer",
|
BlobelLoss,
|
||||||
"EnergyKernelTransformer",
|
EnergyLoss,
|
||||||
"LaplacianKernelTransformer",
|
HellingerSurrogateLoss,
|
||||||
"GaussianKernelTransformer",
|
CombinedLoss,
|
||||||
"GaussianRFFKernelTransformer",
|
TikhonovRegularization,
|
||||||
]
|
TikhonovRegularized,
|
||||||
|
ClassTransformer, # transformers
|
||||||
|
HistogramTransformer,
|
||||||
|
DistanceTransformer,
|
||||||
|
KernelTransformer,
|
||||||
|
EnergyKernelTransformer,
|
||||||
|
LaplacianKernelTransformer,
|
||||||
|
GaussianKernelTransformer,
|
||||||
|
GaussianRFFKernelTransformer,
|
||||||
|
)
|
||||||
|
|
||||||
|
__all__ = [ # control public members, e.g., for auto-documentation in sphinx; omit QuaPyWrapper
|
||||||
|
"ComposableQuantifier",
|
||||||
|
"CVClassifier",
|
||||||
|
"LeastSquaresLoss",
|
||||||
|
"BlobelLoss",
|
||||||
|
"EnergyLoss",
|
||||||
|
"HellingerSurrogateLoss",
|
||||||
|
"CombinedLoss",
|
||||||
|
"TikhonovRegularization",
|
||||||
|
"TikhonovRegularized",
|
||||||
|
"ClassTransformer",
|
||||||
|
"HistogramTransformer",
|
||||||
|
"DistanceTransformer",
|
||||||
|
"KernelTransformer",
|
||||||
|
"EnergyKernelTransformer",
|
||||||
|
"LaplacianKernelTransformer",
|
||||||
|
"GaussianKernelTransformer",
|
||||||
|
"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.
|
||||||
|
|
Loading…
Reference in New Issue