Slide 1

Slide 1 text

Learning Agent-Based Models from Data Gianmarco De Francisci Morales Principal Researcher • CENTAI Team Lead • Social Algorithmics Team 
 [email protected] 1 SALT

Slide 2

Slide 2 text

Learning Agent-Based Models from Data Models Gianmarco De Francisci Morales Principal Researcher • CENTAI Team Lead • Social Algorithmics Team 
 [email protected] 1 SALT

Slide 3

Slide 3 text

2

Slide 4

Slide 4 text

2

Slide 5

Slide 5 text

Agent-based model 3

Slide 6

Slide 6 text

Agent-based model Evolution over time of system of autonomous agents Agents interact according to prede fi ned rules Encode sociological assumptions 3

Slide 7

Slide 7 text

Agent-based model Evolution over time of system of autonomous agents Agents interact according to prede fi ned rules Encode sociological assumptions System is simulated to draw conclusions 3

Slide 8

Slide 8 text

Example: Schelling's segregation 2 types of agents: R and B Satisfaction: number of neighbors of same color Homophily parameter If τ Si < τ → relocate 4

Slide 9

Slide 9 text

Example: Schelling's segregation 2 types of agents: R and B Satisfaction: number of neighbors of same color Homophily parameter If τ Si < τ → relocate 4

Slide 10

Slide 10 text

Are ABMs scienti fi c models? 5

Slide 11

Slide 11 text

Are ABMs scienti fi c models? Mechanistic models Explainable and causal by construction Counterfactual level of ladder of causality 5 𝔼 (Y ∣ X) 𝔼 (Y ∣ do(X)) 𝔼 (YX′  ∣ X, YX )

Slide 12

Slide 12 text

Are ABMs scienti fi c models? Mechanistic models Explainable and causal by construction Counterfactual level of ladder of causality Data not a fi rst-class citizen No sound parameter- fi tting procedure 5

Slide 13

Slide 13 text

Good tests kill fl awed theories — Karl Popper Falsi fi ability of ABMs 6

Slide 14

Slide 14 text

ABMs and Data 7

Slide 15

Slide 15 text

ABMs and Data ABM born as "theory development tool" Simulations generate implications of encoded assumptions 7

Slide 16

Slide 16 text

ABMs and Data ABM born as "theory development tool" Simulations generate implications of encoded assumptions Now people use it as forecasting tool (epidemiology, economics, etc.) 7

Slide 17

Slide 17 text

ABMs and Data ABM born as "theory development tool" Simulations generate implications of encoded assumptions Now people use it as forecasting tool (epidemiology, economics, etc.) Calibration to set parameters from data 7

Slide 18

Slide 18 text

Calibration 8

Slide 19

Slide 19 text

Calibration Run simulations with different parameters until model reproduces 
 summary statistics of data 8

Slide 20

Slide 20 text

Calibration Run simulations with different parameters until model reproduces 
 summary statistics of data No parameter signi fi cance or model selection 8

Slide 21

Slide 21 text

Calibration Run simulations with different parameters until model reproduces 
 summary statistics of data No parameter signi fi cance or model selection Arbitrary choice of summary statistics and distance measure 8

Slide 22

Slide 22 text

Calibration Run simulations with different parameters until model reproduces 
 summary statistics of data No parameter signi fi cance or model selection Arbitrary choice of summary statistics and distance measure Manual, expensive, and error-prone process 8

Slide 23

Slide 23 text

Can we do better? 9

Slide 24

Slide 24 text

Can we do better? Yes! 9

Slide 25

Slide 25 text

Can we do better? Yes! Rewrite ABM as Probabilistic Generative Model 
 Xt ∼ Pt (Xt ∣ Θ, Xτ

Slide 26

Slide 26 text

Can we do better? Yes! Rewrite ABM as Probabilistic Generative Model 
 Xt ∼ Pt (Xt ∣ Θ, Xτ

Slide 27

Slide 27 text

Can we do better? Yes! Rewrite ABM as Probabilistic Generative Model 
 Xt ∼ Pt (Xt ∣ Θ, Xτ

Slide 28

Slide 28 text

Historical Aside Maximum Likelihood Estimation invented by Fisher Dates back to Daniel Bernoulli and Lagrange in the eighteenth century Fisher introduced the method as alternative to method of moments Which he criticizes for its arbitrariness in the choice of moment equations 10

Slide 29

Slide 29 text

Autodiff Set of techniques to evaluate the partial derivative of a computer program Chain rule to break complex expressions Originally created for neural networks and deep learning (backpropagation) Different from numerical and symbolic differentiation ∂f(g(x)) ∂x = ∂f ∂g ∂g ∂x 11

Slide 30

Slide 30 text

Example Automatic Differentiation (autodiff) • Create computation graph for gradient computation ∗ "# + %# ∗ "& %& "' + ∗ −1 *%+ +1 , = 1 1 + *.(012034320545) 1/% 12

Slide 31

Slide 31 text

Example Automatic Differentiation (autodiff) • Create computation graph for gradient computation ∗ "# + %# ∗ "& %& "' + ∗ −1 *%+ +1 1/% − 1 %& - = 1 1 + */(123145431656) - % = 1/% à 89 85 = −1/%& 13

Slide 32

Slide 32 text

Example Automatic Differentiation (autodiff) • Create computation graph for gradient computation ∗ "# + %# ∗ "& %& "' + ∗ −1 *%+ +1 1/% − 1 %& - = 1 1 + */(123145431656) ∗ 1 - % = % + 1 à 89 85 = 1 14

Slide 33

Slide 33 text

Example Automatic Differentiation (autodiff) • Create computation graph for gradient computation ∗ "# + %# ∗ "& %& "' + ∗ −1 *%+ +1 1/% − 1 %& - = 1 1 + */(123145431656) ∗ 1 ∗ - % = *5 à 89 85 = *5 15

Slide 34

Slide 34 text

Example Automatic Differentiation (autodiff) • Create computation graph for gradient computation ∗ "# + %# ∗ "& %& "' + ∗ −1 *%+ +1 1/% − 1 %& - = 1 1 + */(123145431656) ∗ 1 ∗ ∗ −1 ∗ 89 814 - %, " = %" à 8; 81 = % 16

Slide 35

Slide 35 text

Example Automatic Differentiation (autodiff) • Create computation graph for gradient computation ∗ "# + %# ∗ "& %& "' + ∗ −1 *%+ +1 1/% − 1 %& - = 1 1 + */(123145431656) ∗ 1 ∗ ∗ −1 ∗ 89 814 ∗ 89 816 17

Slide 36

Slide 36 text

Problem Solution → 18

Slide 37

Slide 37 text

Problem Solution → No parameter signi fi cance or model selection Probabilistic modeling 
 18 →

Slide 38

Slide 38 text

Problem Solution → No parameter signi fi cance or model selection Arbitrary choice of summary statistics and distance measure Probabilistic modeling 
 Data likelihood 
 18 → →

Slide 39

Slide 39 text

Problem Solution → No parameter signi fi cance or model selection Arbitrary choice of summary statistics and distance measure Manual, expensive, and 
 error-prone process Probabilistic modeling 
 Data likelihood 
 Automatic differentiation 18 → → →

Slide 40

Slide 40 text

Likelihood vs Simulation 19

Slide 41

Slide 41 text

Opinion dynamics How people's belief evolve Polarization, Radicalization, Echo Chambers Data from Social Media 20

Slide 42

Slide 42 text

Opinion dynamics How people's belief evolve Polarization, Radicalization, Echo Chambers Data from Social Media 20

Slide 43

Slide 43 text

Likelihood-Based Methods Improve Parameter Estimation in Opinion D XC X0 XC+1 B 4 n ) (a) BCM-F X: opinions s: interaction outcome e: interacting agents : bounded con fi dence interval ϵ Generative Model 21

Slide 44

Slide 44 text

Macro-Parameter Inference 22

Slide 45

Slide 45 text

Macro-Parameter Inference 22

Slide 46

Slide 46 text

Macro-Parameter Inference 22

Slide 47

Slide 47 text

Macro-Parameter Inference 22 RE=89% 
 (90th pctile) RE=22% 
 (90th pctile)

Slide 48

Slide 48 text

More Accurate and Faster 23

Slide 49

Slide 49 text

More Accurate and Faster 23

Slide 50

Slide 50 text

More Accurate and Faster 23

Slide 51

Slide 51 text

Micro-Parameter Inference 24

Slide 52

Slide 52 text

Micro-Parameter Inference 24

Slide 53

Slide 53 text

Micro-Parameter Inference 24

Slide 54

Slide 54 text

Case Studies 1. Housing Market (HM) 2. Opinion Dynamics (OD) 25

Slide 55

Slide 55 text

A B C n l 26

Slide 56

Slide 56 text

A B C n l 26

Slide 57

Slide 57 text

A B C n l 26

Slide 58

Slide 58 text

0 1000 x=0 x=1 x=2 x=3 k=0 x=4 0 1000 k=1 0 1000 k=2 Number of agents Mt 0 100 k=0 0 100 k=1 100 k er of buyers DB t Learned trace Ground truth Latent Observable 0 1000 x=0 x=1 x=2 x=3 k=0 x=4 0 1000 k=1 0 1000 k=2 Number of agents Mt 0 100 k=0 0 100 k=1 100 k= ber of buyers DB t Learned trace Ground truth 0 1000 x=0 x=1 x=2 x=3 k=0 x=4 1000 k=1 f agents Mt Learned trace Ground truth Micro-State Inference

Slide 59

Slide 59 text

0 1000 x=0 x=1 x=2 x=3 k=0 x=4 0 1000 k=1 0 1000 k=2 Number of agents Mt 0 100 k=0 0 100 k=1 100 k er of buyers DB t Learned trace Ground truth Latent Observable 0 1000 x=0 x=1 x=2 x=3 k=0 x=4 0 1000 k=1 0 1000 k=2 Number of agents Mt 0 100 k=0 0 100 k=1 100 k= ber of buyers DB t Learned trace Ground truth 0 1000 x=0 x=1 x=2 x=3 k=0 x=4 1000 k=1 f agents Mt Learned trace Ground truth Micro-State Inference

Slide 60

Slide 60 text

0 1000 x=0 x=1 x=2 x=3 k=0 x=4 0 1000 k=1 0 1000 k=2 Number of agents Mt 0 100 k=0 0 100 k=1 100 k er of buyers DB t Learned trace Ground truth Latent Observable 0 1000 x=0 x=1 x=2 x=3 k=0 x=4 0 1000 k=1 0 1000 k=2 Number of agents Mt 0 100 k=0 0 100 k=1 100 k= ber of buyers DB t Learned trace Ground truth 0 1000 x=0 x=1 x=2 x=3 k=0 x=4 1000 k=1 f agents Mt Learned trace Ground truth Micro-State Inference

Slide 61

Slide 61 text

Forecasting 28

Slide 62

Slide 62 text

2 0 2 n+ = 0.4 n = 0.6 0 2 n+ = 1.2 n = 1.6 nthetic data traces generated in each scenario. Plots represent the opini Opinion Trajectories Parameter values encode different assumptions and 
 determine signi fi cantly different latent trajectories 29

Slide 63

Slide 63 text

Reconstructing synthetic data Estimated x0 True x0 Estimated xt True xt 30

Slide 64

Slide 64 text

Recovering parameters 31 Figure 4: Examples of synthetic data traces generated in each s 0 2 n+ = 0.6 n = 1.2 0 2 n+ = 0.4 n = 0.6 0 2 n+ = 1.2 n = 1.6 0 2 n+ = 0.2 n = 1.6 Figure 4: Examples of synthetic data traces generated in each scenario. Plots represent the opinion trajectories along time.

Slide 65

Slide 65 text

Real data: 32

Slide 66

Slide 66 text

Real data: Number of upvotes on comments 32

Slide 67

Slide 67 text

Real data: Number of upvotes on comments Estimate position of users and subreddits in opinion space 32

Slide 68

Slide 68 text

Real data: Number of upvotes on comments Estimate position of users and subreddits in opinion space Larger estimated distance of user from subreddit fewer upvotes of user on that subreddit → 32

Slide 69

Slide 69 text

Variational Approach 33

Slide 70

Slide 70 text

Likelihoods are hard 34

Slide 71

Slide 71 text

Likelihoods are hard Writing the correct complete data likelihood can be challenging Easy to make mistakes Requires deep understanding of the data generating process 34

Slide 72

Slide 72 text

Likelihoods are hard Writing the correct complete data likelihood can be challenging Easy to make mistakes Requires deep understanding of the data generating process Is there a way to avoid it? Variational approximation! 34

Slide 73

Slide 73 text

Variational Inference 35

Slide 74

Slide 74 text

Variational Inference Bayesian technique to approximate intractable probability integrals Alternative to Monte Carlo sampling (e.g., MCMC, Gibbs sampling) 35

Slide 75

Slide 75 text

Variational Inference Bayesian technique to approximate intractable probability integrals Alternative to Monte Carlo sampling (e.g., MCMC, Gibbs sampling) approximation of the posterior = variational distribution, tractable parametric family Variational parameters optimized by minimizing the KL divergence between and P(Θ ∣ X) ≈ Qϕ (Θ) Qϕ ϕ P Q 35

Slide 76

Slide 76 text

Variational Inference Bayesian technique to approximate intractable probability integrals Alternative to Monte Carlo sampling (e.g., MCMC, Gibbs sampling) approximation of the posterior = variational distribution, tractable parametric family Variational parameters optimized by minimizing the KL divergence between and P(Θ ∣ X) ≈ Qϕ (Θ) Qϕ ϕ P Q Transforms inference into an optimization problem 35

Slide 77

Slide 77 text

No Need to Write Likelihood 36 P( ∣ ) Original ABM Probabilistic Generative ABM Variational Inference Data Approximate posterior macro- and micro-parameters ˜ P(ε ∣ ) ˜ P(r 1 , …, r N ∣ ) t t+1 t+1 t

Slide 78

Slide 78 text

Accurate Macro-Parameter Inference 37 SVI = Stochastic Variational Inference

Slide 79

Slide 79 text

Accurate Micro-Parameter Inference 38

Slide 80

Slide 80 text

Fast 39

Slide 81

Slide 81 text

Model Thinking 40

Slide 82

Slide 82 text

Model Thinking Always think about the Data-Generating Process 40

Slide 83

Slide 83 text

Model Thinking Always think about the Data-Generating Process Model- fi rst thinking as justi fi cation for scienti fi c claims 40

Slide 84

Slide 84 text

Model Thinking Always think about the Data-Generating Process Model- fi rst thinking as justi fi cation for scienti fi c claims Causal (possibly mechanistic) models (e.g., ABMs) 40

Slide 85

Slide 85 text

Model Thinking Always think about the Data-Generating Process Model- fi rst thinking as justi fi cation for scienti fi c claims Causal (possibly mechanistic) models (e.g., ABMs) Use scienti fi cally signi fi cant models 40

Slide 86

Slide 86 text

Conclusions 41

Slide 87

Slide 87 text

Conclusions Fit ABMs as statistical models Rewrite as probabilistic models for the data-generating process 41

Slide 88

Slide 88 text

Conclusions Fit ABMs as statistical models Rewrite as probabilistic models for the data-generating process Learn latent variables of models Forecasting and predictions Model selection 41

Slide 89

Slide 89 text

Conclusions Fit ABMs as statistical models Rewrite as probabilistic models for the data-generating process Learn latent variables of models Forecasting and predictions Model selection Use data to fi gure out which models work (Ptolemy vs Kepler) Bring ABM in line with statistical models (and scienti fi c ones) 41

Slide 90

Slide 90 text

C. Monti, G. De Francisci Morales, F. Bonchi 
 “Learning Opinion Dynamics From Social Traces” 
 KDD 2020 C. Monti, M. Pangallo, G. De Francisci Morales, F. Bonchi 
 “On Learning Agent-Based Models from Data” 
 Scienti fi c Reports 2023 J. Lenti, C. Monti, G. De Francisci Morales 
 “Likelihood-Based Methods Improve Parameter Estimation in Opinion Dynamics Models” 
 WSDM 2024 J. Lenti, F. Silvestri, G. De Francisci Morales 
 “Variational Inference of Parameters in Opinion Dynamics Models” 
 arXiv:2403.05358 2024 42 [email protected] https://gdfm.me @gdfm7