Skip to content

zaratanDotWorld/powerRanker

Repository files navigation

CircleCI npm version License: MIT

powerRanker

Multipurpose Power Ranker implementation for determining probability distributions over sets of items based on weighted pairwise preference inputs. Chore Wheel spin-off.


Table of Contents

Installation

Installation is simple with npm:

>> npm install --save power-ranker

Usage

const { PowerRanker } = require('power-ranker');

const items = new Set([ 'a', 'b', 'c' ]);
const powerRanker = new PowerRanker({ items });

powerRanker.addPreferences([
  { target: 'a', source: 'b', value: 1 },
  { target: 'b', source: 'c', value: 1 },
]);

const results = powerRanker.run();

// a -> 0.5038945471248252)
// b -> 0.31132043857597014)
// c -> 0.18478501429920438)

API

constructor({ items: Set<string>, options: Object }): PowerRanker

  • Description: Initialize a new instance of PowerRanker
  • Parameters:
    • items: A set of strings describing the items being compared
    • options: An optional options object containing additional configuration
  • Returns: An initialized PowerRanker

addPreferences(preferences: Array<preference>)

  • Description: Add preferences to the ranker
  • Parameters:
    • preferences: An array of preference objects { target: string, source: string, value:float }

Note that a preference value must be between 0 and 1

run({ d:float, epsilon:float, nIter:int }): Map<string, float>

  • Description: Generates rankings using the given preferences
  • Parameters:
    • d: The "damping factor" which regularizes the output, must be between 0 and 1 with 1 being no damping
    • epsilon: A sensitivity used to determine when the algorithm stops running, normally a very small number
    • nIter: A maximum number of iterations to run the algorithm
  • Returns: A map of the rankings

Note that epsilon and nIter come with sensible defaults and normally will not need to be explicitly passed

License

This project is licensed under the MIT License - see LICENSE.txt for details.

Acknowledgements

The authors would like to acknowledge Gitcoin and Metagov for helping fund the development of this project.

About

Multipurpose Power Ranker implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published