anormalratingsystem.computation package

Submodules

anormalratingsystem.computation.ranking module

ranking.py: All ranking logic for the application.

class anormalratingsystem.computation.ranking.ItemRanker(items: list[dict[str, str]], progress_file: str = 'ranking_progress.json')

Bases: object

A class to rank items based on user comparisons.

items

A list of dictionaries containing the items to rank.

Type:

list[dict[str, str]]

ratings

A dictionary to keep track of the number of wins for each item.

Type:

dict[str, int]

progress_file

The file path to save and load progress.

Type:

str

estimate_comparisons_required() int

Estimate the number of comparisons required to rank all items.

Returns:

The estimated number of comparisons required.

Return type:

int

rank_items() list[dict[str, str]]

Rank items based on user comparisons and return a list of ranked items.

Returns:

A list of dictionaries containing the ranked items, where each dictionary has the item name and its corresponding rank.

Return type:

list[dict[str, str]]

Notes

This method ranks items using a comparison-based approach and distributes them into ten buckets according to a normal distribution. The process involves: 1. Grouping the items into pairs and comparing them to determine the better item. 2. Recursively applying the comparison process to the better items until a ranked list is formed. 3. Inserting any remaining items into the ranked list using binary search. 4. Distributing the ranked items into buckets based on a predefined weight distribution that favors the middle buckets, simulating a normal distribution.

Module contents

Computation package for the project.