Code Monkey home page Code Monkey logo

flagr's Introduction

(Py)FLAGR

Fuse, Learn, AGgregate, Rerank

FLAGR is a high performance, modular, open source C++ library for rank aggregation problems. It implements baseline and recent state-of-the-art algorithms that accept ranked preference lists and generate a single consensus list of elements.

PyFLAGR is a Python library built on top of FLAGR library core. It uses the FLAGR algorithm implementations by linking to the associated shared library. It can be easily installed with pip and used in standard Python programs and Jupyter notebooks.

The current FLAGR version is 1.0.8.

Both libraries are licensed under the Apache License, version 2.

Detailed documentation on the FLAGR and PyFLAGR components can be found in the docs/ directory. Code examples in C++ and Python are provided in the examples/ directory.

Official web site: https://flagr.site

Compiling from Sources

FLAGR can be compiled from its C++ sources by using the provided building scripts. These scripts require a working GCC compiler to be installed into the machine that performs the compilation.

There are two building scripts, one for Linux and one for Windows. Specifically:

  • In Linux: type make in Terminal to build the binaries from the C++ sources. The FLAGR binaries include:
    • the executable program FLAGR, and
    • the shared flagr.so library. Third-party programs can link to this shared library to obtain access to the FLAGR algorithm implementations.
  • In Windows: type makefile.bat in Windows CLI or Windows Powershell. The batch file will build the binaries from the C++ sources by generating two files:
    • the executable program FLAGR.exe, and
    • the Dynamic Link Library flagr.dll. Third-party Windows programs can link to this shared library to obtain access to the FLAGR algorithm implementations.

All the binary outputs of the building scripts (i.e., executables and libraries) will be created by default into the bin/Release/ directory of the package.

Running FLAGR

The application accepts 4 optional arguments in the following fashion:

FLAGR [cutoff] [input_file] [output_path] [qrels_file]

The input arguments are:

  • cutoff: the evaluation cut-off point, that is, the number of items of the aggregate list that will be included in the evaluation process. If nothing is passed, then the value 10 is used.
  • input_file: The full path to the input file that stores the input lists to be aggregated. This is where the aggregation algorithm/s read data from.
  • output_path: This is where the output aggregate lists and the evaluation results are stored. If nothing is passed, then the default value output is used.
  • qrels_file: This file stores the relevance judgments of the list elements. It is used to evaluate the employed rank aggregation algorithm/s. If nothing is passed, then no evaluation takes place.

Installing PyFLAGR

PyFLAGR can be installed directly by using pip:

pip install pyflagr

Alternatively, PyFLAGR can be installed from the sources by navigating to the directory where setup.py resides:

pip install .

flagr's People

Contributors

lakritidis avatar

Stargazers

 avatar Sebastian Schmidl avatar GUI Lin avatar

Watchers

 avatar

flagr's Issues

Unable to load PyFLAGR

Hi there,

Thank you for creating this valuable rank aggregation package. I am attempting to use PyFLAGR but have encountered an issue when creating the aggregator object. Per the instructions in the documentation, I have installed PyFLAGR with pip install pyflagr. I am also able to load pyflagr with:

# Import the PyFLAGR modules for rank aggregation
import pyflagr.Linear as Linear
import pyflagr.Majoritarian as Majoritarian
import pyflagr.MarkovChains as MarkovChains
import pyflagr.Kemeny as Kemeny
import pyflagr.RRA as RRA
import pyflagr.Weighted as Weighted

However, I cannot define an aggregator. The following line raises an OSError:

csum = Linear.CombSUM(norm='score')
OSError                                   Traceback (most recent call last)
Cell In[26], line 1
----> 1 csum = Linear.CombSUM(norm='score')

File ~/miniforge3/envs/myenv/lib/python3.10/site-packages/pyflagr/Linear.py:12, in CombSUM.__init__(self, norm, eval_pts)
     11 def __init__(self, norm=\"borda\", eval_pts=10):
---> 12     RAM.__init__(self, eval_pts)
     14     self.normalization = norm
     15     self.flagr_lib.Linear.argtypes = [
     16         ctypes.c_char_p,  # Input data file with the lists to be aggregated
     17         ctypes.c_char_p,  # Input data file with the relevant elements per query - used for evaluation
   (...)
     20         ctypes.c_char_p,  # Random string to be embedded into the output file names
     21         ctypes.c_char_p]  # The directory where the output files will be written

File ~/miniforge3/envs/myenv/lib/python3.10/site-packages/pyflagr/RAM.py:41, in RAM.__init__(self, eval_pts)
     38     self.flagr_lib = ctypes.CDLL(os.path.dirname(os.path.realpath(__file__)) + '/flagr.dll')
     40 elif platform == \"darwin\":
---> 41     self.flagr_lib = ctypes.CDLL(os.path.dirname(os.path.realpath(__file__)) + \"/flagr.dylib\")

File ~/miniforge3/envs/myenv/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 self._FuncPtr = _FuncPtr
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:
    376     self._handle = handle

OSError: dlopen(/Users/an123/miniforge3/envs/myenv/lib/python3.10/site-packages/pyflagr/flagr.dylib, 0x0006): tried: '/Users/an123/miniforge3/envs/myenv/lib/python3.10/site-packages/pyflagr/flagr.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/an123/miniforge3/envs/myenv/lib/python3.10/site-packages/pyflagr/flagr.dylib' (no such file), '/Users/an123/miniforge3/envs/myenv/lib/python3.10/site-packages/pyflagr/flagr.dylib' (no such file)

I would be grateful for your assistance in resolving this issue. Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.