PrefGraph Logo
  • Installation
    • Extras
    • Choose Your Workflow
  • Loading Data
    • Synthetic data (Rust-parallel generators)
    • Budget data from Parquet (wide format)
    • Budget data from Parquet (long format)
    • Budget data from a DataFrame (per‑user arrays)
    • Menu data from Parquet (events → menus)
  • Theory
    • Phase 1 - Foundations
    • Phase 2 - Budget Consistency
    • Phase 3 - Budget Efficiency
    • Phase 4 - Budget Structure and Recovery
    • Phase 5 - Deterministic Menu Choice
    • Phase 6 - Stochastic Menus and Attention
    • Contents
      • Method Landscape
        • Abbreviations
      • Theoretical Foundations
        • Formal Notation
        • Maintained Assumptions
        • Axiomatic Hierarchy
      • Axiomatic Consistency Tests
        • GARP (Generalized Axiom of Revealed Preference)
        • WARP (Weak Axiom of Revealed Preference)
        • SARP (Strong Axiom of Revealed Preference)
        • Smooth Preferences and Differentiable Utility
        • Acyclical Strict Preferences (Acyclical P)
        • Generalized Axiom of Price Preferences (GAPP)
      • Efficiency and Power Indices
        • Critical Cost Efficiency Index (CCEI)
        • Money Pump Index (MPI)
        • Houtman-Maks Index (HM)
        • Granular Efficiency (Varian’s Index)
        • Statistical Test Power (Bronars’ Index)
        • Observation Graph Network Features
      • Structural Preference Analysis and Utility Recovery
        • Homothetic Preferences (HARP)
        • Quasilinear Utility (Income Invariance)
        • Weak Separability (Feature Independence)
        • Utility Recovery via Afriat’s Inequalities
      • Abstract Choice Theory and Menu-Based Analysis
        • Formal Notation
        • The Revealed Preference Relation
        • Weak Axiom of Revealed Preference (WARP)
        • Strong Axiom of Revealed Preference (SARP)
        • Congruence and Full Rationalizability
        • Houtman-Maks Efficiency for Discrete Choice
        • Ordinal Preference Recovery
        • Item Graph Network Features
      • Stochastic Choice
        • Random Utility Model
        • Logit Model
        • McFadden’s Axioms
      • Limited Attention
        • Attention Filter Framework
        • WARP(LA): WARP with Limited Attention
        • Recovering Attention Filters
        • Consideration Set Estimation
        • Salience Weights
        • Random Attention Model (RAM)
        • RAM Assumptions
        • Attention Bounds
  • Identification and Failure Modes
    • Stockouts and Unavailability
    • Platform and Recommendation Bias
    • Reconstructed Menus
    • Bundle Aggregation
    • Category Aggregation
    • Habit and Repeated Exposure
    • Time-Varying Preferences Over Long Panels
  • Budgets
    • Theory
    • Tutorials
      • Tutorial 1: Budget-Based Analysis
        • Prerequisites
        • Important Assumptions
        • Part 1: The Data
        • Part 2: Building BehaviorLogs
        • Part 3: Testing Consistency (GARP)
        • Part 3a: Lenient Consistency (Acyclical P)
        • Part 4: Assessing Test Power
        • Part 5: Measuring Efficiency (CCEI)
        • Part 6: Welfare Loss (MPI)
        • Part 6a: Per-Observation Efficiency (VEI)
        • Part 6b: Swaps Index
        • Part 6c: Observation Contributions
        • Part 7: Advanced Topics
        • Part 8: Unified Summary Display
        • Part 9: Diagnostic Visualizations
        • Part 10: Summary
        • See Also
      • Tutorial 1a: Advanced Budget Analysis
        • Prerequisites
        • Part 1: Homothetic Preferences (HARP)
        • Part 2: The Lancaster Model
        • Part 3: Utility Recovery
        • See Also
      • Tutorial 6: E-Commerce at Scale
        • Prerequisites
        • Part 1: The Data Challenge
        • Part 2: Theory Review
        • Part 3: Data Processing Pipeline
        • Part 4: Implementing the Algorithms
        • Part 5: Analyzing One User
        • Part 6: Scaling to All Users
        • Part 7: Comparison to Benchmarks
        • Part 8: Heterogeneity Analysis
        • Part 9: Power Analysis
        • Part 10: Using PrefGraph
        • Running the Full Pipeline
        • Key Takeaways
        • Exercises
    • Applications
      • Grocery Scanner Data
        • Introduction
        • Background
        • Data
        • Pipeline Walkthrough
        • Batch Analysis
        • Beyond Consistency Scores
        • Temporal Panel Analysis
        • Interpretation
      • LLM Prompt Consistency
        • Introduction
        • Formal Setup
        • Experiment Design
        • Algorithm
        • Running the Experiment
        • Interpretation
    • Examples
      • Examples
        • Batch Scoring (Engine)
        • Single-User Analysis
        • Full Report
        • HARP (Homotheticity)
        • VEI (Per-Observation Efficiency)
        • Utility Recovery
        • Power Analysis
        • Quasilinear Utility
        • Menu Choices (SARP)
        • Production Data
        • Loading Data
  • Menus
    • Theory
    • Tutorials
      • Tutorial 2: Menu-Based Choice
        • Prerequisites
        • Part 1: The Data (MenuChoiceLog)
        • Part 2: Testing WARP
        • Part 3: Testing SARP
        • Part 4: Full Rationalizability (Congruence)
        • Part 5: Efficiency Index (Houtman-Maks)
        • Part 6: Recovering Preferences
        • Part 7: Limited Attention Models
        • Part 8: Application Example
        • Part 9: Notes
        • Part 10: Unified Summary Display
        • See Also
      • Tutorial: Stochastic Choice
        • Prerequisites
        • The Data (StochasticChoiceLog)
        • Random Utility Models
        • Testing McFadden Axioms
        • Regularity Axiom Testing
        • Testing IIA (Independence of Irrelevant Alternatives)
        • Application: A/B Testing for Product Features
        • Notes
        • See Also
      • Tutorial 7: Revealed Attention
        • Prerequisites
        • Part A: Deterministic Attention (WARP-LA)
        • Part B: Random Attention Model (RAM)
        • Part C: Application Examples
        • Part D: Notes
        • Part E: Attention Overload
        • Part F: Status Quo Bias
        • Part G: Attention Visualizations
        • See Also
    • Applications
      • Recommender Systems
        • Introduction
        • Formal Setup
        • Data
        • Algorithm
        • Pipeline Walkthrough
        • Batch Analysis
        • Temporal Analysis: Churn Detection
        • Interpretation
    • Examples
      • Examples
        • SARP / WARP Consistency
        • Detecting Violations
        • Houtman-Maks Efficiency
        • Ordinal Utility Recovery
        • Limited Attention (WARP-LA)
        • Stochastic Choice (RUM)
        • Risk Preferences
        • Context Effects (Decoy Detection)
        • Ranking and Pairwise Comparison
        • Batch Menu Scoring (Engine)
  • Examples
    • Detecting Inconsistency in AI Agents
      • Example
        • Setup
        • How to read the results
        • Why this design
        • Results 1: Deterministic (temp=0)
        • Results 2: Stochastic Choice (RUM)
        • Patterns
        • Findings
        • Computational Cost
        • Replication
        • Appendix
    • Descriptive Study of Classifieds Choice
      • Platform and Data
      • Results
        • User Profiles
        • Stochastic Consistency
        • Search vs Recommendation
        • Violation Anatomy
      • Pipeline
    • Predicting Customer Spend and Engagement
      • Setup
        • Features
        • Targets
      • Results
      • Findings
      • Suggestive Directions
      • Feature Importance
      • Replication
      • Dataset Summary
      • Feature Correlation
      • Limitations
      • Null Rates
      • Dataset Descriptions
    • Performance Benchmarks
      • Scalability and Throughput
      • Computational Complexity by Metric
      • Memory Management and Streaming
      • Large-Scale Benchmarks
      • End-to-End from Disk
      • Complexity Summary
      • Hardware Configuration
  • Under the Hood
    • Complexity
    • Budget-Based Methods
      • GARP - SCC Algorithm
      • CCEI (Afriat Efficiency Index)
      • MPI (Money Pump Index) - Karp’s Algorithm
      • HARP (Homothetic Axiom) - Max-Product Paths
      • Houtman-Maks Index - Greedy + ILP
      • VEI (Varian Efficiency Index) - Exact MILP
      • GAPP (Generalized Axiom of Price Preference)
    • Stochastic Choice and RUM
    • Practical Usage: Code Examples
    • Solver Stack
  • API
    • One-Liner API
      • analyze()
    • Engine (Batch Scoring)
      • Engine
        • Engine
      • EngineResult
        • EngineResult
    • High-Level Classes
      • BehavioralAuditor
        • BehavioralAuditor
      • AuditReport
        • AuditReport
      • PreferenceEncoder
        • PreferenceEncoder
    • Summary Classes
      • BehavioralSummary
        • BehavioralSummary
      • PanelSummary
        • PanelSummary
    • Data Containers
      • BehaviorLog
        • BehaviorLog
      • BehaviorPanel
        • BehaviorPanel
      • MenuChoicePanel
        • MenuChoicePanel
      • RiskChoiceLog
        • RiskChoiceLog
      • EmbeddingChoiceLog
        • EmbeddingChoiceLog
    • Consistency Functions
      • validate_consistency()
      • validate_consistency_weak()
      • validate_sarp()
      • validate_smooth_preferences()
      • validate_strict_consistency()
      • validate_price_preferences()
    • Efficiency Functions
      • compute_integrity_score()
      • compute_ccei()
      • compute_confusion_metric()
      • compute_mpi_bounds()
      • compute_minimal_outlier_fraction()
      • compute_granular_integrity()
      • compute_test_power()
    • Preference Structure Functions
      • validate_proportional_scaling()
      • test_income_invariance()
      • test_feature_independence()
      • test_cross_price_effect()
      • compute_cross_price_matrix()
    • Utility Recovery
      • fit_latent_values()
      • build_value_function()
      • predict_choice()
    • Embedding Analysis
      • find_preference_anchor()
      • validate_embedding_consistency()
      • compute_signal_strength()
    • Risk Analysis
      • compute_risk_profile()
      • check_expected_utility_axioms()
      • classify_risk_type()
    • Menu Choice Functions
      • MenuChoiceLog
        • MenuChoiceLog
      • MenuPreferenceEncoder
        • MenuPreferenceEncoder
      • MenuAuditReport
        • MenuAuditReport
      • Menu Consistency Functions
        • validate_menu_warp()
        • validate_menu_sarp()
        • validate_menu_consistency()
        • compute_menu_efficiency()
        • fit_menu_preferences()
    • Integrability (Slutsky Conditions)
      • test_integrability()
      • compute_slutsky_matrix()
      • check_slutsky_symmetry()
      • check_slutsky_nsd()
    • Welfare Analysis
      • analyze_welfare_change()
      • compute_compensating_variation()
      • compute_equivalent_variation()
      • recover_cost_function()
      • compute_consumer_surplus()
      • compute_deadweight_loss()
    • Additive Separability
      • test_additive_separability()
      • identify_additive_groups()
      • check_no_cross_effects()
    • Compensated Demand
      • decompose_price_effects()
      • compute_hicksian_demand()
      • check_compensated_law_of_demand()
      • compute_slutsky_decomposition()
      • estimate_compensated_demand()
    • General Metric Preferences
      • find_ideal_point_general()
      • determine_best_metric()
      • test_metric_rationality()
    • Stochastic Choice
      • StochasticChoiceLog
        • StochasticChoiceLog
        • fit_random_utility_model()
        • test_mcfadden_axioms()
        • estimate_choice_probabilities()
        • check_independence_irrelevant_alternatives()
        • fit_luce_model()
    • Limited Attention
      • test_attention_rationality()
      • estimate_consideration_sets()
      • compute_salience_weights()
      • test_attention_filter()
    • Production Theory
      • ProductionLog
        • ProductionLog
        • test_profit_maximization()
        • check_cost_minimization()
        • estimate_returns_to_scale()
        • compute_technical_efficiency()
    • Data Generators
      • generate_random_budgets()
      • generate_random_menus()
      • generate_random_production()
      • generate_random_intertemporal()
    • Dataset Loaders
      • load_demo()
      • load_dunnhumby()
      • load_open_ecommerce()
      • load_uci_retail()
      • load_retailrocket()
      • load_instacart()
      • load_instacart_menu_v2()
      • load_yoochoose()
      • load_olist()
      • load_m5()
      • load_rees46()
      • load_online_retail_ii()
      • load_hm()
      • load_pakistan()
      • load_favorita()
      • load_taobao()
      • list_datasets()
    • Exceptions and Warnings
      • Base Exception
        • PrefGraphError
      • Data Validation Exceptions
        • DataValidationError
        • DimensionError
        • ValueRangeError
        • NaNInfError
      • Computation Exceptions
        • OptimizationError
        • NotFittedError
        • InsufficientDataError
      • Warnings
        • DataQualityWarning
        • NumericalInstabilityWarning
    • Troubleshooting
  • References
    • Consistency Testing
    • Efficiency Measures
    • Stochastic & Attention
    • Welfare & Extensions
    • Algorithmic Methods
    • AI & Alignment Applications
PrefGraph
  • Overview: module code

All modules for which code is available

  • prefgraph.algorithms.abstract_choice
  • prefgraph.algorithms.aei
  • prefgraph.algorithms.attention
  • prefgraph.algorithms.garp
  • prefgraph.algorithms.harp
  • prefgraph.algorithms.mpi
  • prefgraph.algorithms.production
  • prefgraph.algorithms.quasilinear
  • prefgraph.algorithms.utility
  • prefgraph.algorithms.vei
  • prefgraph.analyze
  • prefgraph.auditor
  • prefgraph.contrib.acyclical_p
  • prefgraph.contrib.additive
  • prefgraph.contrib.bronars
  • prefgraph.contrib.differentiable
  • prefgraph.contrib.gapp
  • prefgraph.contrib.gross_substitutes
  • prefgraph.contrib.integrability
  • prefgraph.contrib.risk
  • prefgraph.contrib.separability
  • prefgraph.contrib.spatial
  • prefgraph.contrib.stochastic
  • prefgraph.contrib.welfare
  • prefgraph.core.exceptions
  • prefgraph.core.panel
  • prefgraph.core.session
  • prefgraph.core.summary
  • prefgraph.datasets
    • prefgraph.datasets._demo
    • prefgraph.datasets._dunnhumby
    • prefgraph.datasets._favorita
    • prefgraph.datasets._generators
    • prefgraph.datasets._hm
    • prefgraph.datasets._instacart
    • prefgraph.datasets._m5
    • prefgraph.datasets._olist
    • prefgraph.datasets._online_retail_ii
    • prefgraph.datasets._open_ecommerce
    • prefgraph.datasets._pakistan
    • prefgraph.datasets._uci_retail
    • prefgraph.datasets._yoochoose
  • prefgraph.encoder
  • prefgraph.engine

© Copyright 2024, PrefGraph Contributors.

Built with Sphinx using a theme provided by Read the Docs.