Recommendation systems typically optimize for consumer relevance, but this can unintentionally disadvantage niche users or small producers. This work formalizes consumer utility (relevance) and producer utility (exposure), and introduces Conditional Value at Risk (CVaR) as an optimization objective to directly target fairness.
The project investigates fairness in multi-stakeholder marketplaces (e.g., platforms with both consumers and producers) and proposes optimization methods that balance consumer satisfaction with equitable producer exposure. It integrates machine learning recommender models with fairness-aware allocation strategies and evaluates their performance on real-world and synthetic datasets.
- Defines consumer and producer utility functions in two-sided marketplaces
- Introduces fairness-aware optimization (mean utility, max–min fairness, CVaR)
- Demonstrates that fairness constraints can improve business outcomes such as Sell-Through Rate (STR) and Gross Merchandise Value (GMV)
- Compares exact solvers (SCIP, Gurobi) with scalable approximations (relaxation, Augmented Lagrangian)
- Python 3.12+
- uv for dependency management
- Install uv (if not already installed):
# On macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh- Clone and setup the repository:
git clone <your-repo-url>
uv sync- Verify installation:
uv run python -c "import cvxpy, torch, numpy; print('Installation successful!')"├── src/ # Core implementation
│ ├── problems/ # Optimization problems (CVaR, mean, min)
│ ├── optimizers/ # Solver implementations
│ ├── models/ # ML model definitions
│ └── measures.py # Fairness and utility metrics
├── notebooks/ # Jupyter notebooks for experiments
│ ├── movielens/ # MovieLens dataset experiments
│ ├── experiments/ # Additional experimental results
│ └── *.ipynb # Individual analysis notebooks
├── data/ # Datasets and preprocessed data
│ ├── ml-100k/ # MovieLens 100K dataset
│ ├── *_predictions.npy # Model predictions
│ └── *_user_groups.json # User group assignments
├── outputs/ # Output files (logs, results)
└── results/ # Experimental results and visualizations
Start with the main experiment notebook:
uv run jupyter notebook notebooks/movielens/experiments.ipynbThis notebook demonstrates:
- Loading and preprocessing the MovieLens dataset
- Training recommendation models
- Running fairness-aware optimization experiments
- Generating tradeoff curves between consumer utility and producer fairness
For Conditional Value at Risk experiments:
uv run jupyter notebook notebooks/movielens/cvar.ipynbTo run your own experiments, use the core optimization functions:
from src.problems.problems import compute_consumer_optimal_solution
import numpy as np
# Example: Run CVaR optimization
rel_matrix = np.random.rand(100, 50) # 100 users, 50 items
k_rec = 10 # Recommend 10 items per user
gamma = 0.8 # Fairness constraint strength
group_assignments = [0, 1, 0, 1, ...] # User group assignments
alpha = 0.1 # CVaR confidence level
# Solve the optimization problem
optimal_value, allocations = compute_consumer_optimal_solution(
rel_matrix=rel_matrix,
k_rec=k_rec,
producer_max_min_utility=5.0,
gamma=gamma,
method="cvar",
group_assignments=group_assignments,
alpha=alpha
)The experiments demonstrate several important findings:
- Fairness-Utility Tradeoffs: There exists a clear tradeoff between consumer utility and producer fairness
- CVaR Effectiveness: CVaR-based optimization provides better worst-case guarantees than mean utility optimization
- Business Impact: Fairness constraints can improve long-term business metrics like STR and GMV
- Scalability: Relaxed optimization methods provide good approximations with significantly reduced computational cost
The repository implements several fairness-aware optimization approaches:
mean: Maximizes average consumer utilitymin: Maximizes minimum consumer utility (max-min fairness)cvar: Minimizes Conditional Value at Risk for group fairnesscvar_relaxed_naive: CVaR with naive roundingcvar_relaxed_topk: CVaR with top-k rounding
The experiments use several datasets:
- MovieLens 100K: Standard collaborative filtering benchmark
- Amazon Reviews: Large-scale e-commerce data
- Synthetic Data: Controlled experiments for validation
Key dependencies include:
- CVXPY: Convex optimization framework
- Gurobi/SCIP: Commercial/open-source solvers
- PyTorch: Deep learning models
- NumPy/SciPy: Numerical computing
- Matplotlib/Seaborn: Visualization
See pyproject.toml for the complete dependency list.
- Solver not found: Make sure you have Gurobi or SCIP installed and properly licensed
- Memory issues: For large datasets, consider using the relaxed optimization methods
- Installation problems: Ensure you're using Python 3.12+ and the latest version of uv
- Check the Jupyter notebooks for usage examples
- Review the docstrings in
src/problems/problems.pyfor detailed function documentation - Open an issue for specific problems or questions