Skip to main content

A python package for implementing Markov Chain Type 4 rank aggregation

Project description

Markov Chain Type 4 Rank Aggregation

implementation of MC4 and MCT Rank Aggregation algorithm using Python

Description

This project is all about implementing two of the most popular rank aggregation algorithms, Markov Chain Type 4 or MC4 and MCT. In the field of Machine Learning and many other scientific problems, several items are often needed to be ranked based on some criterion. However, different ranking schemes order the items based on different preference criteria. Hence the rankings produced by them may differ greatly.

Therefore a rank aggregation technique is often used for combining the individual rank lists into a single aggregated ranking. Though there are many rank aggregation algorithms, MC4 and MCT are two of the most renowned ones.

Resource

Links to the original contents

Installation

For the latest release, pip install mc4

For a specific release, pip install mc4=={version} such as pip install mc4==1.0.0

General Usage

Using this package is very easy.

  1. Prepare a dataset containing ranks of all the items provided by different algorithms. See here for sample datasets and more info.

  2. Use following lines of code to use the package. Make sure to pass arguments according to your dataset otherwise answers will be incorrect.

from mc4.algorithm import mc4_aggregator
import pandas as pd

# Method 1
aggregated_ranks = mc4_aggregator('test_dataset_1.csv', header_row = 0, index_col = 0) 

# or Method 2
df = pd.read_csv('test_dataset_1.csv', header = 0, index_col = 0)
aggregated_ranks = mc4_aggregator(df, header_row = 0, index_col = 0) 

print(aggregated_ranks)

here test_dataset_1.csv is a sample dataset containing ranks of different items provided by different algorithms.

mc4_aggregator takes some mandatory and optional arguments -

  • algo (string): algorithm for rank aggregation, mc4 or mct, default is mc4
  • order (string): order of the dataset, row or column, default is row. More on this, here.
  • header_row (int or None): row number of the dataset containing the header, default is None
  • index_col (int or None): column number of the dataset containing the index, default is None
  • precision (float): acceptable error margin for convergence, default is 1e-07
  • iterations (int): number of iterations to reach stationary distribution, default is 200
  • erg_number (float): small, positive number used to calculate ergodic transition matrix, default is 0.15

Command Line Usage

You can directly use this package from command line if you have the dataset prepared already.

  • To get help and usage details,

    ~$ mc4_aggregator -h or --help
    
  • Use with default settings,

    ~$ mc4_aggregator dataset.csv
    
  • Specify the algorithm for rank aggregation using -a or --algo, options: mc4 or mct, default is mc4

    ~$ mc4_aggregator dataset.csv -a mct
    
  • Specify order using -oor --order, options: row or column, default is row

    ~$ mc4_aggregator dataset.csv -o column
    
  • Specify header row using -hr or --header_row, default is None

    ~$ mc4_aggregator dataset.csv -hr 0
    
  • Specify index column using -ic or --index_col, default is None

    ~$ mc4_aggregator dataset.csv -ic 0
    
  • Specify precision using -p or --precision, default is 1e-07

    ~$ mc4_aggregator dataset.csv -p 0.000001
    
  • Specify iterations using -i or --iterations, default is 200

    ~$ mc4_aggregator dataset.csv -i 300
    
  • Specify ergodic number using -e or --erg_number, default is 0.15

    ~$ mc4_aggregator dataset.csv -e 0.20
    
  • All together,

    ~$ mc4_aggregator dataset.csv -a mct -o column -hr 0 -ic 0 -p 0.000001 -i 300 -e 0.20
    

Output

Output of mc4_aggregator will be a dictionary containing itemwise ranks. In absence of item names, items will be represented using integers.

Important Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mc4-2.3.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

mc4-2.3.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file mc4-2.3.0.tar.gz.

File metadata

  • Download URL: mc4-2.3.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for mc4-2.3.0.tar.gz
Algorithm Hash digest
SHA256 ffe2115ea527d1e62064eb5b28b38ea5c030f1570c0a2b9d76400e860abed454
MD5 b414ba0ef2fadeadcc1fd4f9bc84e793
BLAKE2b-256 d38f3c99afb24b20b71effcde218e5ddde8640440cf7a6161263521e10d2b504

See more details on using hashes here.

File details

Details for the file mc4-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: mc4-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for mc4-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 388510f28b10d70f637d95bf3df1ec839771e2d994055ddba1d371c81732d8a3
MD5 679e9ea41102568ef13b1b6c8cf437b8
BLAKE2b-256 9da7b9e2aaa6537d0a8d17f86812852058e5b13078fc055a20e2cd8e714cb3f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page