A package for generating synthetic data, reranking students, and calculating fairness metrics.
Project description
Fairness Ranking
This package provides functions for generating synthetic data, reranking students based on tolerance, and calculating fairness metrics.
Installation
To install the package from PyPI, run:
pip install fairness_ranking
Usage
Here is an example of how to use the package:
import fairness_ranking.ranking as fr
# Define the number of candidates and tolerance
num_candidates = 10
tolerance = 252
# Generate synthetic data
synthetic_data = fr.generate_synthetic_data(num_candidates, 'A vs B')
# Rerank the synthetic data
reranked_data = fr.rerank_students(synthetic_data, tolerance)
# Calculate rewards and totals
data_with_rewards, total_w, total_b = fr.add_rewards_and_calculate_totals(reranked_data, 'linear')
# Calculate fairness metric
initial_rewards = {'w': total_w, 'b': total_b}
post_reranking_rewards = {'w': total_w, 'b': total_b}
fairness_metric = fr.calculate_fairness_metric(initial_rewards, post_reranking_rewards)
print(f"Fairness Metric: {fairness_metric}")
Functions
generate_synthetic_data(num_candidates, gap_scenario, seed=42)
Generates synthetic data with varying gaps between candidate scores.
num_candidates: Number of candidates.
gap_scenario: The scenario defining the score gaps ('A vs B', 'A vs C', 'A vs D', 'MIX').
seed: Seed for random number generation (default is 42).
rerank_students(students, tolerance)
Reranks students based on a given tolerance.
students: List of student dictionaries with scores and groups.
tolerance: Tolerance value for reranking.
calculate_logarithmic_rewards(n)
Calculates logarithmic rewards.
n: Number of candidates.
add_rewards_and_calculate_totals(data, reward_type='linear')
Adds rewards to the data and calculates total rewards for each group.
data: List of candidate dictionaries with scores and groups.
reward_type: Type of rewards ('linear' or 'logarithmic').
calculate_fairness_metric(initial_rewards, post_reranking_rewards)
Calculates the fairness metric based on initial and post-reranking rewards.
initial_rewards: Dictionary with initial total rewards for each group.
post_reranking_rewards: Dictionary with post-reranking total rewards for each group.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fairness_ranking-0.1.1.tar.gz.
File metadata
- Download URL: fairness_ranking-0.1.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82ac69cdcdd8e22967c1e258f438f0c62a2a9fac3c0289e932c908a89c9e4fe8
|
|
| MD5 |
0626384bde643746c63899c4be7d5764
|
|
| BLAKE2b-256 |
d3a1b3c78b863371b8743353738a43b0f8d375b440bb31e8b92f2f4ed2d31b28
|
File details
Details for the file fairness_ranking-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fairness_ranking-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95ff17ea87f4fb9574123542a5668fb27e12eebaab68d223d5ce58b1554e818d
|
|
| MD5 |
96c516ee55e0f9449016d02f3ffee13d
|
|
| BLAKE2b-256 |
c5510f4e0d278ec74703be5bf06f06c38db8b3f79f4bd2d46be716556d0bfd64
|