Multipurpose Power Ranker implementation for determining probability distributions over sets of items based on weighted pairwise preference inputs. Chore Wheel spin-off.
Installation is simple with npm
:
>> npm install --save power-ranker
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)
- Description: Initialize a new instance of PowerRanker
- Parameters:
items
: A set of strings describing the items being comparedoptions
: An optional options object containing additional configuration
- Returns: An initialized PowerRanker
- 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
- 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 dampingepsilon
: A sensitivity used to determine when the algorithm stops running, normally a very small numbernIter
: 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
This project is licensed under the MIT License - see LICENSE.txt for details.
The authors would like to acknowledge Gitcoin and Metagov for helping fund the development of this project.