ranking 0.0.1

Calculate average or median ranking from many samples or ranked data
Documentation
  • Coverage
  • 0%
    0 out of 6 items documented0 out of 2 items with examples
  • Size
  • Source code size: 5.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.32 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • drbh/ranking-rs
    6 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • drbh

Ranking

Simple consolidated ranking from many samples of ranked data. No dependencies, 100% Rust, very simple, lightweight and fast.

Use Crate

ranking = "0.0.1"

Example Code

The following code uses both the Median and Average metric to compute the final ranking. This code is also in examples/basic.rs

use ranking::{calculate_ranking, Metric};

fn main() {
    // example of people ranking tequila brands
    let ranking_a = vec!["Don Julio", "Patron", "Herradura", "Espolon", "El Jimidor"];
    let ranking_b = vec!["Espolon", "Herradura", "Don Julio", "El Jimidor", "Patron"];
    let ranking_c = vec!["Espolon", "Don Julio", "El Jimidor", "Herradura", "Patron"];

    let everyones_rankings = vec![
        ("david", ranking_a),
        ("sakura", ranking_b),
        ("joe", ranking_c),
    ];

    // here we use the median to calculate the final ranking
    let m_metric = Metric::Median;
    let rankings_by_median = calculate_ranking(everyones_rankings.clone(), m_metric);
    println!("{:?}", rankings_by_median);
    // [(0.0, "Espolon"), (1.0, "Don Julio"), (2.0, "Herradura"), (3.0, "El Jimidor"), (4.0, "Patron")]

    // here we use the average to calculate the final ranking
    let a_metric = Metric::Average;
    let rankings_by_average = calculate_ranking(everyones_rankings.clone(), a_metric);
    println!("{:?}", rankings_by_average);
    // [(1.0, "Don Julio"), (1.0, "Espolon"), (2.0, "Herradura"), (3.0, "El Jimidor"), (3.0, "Patron")]
}