1
0
Fork 0
QuaPy/README.md

118 lines
4.8 KiB
Markdown
Raw Normal View History

2020-11-16 16:46:30 +01:00
# QuaPy
2021-11-23 18:49:48 +01:00
QuaPy is an open source framework for quantification (a.k.a. supervised prevalence estimation, or learning to quantify)
written in Python.
2021-11-23 18:49:48 +01:00
QuaPy is based on the concept of "data sample", and provides implementations of the
most important aspects of the quantification workflow, such as (baseline and advanced)
quantification methods,
quantification-oriented model selection mechanisms, evaluation measures, and evaluations protocols
used for evaluating quantification methods.
2021-11-23 18:49:48 +01:00
QuaPy also makes available commonly used datasets, and offers visualization tools
for facilitating the analysis and interpretation of the experimental results.
2021-12-15 16:39:57 +01:00
### Last updates:
2023-02-14 18:15:30 +01:00
* Version 0.1.7 is released! major changes can be consulted [here](quapy/CHANGE_LOG.txt).
* A detailed documentation is now available [here](https://hlt-isti.github.io/QuaPy/)
* The developer API documentation is available [here](https://hlt-isti.github.io/QuaPy/build/html/modules.html)
2021-12-15 16:39:57 +01:00
2021-05-10 13:40:40 +02:00
### Installation
```commandline
pip install quapy
```
2022-08-29 12:03:03 +02:00
### Cite QuaPy
If you find QuaPy useful (and we hope you will), plese consider citing the original paper in your research:
```
@inproceedings{moreo2021quapy,
title={QuaPy: a python-based framework for quantification},
author={Moreo, Alejandro and Esuli, Andrea and Sebastiani, Fabrizio},
booktitle={Proceedings of the 30th ACM International Conference on Information \& Knowledge Management},
pages={4534--4543},
year={2021}
}
```
2021-02-02 12:10:57 +01:00
## A quick example:
2021-11-23 18:49:48 +01:00
The following script fetches a dataset of tweets, trains, applies, and evaluates a quantifier based on the
_Adjusted Classify & Count_ quantification method, using, as the evaluation measure, the _Mean Absolute Error_ (MAE)
between the predicted and the true class prevalence values
2021-02-02 12:10:57 +01:00
of the test set.
```python
import quapy as qp
from sklearn.linear_model import LogisticRegression
dataset = qp.datasets.fetch_twitter('semeval16')
# create an "Adjusted Classify & Count" quantifier
model = qp.method.aggregative.ACC(LogisticRegression())
model.fit(dataset.training)
2021-08-10 11:44:44 +02:00
estim_prevalence = model.quantify(dataset.test.instances)
true_prevalence = dataset.test.prevalence()
2021-02-02 12:10:57 +01:00
2021-08-10 11:44:44 +02:00
error = qp.error.mae(true_prevalence, estim_prevalence)
2021-02-02 12:10:57 +01:00
print(f'Mean Absolute Error (MAE)={error:.3f}')
```
2021-11-23 18:49:48 +01:00
Quantification is useful in scenarios characterized by prior probability shift. In other
words, we would be little interested in estimating the class prevalence values of the test set if
we could assume the IID assumption to hold, as this prevalence would be roughly equivalent to the
class prevalence of the training set. For this reason, any quantification model
should be tested across many samples, even ones characterized by class prevalence
values different or very different from those found in the training set.
QuaPy implements sampling procedures and evaluation protocols that automate this workflow.
2021-02-08 19:16:43 +01:00
See the [Wiki](https://github.com/HLT-ISTI/QuaPy/wiki) for detailed examples.
2021-02-02 12:10:57 +01:00
## Features
2021-11-23 18:49:48 +01:00
* Implementation of many popular quantification methods (Classify-&-Count and its variants, Expectation Maximization,
2023-02-14 17:00:50 +01:00
quantification methods based on structured output learning, HDy, QuaNet, quantification ensembles, among others).
* Versatile functionality for performing evaluation based on sampling generation protocols (e.g., APP, NPP, etc.).
2021-11-23 18:49:48 +01:00
* Implementation of most commonly used evaluation metrics (e.g., AE, RAE, SE, KLD, NKLD, etc.).
* Datasets frequently used in quantification (textual and numeric), including:
2021-02-02 12:10:57 +01:00
* 32 UCI Machine Learning datasets.
2021-11-23 18:49:48 +01:00
* 11 Twitter quantification-by-sentiment datasets.
* 3 product reviews quantification-by-sentiment datasets.
2023-02-14 17:00:50 +01:00
* 4 tasks from LeQua competition (_new in v0.1.7!_)
2021-11-23 18:49:48 +01:00
* Native support for binary and single-label multiclass quantification scenarios.
* Model selection functionality that minimizes quantification-oriented loss functions.
* Visualization tools for analysing the experimental results.
2021-02-02 12:10:57 +01:00
## Requirements
2021-02-08 19:16:43 +01:00
* scikit-learn, numpy, scipy
2021-02-02 12:10:57 +01:00
* pytorch (for QuaNet)
* svmperf patched for quantification (see below)
* joblib
* tqdm
* pandas, xlrd
* matplotlib
2021-02-08 19:16:43 +01:00
## Documentation
The [developer API documentation](https://hlt-isti.github.io/QuaPy/build/html/modules.html) is available [here](https://hlt-isti.github.io/QuaPy/build/html/index.html).
2021-11-23 18:49:48 +01:00
Check out our [Wiki](https://github.com/HLT-ISTI/QuaPy/wiki), in which many examples
2021-02-24 16:47:12 +01:00
are provided:
* [Datasets](https://github.com/HLT-ISTI/QuaPy/wiki/Datasets)
* [Evaluation](https://github.com/HLT-ISTI/QuaPy/wiki/Evaluation)
2023-02-14 17:00:50 +01:00
* [Protocols](https://github.com/HLT-ISTI/QuaPy/wiki/Protocols)
2021-02-24 16:47:12 +01:00
* [Methods](https://github.com/HLT-ISTI/QuaPy/wiki/Methods)
2023-02-14 17:00:50 +01:00
* [SVMperf](https://github.com/HLT-ISTI/QuaPy/wiki/ExplicitLossMinimization)
2021-02-24 16:47:12 +01:00
* [Model Selection](https://github.com/HLT-ISTI/QuaPy/wiki/Model-Selection)
2021-08-10 11:44:44 +02:00
* [Plotting](https://github.com/HLT-ISTI/QuaPy/wiki/Plotting)
2023-06-25 13:28:48 +02:00
## Acknowledgments:
2023-06-25 13:31:50 +02:00
<img src="SoBigData.png" alt="SoBigData++" width="250"/>