Skip to content

Commit 2085990

Browse files
committed
Reflect the adaptation of the qunfold wrapper also in the documentation
1 parent 1612b51 commit 2085990

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

docs/source/manuals/methods.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,17 +447,24 @@ The [](quapy.method.composable) module allows the composition of quantification
447447
```sh
448448
pip install --upgrade pip setuptools wheel
449449
pip install "jax[cpu]"
450-
pip install "qunfold @ git+https://github.com/mirkobunse/qunfold@v0.1.4"
450+
pip install "qunfold @ git+https://github.com/mirkobunse/qunfold@v0.1.5"
451451
```
452452

453453
### Basics
454454

455455
The composition of a method is implemented through the [](quapy.method.composable.ComposableQuantifier) class. Its documentation also features an example to get you started in composing your own methods.
456456

457457
```python
458+
from quapy.method.composable import (
459+
ComposableQuantifier,
460+
TikhonovRegularized,
461+
LeastSquaresLoss,
462+
ClassRepresentation,
463+
)
464+
458465
ComposableQuantifier( # ordinal ACC, as proposed by Bunse et al., 2022
459-
TikhonovRegularized(LeastSquaresLoss(), 0.01),
460-
ClassTransformer(RandomForestClassifier(oob_score=True))
466+
TikhonovRegularized(LeastSquaresLoss(), 0.01),
467+
ClassRepresentation(RandomForestClassifier(oob_score=True))
461468
)
462469
```
463470

@@ -484,16 +491,16 @@ You can use the [](quapy.method.composable.CombinedLoss) to create arbitrary, we
484491

485492
### Feature transformations
486493

487-
- [](quapy.method.composable.ClassTransformer)
488-
- [](quapy.method.composable.DistanceTransformer)
489-
- [](quapy.method.composable.HistogramTransformer)
490-
- [](quapy.method.composable.EnergyKernelTransformer)
491-
- [](quapy.method.composable.GaussianKernelTransformer)
492-
- [](quapy.method.composable.LaplacianKernelTransformer)
493-
- [](quapy.method.composable.GaussianRFFKernelTransformer)
494+
- [](quapy.method.composable.ClassRepresentation)
495+
- [](quapy.method.composable.DistanceRepresentation)
496+
- [](quapy.method.composable.HistogramRepresentation)
497+
- [](quapy.method.composable.EnergyKernelRepresentation)
498+
- [](quapy.method.composable.GaussianKernelRepresentation)
499+
- [](quapy.method.composable.LaplacianKernelRepresentation)
500+
- [](quapy.method.composable.GaussianRFFKernelRepresentation)
494501

495502
```{hint}
496-
The [](quapy.method.composable.ClassTransformer) requires the classifier to have a property `oob_score==True` and to produce a property `oob_decision_function` during fitting. In [scikit-learn](https://scikit-learn.org/), this requirement is fulfilled by any bagging classifier, such as random forests. Any other classifier needs to be cross-validated through the [](quapy.method.composable.CVClassifier).
503+
The [](quapy.method.composable.ClassRepresentation) requires the classifier to have a property `oob_score==True` and to produce a property `oob_decision_function` during fitting. In [scikit-learn](https://scikit-learn.org/), this requirement is fulfilled by any bagging classifier, such as random forests. Any other classifier needs to be cross-validated through the [](quapy.method.composable.CVClassifier).
497504
```
498505

499506

examples/14.composable_methods.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""
22
This example illustrates the composition of quantification methods from
3-
arbitrary loss functions and feature transformations. It will extend the basic
3+
arbitrary loss functions and feature representations. It will extend the basic
44
example on the usage of quapy with this composition.
55
66
This example requires the installation of qunfold, the back-end of QuaPy's
77
composition module:
88
99
pip install --upgrade pip setuptools wheel
1010
pip install "jax[cpu]"
11-
pip install "qunfold @ git+https://github.com/mirkobunse/qunfold@v0.1.4"
11+
pip install "qunfold @ git+https://github.com/mirkobunse/qunfold@v0.1.5"
1212
"""
1313

1414
import numpy as np
@@ -24,20 +24,20 @@
2424
training, testing = data.train_test
2525

2626
# We start by recovering PACC from its building blocks, a LeastSquaresLoss and
27-
# a probabilistic ClassTransformer. A 5-fold cross-validation is implemented
27+
# a probabilistic ClassRepresentation. A 5-fold cross-validation is implemented
2828
# through a CVClassifier.
2929

3030
from quapy.method.composable import (
3131
ComposableQuantifier,
3232
LeastSquaresLoss,
33-
ClassTransformer,
33+
ClassRepresentation,
3434
CVClassifier,
3535
)
3636
from sklearn.linear_model import LogisticRegression
3737

3838
pacc = ComposableQuantifier(
3939
LeastSquaresLoss(),
40-
ClassTransformer(
40+
ClassRepresentation(
4141
CVClassifier(LogisticRegression(random_state=0), 5),
4242
is_probabilistic = True
4343
),
@@ -63,7 +63,7 @@
6363

6464
model = ComposableQuantifier(
6565
HellingerSurrogateLoss(), # the loss is different from before
66-
ClassTransformer( # we use the same transformer
66+
ClassRepresentation( # we use the same representation
6767
CVClassifier(LogisticRegression(random_state=0), 5),
6868
is_probabilistic = True
6969
),
@@ -79,7 +79,7 @@
7979
print(f"MAE = {np.mean(absolute_errors):.4f}+-{np.std(absolute_errors):.4f}")
8080

8181
# In general, any composed method solves a linear system of equations by
82-
# minimizing the loss after transforming the data. Methods of this kind include
82+
# minimizing the loss after representing the data. Methods of this kind include
8383
# ACC, PACC, HDx, HDy, and many other well-known methods, as well as an
8484
# unlimited number of re-combinations of their building blocks.
8585

@@ -93,18 +93,18 @@
9393

9494
model = ComposableQuantifier(
9595
CombinedLoss(HellingerSurrogateLoss(), LeastSquaresLoss()),
96-
ClassTransformer(
96+
ClassRepresentation(
9797
CVClassifier(LogisticRegression(random_state=0), 5),
9898
is_probabilistic = True
9999
),
100100
)
101101

102-
from qunfold.quapy import QuaPyWrapper
103-
from qunfold import GenericMethod
102+
from quapy.method.composable import QUnfoldWrapper
103+
from qunfold import LinearMethod
104104

105-
model = QuaPyWrapper(GenericMethod(
105+
model = QUnfoldWrapper(LinearMethod(
106106
CombinedLoss(HellingerSurrogateLoss(), LeastSquaresLoss()),
107-
ClassTransformer(
107+
ClassRepresentation(
108108
CVClassifier(LogisticRegression(random_state=0), 5),
109109
is_probabilistic = True
110110
),
@@ -115,7 +115,7 @@
115115

116116
param_grid = {
117117
"loss__weights": [ (w, 1-w) for w in [.1, .5, .9] ],
118-
"transformer__classifier__estimator__C": [1e-1, 1e1],
118+
"representation__classifier__estimator__C": [1e-1, 1e1],
119119
}
120120

121121
grid_search = qp.model_selection.GridSearchQ(

0 commit comments

Comments
 (0)