prl
[P]reference and [R]ule [L]earning algorithm implementation for Python 3 (https://arxiv.org/abs/1812.07895)
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.0%) to scientific vocabulary
Keywords
Repository
[P]reference and [R]ule [L]earning algorithm implementation for Python 3 (https://arxiv.org/abs/1812.07895)
Basic Info
Statistics
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
PRL: Preference and Rule Learning
PRL is a preference learning algorithm which learns the maximal margin hypothesis by incrementally solving a two-player zero-sum game. The algorithm has theoretical guarantees about its convergence to the optimal solution. PRL has been presented @ AAAI 2019; the reference paper is:
M. Polato and F. Aiolli, "Interpretable preference learning: a game theoretic framework for large margin on-line feature and rule learning", AAAI 2019.
Installing PRL with Pypi (Python 3)
PRL is available in the PyPi repository and it can be installed with
sh
pip3 install prl
and then it can be imported in python with
python
import prl
How to use the PRL module
It is possible to run PRL using the provided python script run_prl.py.
Configuration file
In order to correctly run the script the configuration file must be initialized. An example of configuration file is provided in config/config.json
json
{
"algorithm" : "PRL",
"feat_gen" : "GenHPolyF",
"feat_gen_params" : [3],
"pref_generator" : "macro",
"columns_budget" : 1000,
"iterations" : 10,
"solver" : "LinProg",
"solver_params" : [0]
}
The meaning of each configuration attribute is described in the following:
* algorithm: it selects the PRL variation. Actually two PRL variations are implemented:
* PRL: which is the standard algorithm as presented in the paper mentioned above;
* PRL_ext: that is slight different from PRL, in the sense that the budget of columns is not fixed, but at each iterations columns_budget number of new columns are generated. This variation guarantees that regardless of the initial budget at some iteration the number of columns will be enough to guarantee the convergence to the optimum (as the number of iterations increases);
* KPRL: which is similar to the standard PRL but instead of generating preference-feature pairs as columns, it generates preference-kernel pairs.
feat_gen: it indicates which feature generator will be used by PRL. Feature generators are implemented in the scriptgenF.pyand at the moment the following feature generators scheme are implemented:GenLinF: generates linear features, i.e., it randomly picks a feature from the input ones;GenHPolyF: generates homogeneous polynomial features of the specified degree;GenDPKF: generates dot-product polynomials features of the specified degree. It mainly differs fromGenHPolyFon the weighting scheme of the features;GenConjF: it assumes binary/boolean input vectors and it generates conjunctive (logical AND) features of the specified arity;GenRuleF: generates conjunctions of logical rules over the input attributes. The generated rules has a form likeage >= 10 and height <= 160. The arity of the conjunction is a parameter of the generator;GenRuleEqF: likeGenRuleF, but the only relation considered is the equality (==).
feat_gen_params: ordered list of parameters for the selected feature generator. For more details, please refer to the documentation of the generators;kernel_gen: (Only for KPRL) it indicates which kernel generator will be used by KPRL. Kernel generators are implemented in the scriptgenK.pyand at the moment the following kernel generators scheme are implemented:GenKList: generates a kernel from the provided list of kernel functions, i.e., it randomly picks a kernel from the provided list;GenHPK: generates an homogeneous polynomial kernel function of one of the specified degrees;
kernel_gen_params: (Only for KPRL) ordered list of parameters for the selected kernel generator. For more details, please refer to the documentation of the generators;pref_generator: it indicated which preference generator will be used by PRL. The possible preference generation schemes are:macro: a macro preference describes preferences like yi is preferred to `yjfor the instancexi, where(xi, yi) in X x Y, while(xi, y_j) not in X x Y`. This kind of preferences are suitable for label ranking tasks;micro: a micro preference describes preferences like(x_i, y_i)is preferred to(x_j, y_j), where(x_i, y_i) in X x Y, while(x_j, y_j) not in X x Y. This kind of preferences are suitable for instance ranking tasks.
columns_budget: the number of columns of the matrix game;iterations: number of iterations of PRL;solver: the algorithm for solving the game. Up to now the available algorithms areFictitiousPlay,AMWandLinProg;solver_params: it is the ordered list of parameters of the solver. For more details, please refer to the documentation of the solvers.
Inside the config folder an example of configuration file which uses KPRL is also provided.
Run PRL
Once the configuration file is ready, PRL can be trained and evaluated by using the provided script
sh
python run_prl.py [OPTIONS] dataset
where dataset must be an svmlight file and the possible options are the following:
* -c CONFIG_FILE, --config_file CONFIG_FILE: CONFIG_FILE specifies the path of the configuration file (default: config/config.json);
* -t SIZE, --test_size SIZE: SIZE specifies the portion (in percentage, float between 0 and 1) of the dataset will be used as test set (default: 0.3);
* -n NORM, --normalize NORM: NORM specifies the type of data normalization - {0:None, 1:Min-Max scaling, 2:L2 normalization} (default: 1)
* -s SEED, --seed SEED: SEED specifies the pseudo-random seed. Useful for replicability purposes (default: 42);
* -v, --verbose: whether the output it is verbose or not;
* -h, --help: shows the help.
An example of run, using the configuration file as above, is:
sh
python3 run_prl.py -t 0.2 -s 1 -v
which runs PRL using 80% of the dataset as training set and the rest as test set, using 1 as pseudo-random seed and a verbose output.
Evaluation
The evaluation is computed in terms of accuracy, balanced accuracy and it also shows the confusion matrix.
Version
0.94b
Requirements
PRL requires the following python modules: * CVXOPT * Numpy * Scikit-learn * SciPy
Owner
- Name: Mirko
- Login: makgyver
- Kind: user
- Location: Torino
- Company: University of Torino - Department of Computer Science
- Website: makgyver.github.io
- Repositories: 13
- Profile: https://github.com/makgyver
Assistant Professor @ University of Torino
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 8 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 45 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 5
- Total maintainers: 1
pypi.org: prl
[P]reference and [R]ule [L]earning algorithm implementation
- Homepage: https://github.com/makgyver/PRL
- Documentation: https://prl.readthedocs.io/
- License: MIT
-
Latest release: 0.94b0
published almost 7 years ago
Rankings
Maintainers (1)
Dependencies
- cvxopt *
- numpy *
- scipy *
- sklearn *