Applying Bayesian networks in the game of Minesweeper

Similar documents
AN APPLICATION IN PROBABILISTIC INFERENCE

Tensor rank-one decomposition of probability tables

Arithmetic circuits of the noisy-or models

Bayesian networks in Mastermind

Belief Update in CLG Bayesian Networks With Lazy Propagation

A Decision Theoretic View on Choosing Heuristics for Discovery of Graphical Models

Fractional Belief Propagation

Abstract. Three Methods and Their Limitations. N-1 Experiments Suffice to Determine the Causal Relations Among N Variables

THE VINE COPULA METHOD FOR REPRESENTING HIGH DIMENSIONAL DEPENDENT DISTRIBUTIONS: APPLICATION TO CONTINUOUS BELIEF NETS

The Necessity of Bounded Treewidth for Efficient Inference in Bayesian Networks

Undirected Graphical Models

Directed Graphical Models or Bayesian Networks

Directed and Undirected Graphical Models

An Empirical Study of Probability Elicitation under Noisy-OR Assumption

On Markov Properties in Evidence Theory

Undirected Graphical Models: Markov Random Fields

p L yi z n m x N n xi

Data Mining 2018 Bayesian Networks (1)

Noisy-or classifier. Laboratory for Intelligent Systems University of Economics, Prague, Czech Republic

2 : Directed GMs: Bayesian Networks

Representing Independence Models with Elementary Triplets

Graphical models and causality: Directed acyclic graphs (DAGs) and conditional (in)dependence

Bayesian Networks: Representation, Variable Elimination

Independencies. Undirected Graphical Models 2: Independencies. Independencies (Markov networks) Independencies (Bayesian Networks)

Respecting Markov Equivalence in Computing Posterior Probabilities of Causal Graphical Features

CS 5522: Artificial Intelligence II

Mixtures of Polynomials in Hybrid Bayesian Networks with Deterministic Variables

Nash Propagation for Loopy Graphical Games

COMP538: Introduction to Bayesian Networks

Introduction to Probabilistic Graphical Models

Y1 Y2 Y3 Y4 Y1 Y2 Y3 Y4 Z1 Z2 Z3 Z4

Local Characterizations of Causal Bayesian Networks

1 : Introduction. 1 Course Overview. 2 Notation. 3 Representing Multivariate Distributions : Probabilistic Graphical Models , Spring 2014

A graph contains a set of nodes (vertices) connected by links (edges or arcs)

Weighting Expert Opinions in Group Decision Making for the Influential Effects between Variables in a Bayesian Network Model

Machine Learning 4771

6.047 / Computational Biology: Genomes, Networks, Evolution Fall 2008

Improving Search-Based Inference in Bayesian Networks

Learning Bayesian Networks Does Not Have to Be NP-Hard

Lecture 15. Probabilistic Models on Graph

Representation of undirected GM. Kayhan Batmanghelich

Influence diagrams for speed profile optimization: computational issues

2 : Directed GMs: Bayesian Networks

Separable and Transitive Graphoids

Chris Bishop s PRML Ch. 8: Graphical Models

Lecture 12: May 09, Decomposable Graphs (continues from last time)

Machine Learning Lecture 14

Graphical models. Sunita Sarawagi IIT Bombay

Bayesian Networks: Construction, Inference, Learning and Causal Interpretation. Volker Tresp Summer 2016

CS281A/Stat241A Lecture 19

Bayes-Ball: The Rational Pastime (for Determining Irrelevance and Requisite Information in Belief Networks and Influence Diagrams)

6.867 Machine learning, lecture 23 (Jaakkola)

Probabilistic Graphical Models

CSL302/612 Artificial Intelligence End-Semester Exam 120 Minutes

4.1 Notation and probability review

Bayesian Networks: Construction, Inference, Learning and Causal Interpretation. Volker Tresp Summer 2014

Dynamic importance sampling in Bayesian networks using factorisation of probability trees

Artificial Intelligence Bayes Nets: Independence

An Introduction to Bayesian Machine Learning

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

4 : Exact Inference: Variable Elimination

Integrating Correlated Bayesian Networks Using Maximum Entropy

Decision-Theoretic Specification of Credal Networks: A Unified Language for Uncertain Modeling with Sets of Bayesian Networks

Modeling High-Dimensional Discrete Data with Multi-Layer Neural Networks

Discrete Bayesian Networks: The Exact Posterior Marginal Distributions

Generalized Loopy 2U: A New Algorithm for Approximate Inference in Credal Networks

Lecture 17: May 29, 2002

Graphical Models and Independence Models

Computational Genomics. Systems biology. Putting it together: Data integration using graphical models

Bayesian belief networks. Inference.

Using Bayesian Network Representations for Effective Sampling from Generative Network Models

What Causality Is (stats for mathematicians)

On Conditional Independence in Evidence Theory

Implementing Machine Reasoning using Bayesian Network in Big Data Analytics

Lecture 4 October 18th

Average-case analysis of a search algorithm for estimating prior and posterior probabilities in Bayesian networks with extreme probabilities

The Parameterized Complexity of Approximate Inference in Bayesian Networks

CS Lecture 4. Markov Random Fields

Published in: Tenth Tbilisi Symposium on Language, Logic and Computation: Gudauri, Georgia, September 2013

Arc Reversals in Hybrid Bayesian Networks with Deterministic Variables. Abstract

Fixed Point Solutions of Belief Propagation

Extraction of NAT Causal Structures Based on Bipartition

Inference in Hybrid Bayesian Networks Using Mixtures of Gaussians

Applications of Bayesian networks

Bayes Nets: Independence

A Stochastic l-calculus

Likelihood Analysis of Gaussian Graphical Models

Bayesian Networks in Reliability: The Good, the Bad, and the Ugly

Bayesian Network Inference Using Marginal Trees

Markovian Combination of Decomposable Model Structures: MCMoSt

Introduction to Graphical Models. Srikumar Ramalingam School of Computing University of Utah

Learning in Bayesian Networks

Complexity of probabilistic reasoning in directed-path singly-connected Bayes networks

Using Bayesian Network Representations for Effective Sampling from Generative Network Models

Protein Complex Identification by Supervised Graph Clustering

Towards an extension of the PC algorithm to local context-specific independencies detection

Quantifying uncertainty & Bayesian networks

Probabilistic Graphical Models (I)

STA 4273H: Statistical Machine Learning

Directed acyclic graphs and the use of linear mixed models

Transcription:

Applying Bayesian networks in the game of Minesweeper Marta Vomlelová Faculty of Mathematics and Physics Charles University in Prague http://kti.mff.cuni.cz/~marta/ Jiří Vomlel Institute of Information Theory and Automation of the AS CR Academy of Sciences of the Czech Republic http://www.utia.cas.cz/vomlel Abstract We use the computer game of Minesweeper to illustrate few modeling tricks utilized when applying Bayesian network (BN) models in real applications. Among others, we apply rank-one decomposition (ROD) to conditional probability tables (CPTs) representing addition. Typically, this transformation helps to reduce the computational complexity of probabilistic inference with the BN model. However, in this paper we will see that (except for the total sum node) when ROD is applied to the whole CPT it does not bring any savings for the BN model of Minesweeper. Actually, in order to gain from ROD we need minimal rank-one decompositions of CPTs when the state of the dependent variable is observed. But this is not known and it is a topic for our future research. 1 Introduction The game of Minesweeper is a one-player grid game. It is bundled with several computer operating systems, e.g., with Windows or with the KDE desktop environment. The game starts with a grid of n m blank fields. During the game the player clicks on different fields. If the player clicks on a field containing a mine then the game is over. Otherwise the player gets information on how many fields in the neighborhood of the selected field contain a mine. The goal of the game is to discover all mines without clicking on any of them. In Figure 1 we present two screenshots from the game. For more information on Minesweeper see, e.g., Wikipedia [12]. J. Vomlel was supported by grants number 1M0572 and 2C06019 (MŠMT ICC/08/E010 (Eurocores LogICCC), and 201/09/1891 (GA ČR). ČR),

2 M. VOMLELOVÁ, J. VOMLEL Figure 1: Two screenshots from the game of Minesweeper. The screenshot on the right hand side is taken after the player stepped on a mine. It shows the actual position of mines. Bayesian networks (BNs) [8, 5, 4] are probabilistic graphical models that use acyclic directed graphs (DAGs) G = (V, E) to encode conditional independence relations among random variables associated with the nodes of the graph. The quantitative part of a BN are conditional probability tables (CPTs) P (X i pa(x i )), i V that define together the joint probability distribution represented by the BN as the product P (X i, i V ) = i V P (X i pa(x i )). (1) In many real applications the CPTs have a special local structure that can be further exploited to gain even more efficient inference. Examples of such CPTs are CPTs representing functional (i.e. deterministic) dependence or CPTs representing noisy functional dependence: noisy-or, noisy-and, noisy-max, noisy-min, etc. A method that allows to use the local structure within standard inference techniques (such as [6, 3]) is the rank-one decomposition of CPTs [2, 11, 10]. A typical task solved by BNs is the computation of conditional probabilities given an evidence inserted in the model. In the game of Minesweeper the player is interested in the probabilities of a mine at all fields of the grid given the observations she has made. The reader may ask why for solving this deterministic game we use BNs instead of the standard techniques of constraint processing. The reason is that we aim at more general problems that correspond to real applications. An advantage of BN models is that they can also represent uncertainty in the mod-

Applying Bayesian networks in Minesweeper 3 eled domain. This can, for example, model situations when the observations or measurements are noisy. In the game of Minesweeper the observations are the presence or absence of mines. For example, we can extend the BN model of Minesweeper so that the influence of mines from the neighboring fields on the observed count is noisy (i.e. non-deterministic). 2 A Bayesian network model for Minesweeper Assume a game of Minesweeper on a n m grid. The BN model of Minesweeper contains two variables for each field (i, j) {1,..., n} {1,..., m} on the game grid. The variables in the first set X = {X 1,1,..., X n,m } are binary and correspond to the (originally unknown) state of each field of the game grid. They have state 1 if there is a mine on this field and state 0 otherwise. The variables in the second set Y = {Y 1,1,..., Y n,m } are observations made during the game. Each variables Y i,j has as its parents 1 from X that are on the neighboring positions in the grid, i.e. { } Xk,l X : k {i 1, i, i + 1}, l {j 1, j, j + 1}, pa(y i,j ) =. (k, l) (i, j), 1 k n, 1 l m The variables from Y provide the number of neighbors with a mine. Therefore their number of states is the number of their parents plus one. Their CPTs are defined by the addition function for all combinations of states x of pa(y i,j ) and states y of Y i,j as P (Y i,j = y pa(y i,j ) = x) = { 1 if y = x x x 0 otherwise. Whenever an observation of Y i,j is made the variable X i,j can be removed from the BN since its state is known. If its state is 1 the game is over, otherwise it is 0 and the player cannot click on the same field again. When evidence from an observation is distributed to its neighbors also the node corresponding to the observation can be removed from the DAG. In addition, we need not include into the BN model observations Y i,j that were not observed yet. In order to compute a marginal probability of a variable X i,j we sum the probability values of the joint probability distribution over all combinations of states of remaining variables. It holds for all combinations of states x of pa(y i,j ) that P (Y k,l = y pa(y i,j ) = x) = 1 y therefore the CPT of Y i,j can be omitted from the joint probability distribution represented by the BN. 1 Since there is a one-to-one mapping between nodes of the DAG of a BN and the variables of BN we will use the graph notion also when speaking about random variables. (2)

4 M. VOMLELOVÁ, J. VOMLEL The above considerations implies that in every moment of the game we will have at most one node for each field (i, j) of the grid. Each node of a graph corresponding to a grid position (i, j) will be indexed by a unique number g = j + (i 1) m. 3 A standard approach for inference in BNs In a standard inference technique such as [6] or [3] the DAG of the BN is transformed to an undirected graph so that each subgraph of the DAG of a BN induced by set variable Y and its parents, say {X 1,..., X m }, is replaced by the complete undirected graph on {Y, X 1,..., X m }. This step is called moralization. See Figure 2. X 1 X 2 X m X 1 X 2 X m Y Y Figure 2: The original subgraph of the DAG induced by {Y, X 1,..., X m } and its counterpart after moralization. The second graph transformation is triangulation of the moral graph. An undirected graph is triangulated if it does not contain an induced subgraph that is a cycle without a chord of a length of at least four. A set of nodes C V of a graph G = (V, E) is a clique if it induces a complete subgraph of G and it is not a subset of the set of nodes in any larger complete subgraph of G. An important parameter for the inference efficiency is the total table size after triangulation. The table size of a clique C in an undirected graph is i C X i, where X i is the number of states of a variable X i corresponding to a node i. The total table size (tts) of a triangulation is defined as the sum of table sizes for all cliques of the triangulated graph. Therefore, it is desirable to find a triangulation of the original graph having the total table size as small as possible. Since this problem is known to be NP-hard different heuristics are often used. In this paper we use minweight heuristics [7] (called H1 in [1]), which, in case of binary variables, is equivalent to the minwidth heuristics [9]. See Figure 3 for an example of the triangulated moral graph for the standard method after twenty observations in the game of Minesweeper on a 10 10 grid. During the triangulation we added five edges only. This is a typical behavior unless we get long cycles in the moral graph.

Applying Bayesian networks in Minesweeper 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Figure 3: An example of the triangulated moral graph of the BN after twenty observations in the game of Minesweeper on a 10 10 grid for the standard method. 4 Rank-one decomposition of tables representing addition In the BN model of Minesweeper the CPTs have a special local structure (they correspond to addition). Therefore, we can transform the CPTs using tensor rank-one decomposition (ROD) [2, 11, 10]. A minimal ROD of CPTs representing addition was proposed in [10]. Assume that X 1,..., X m are parents of Y, and CPT P (Y X 1,..., X m ) represents addition and is defined as in formula (2). Then using Theorem 3 from [10] we can write P (Y = y X 1 = x 1,..., X m = x m ) = where for b = 0,..., m m m ξ b (y) ϕ i,b (x i ), (3) ξ b are real valued functions defined for states {0, 1,..., m} of Y and for i = 1,..., m ϕ i,b are real valued functions defined for states {0, 1} of X i. This decomposition is called rank-one decomposition (ROD) of addition. In graphical terms it means that each subgraph of the DAG of a BN induced by set b=0 i=1

6 M. VOMLELOVÁ, J. VOMLEL {Y, X 1,..., X m } is replaced by an undirected graph containing one additional variable B that is connected by an undirected edge with all variables from {Y, X 1,..., X m }, see Figure 4. The minimum number of states of B that allows to write a table in the form of equation (3) is called the rank of the table. In case of CPT for addition the rank is m + 1, which means we cannot do this decomposition with less than m + 1 states of B. X 1 X 2 X m X 1 X 2 X m B Y Y Figure 4: The original subgraph of the DAG induced by {Y, X 1,..., X m } and its counterpart after ROD. In our current approach we use only a part of table ξ b corresponding to the observed state y. This implies we can eliminate node corresponding to the variable Y from the graph, so that there is only one node in the graph (i.e, node corresponding to varible B) for the corresponding field of the grid. The second graph transformation is again triangulation, but this time applied to the undirected graph after ROD. See Figure 5 for an example of the graph for the model after ROD and after twenty observations in the game of Minesweeper on a 10 10 grid. Note, that while for variables corresponding to unobserved fields of the game grid the number of states is two, for the variables corresponding to the observed fields of the game grid the number of states is typically higher (up to eight states) in the model after ROD. However, there are fewer edges than in the standard approach but during triangulation we added 73 edges, which is much more than for the triangulated moral graph produced by the standard approach. For the triangulated graph of the graph from Figure 5 see Figure 6. During the computations with the model after ROD we decrease the number of states of observed nodes Y i,j and of corresponding B i,j by one for each observed parent and modify the CPT accordingly. At the same time we delete edges from parents with evidence to observed nodes. The node for the total number of mines in the game Typically, in the game of Minesweeper the total number of mines z is known in advance. If we want to exploit this information we need to extend the model by one auxiliary node Z that will impose this constraint. This node has the

Applying Bayesian networks in Minesweeper 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Figure 5: An example of the graph of the BN after ROD and after the same twenty observations as in Figure 3 in the game of Minesweeper on a 10 10 grid. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Figure 6: Triangulated graph of the graph from Figure 5.

8 M. VOMLELOVÁ, J. VOMLEL number of states equal to the total number of fields on the game grid plus one, which is n m + 1. It has all binary nodes from the set X = {X 1,1,..., X n,m } as its parents and we enter the evidence Z = z in the BN model. If we used the standard approach described in Section 3 for node Z we would get a complete graph over all nodes from X. This would make the BN model of the game intractable for larger values of n m. However, since we use ROD for node Z we connect it with all nodes from X but we do not require nodes from X to be pairwise connected. The total table size of the BN with node Z after ROD is n m larger than the total table size of the BN without node Z. Since this is a constant for a fixed grid we do all experiments without the auxiliary Z node. 5 Experiments We performed the experiments with the game of Minesweeper for two different grid sizes 10 10 and 20 20. For simplicity we used a random selection of fields to be played and we assumed we never hit the mine during the game. Of course, this is an unrealistic assumption, but since we are interested in the complexity of inference in the BN models it suffices to get an upper bound on the worst case computational complexity. For the results of experiments see Figures 7 and 8, where each value is the average over twenty different games. log10(tts) 1 2 3 4 rank one decomposition the standard technique 0 20 40 60 80 100 the number of observations Figure 7: The development of the total table size (tts) for the ROD and standard methods during the game of Minesweeper on the 10 10 grid. From the results of experiments we can see that the ROD as it is currently applied does not bring any advantages of the standard method. But, recall that

Applying Bayesian networks in Minesweeper 9 log10(tts) 0 2 4 6 8 0 100 200 300 400 the number of observations rank one decomposition the standard technique Figure 8: The development of the total table size (tts) for the ROD and standard methods during the game of Minesweeper on the 20 20 grid. ROD is very useful for the auxiliary node Z, which stands for the total number of mines. However, the way we apply ROD in Section 4 is not the most efficient utilization of ROD. Given a state y of Y we could find more compact factorizations of P (Y = y X 1,..., X m ). For example in two extreme cases, if y = m or y = 0 we know that the state of all X i, i = 1,..., m is 1 or 0, respectively. Consequently, the rank of P (Y = y X 1,..., X m ) for y = 0, m is one. However, we do not know the rank and minimal rank-one decompositions of P (Y = y X 1,..., X m ) for other values of y. This is a topic for our future research. We conjecture that for most values of y the rank of P (Y = y X 1,..., X m ) will be lower than m + 1, which will lessen the total table size for the ROD method. 6 Conclusions In this paper we report experiments with Bayesian networks build for the game of Minesweeper. During the construction of BN we use several modeling tricks that allow more efficient inference in the BNs for this game. We compare the computational complexity of the inference in the BN model for the standard approach and after the rank-one decomposition. We observed that there are no significant differences in the computational complexity of the two approaches. Probably, the most important theoretical observation is that we miss minimal rank-one decompositions for the CPTs with a local structure when the state of the child variable is observed. We believe this would help to reduce the

10 M. VOMLELOVÁ, J. VOMLEL computational complexity with the BN model after ROD. This is an issue for our future research. References [1] A. Cano and S. Moral. Heuristic algorithms for the triangulation of graphs. In B. Bouchon-Meunier, R. R. Yager, and L. A. Zadeh, editors, Advances in Intelligent Computing IPMU 94: Selected Papers, pages 98 107. Springer, 1994. [2] F. J. Díez and S. F. Galán. An efficient factorization for the noisy MAX. International Journal of Intelligent Systems, 18:165 177, 2003. [3] F. V. Jensen, S. L. Lauritzen, and K. G. Olesen. Bayesian updating in recursive graphical models by local computation. Computational Statistics Quarterly, 4:269 282, 1990. [4] Finn Verner Jensen. Bayesian networks and decision graphs. Statistics for Engineering and Information Science. Springer Verlag, New York, Berlin, Heidelberg, 2001. [5] S. L. Lauritzen. Graphical Models. Clarendon Press, Oxford, 1996. [6] S. L. Lauritzen and D. J. Spiegelhalter. Local computations with probabilities on graphical structures and their application to expert systems (with discussion). Journal of the Royal Statistical Society, Series B, 50:157 224, 1988. [7] S. M. Olmsted. On representing and solving decision problems. PhD thesis, Stanford University, 1983. [8] Judea Pearl. Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference. Morgan Kaufman, San Mateo, CA, 1988. [9] D. J. Rose. A graph-theoretic study of the numerical solution of sparse positive definite systems of linear equations. Graph Theory and Computing, pages 183 217, 1972. [10] P. Savicky and J. Vomlel. Exploiting tensor rank-one decomposition in probabilistic inference. Kybernetika, 43(5):747 764, 2007. [11] J. Vomlel. Exploiting functional dependence in Bayesian network inference. In Proceedings of the 18th Conference on Uncertainty in AI (UAI), pages 528 535. Morgan Kaufmann Publishers, 2002. [12] Wikipedia. Minesweeper (computer game). http://en.wikipedia.org/wiki/minesweeper (computer game), 2009.