a3ba3885e1f2aaab22c7c013b586c23960d36617
[ker2014-2.git] / report / ass2-2.tex
1 \chapter{Visual representations and reasoning}
2 We chose pizzas for our domain, as everybody likes pizzas. We chose to have six different pizzas. As all pizzas have tomato sauce and cheese, we didn't take those into account. Below we listed all the pizzas and their ingredients.
3 \begin{itemize}
4 \item Margherita; basilicum
5 \item Hawaii; ham, pineapple and basilicum
6 \item Salami; salami and basilicum
7 \item Funghi; mushrooms and ham
8 \item Pepperoni; salami and jalape\~nos
9 \end{itemize}
10
11 We are able to observe different kind of shapes; circles, double circles (like tires or olives in our case), squares and blobs.
12
13 Our style of reasoning that we employed is deductive.
14 \iffalse
15 TODO
16 In a more structured way, you are required to describe clearly and fully:
17 • The domain and the individual images
18 • The representation of observations, assumables and the causal theory between them in AILog
19 • The style of reasoning employed (abductive, deductive) and what considerations have played
20 a role
21 • The queries used to infer information about individual images
22 • The results of the queries and reflections on their effectiveness and intuitions behind them
23 • General reflections on your model, how appropriate it is for this domain, how effective it is
24 and how would need to proceed if one would like to extend it to large datasets or realistic,
25 real-time operation.
26
27
28 \fi
29 \section{Domain representation}
30 Translating the domain specification to AILog results in the following AILog
31 code:
32 \inputminted[linenos,fontsize=\footnotesize]{prolog}{./src/pizza.ail}
33
34 \section{Queries}
35 \subsection{Initial probabilities}
36 Chances for shapes to be present are visible in Table~\ref{chances} and from
37 that we can calculate all the initial probabilites for all the shapes for
38 example with the following queries:
39 \begin{minted}[fontsize=\footnotesize]{prolog}
40 ailog: predict circle.
41 Answer: P(circle|Obs)=0.01.
42 [ok,more,explanations,worlds,help]: ok.
43 ailog: observe circle.
44 Answer: P(circle|Obs)=0.01.
45 [ok,more,explanations,worlds,help]: ok.
46 ailog: predict circlePresent.
47 Answer: P(circlePresent|Obs)=0.95.
48 [ok,more,explanations,worlds,help]: ok.
49 \end{minted}
50 \begin{table}
51 \label{chances}
52 \begin{tabular}{|l|ll|}
53 \hline
54 & Observed\\
55 Present & T & F\\
56 \hline
57 T & $0.95$ & $0.01$\\
58 F & $0.05$ & $0.99$\\
59 \hline
60 \end{tabular}
61 \end{table}
62
63 \subsection{Querying probabilites for pizzas}
64 Since the chance of a false positive on a shape is so low the initial
65 probabilities for pizza types are very low. When certain shapes that belong to
66 a certain type of pizza occur the probability improves a lot. We can show this
67 by showing the probabilites of a pepperoni pizza before, during and after
68 observing the ingredients with the following queries:
69 \begin{minted}[fontsize=\footnotesize]{prolog}
70 ailog: predict p_pepperoni.
71 Answer: P(p_pepperoni|Obs)=0.0019.
72 [ok,more,explanations,worlds,help]: ok.
73 ailog: observe circle.
74 Answer: P(circle|Obs)=1.0.
75 [ok,more,explanations,worlds,help]: ok.
76 ailog: predict p_pepperoni.
77 Answer: P(p_pepperoni|Obs)=0.0019.
78 [ok,more,explanations,worlds,help]: ok.
79 ailog: observe doublecircle.
80 Answer: P(doublecircle|Obs)=0.01.
81 [ok,more,explanations,worlds,help]: ok.
82 ailog: predict p_pepperoni.
83 Answer: P(p_pepperoni|Obs)=0.19.
84 [ok,more,explanations,worlds,help]: ok.
85 \end{minted}
86
87 \subsection{Finding out which pizza is the most likely to be present on the
88 image}
89 We do not only want to know what the probability for a specific pizza is but
90 also the most likely pizza so that we can give an educated guess about the
91 pizza type present on the image processed. This can be done with the following
92 queries using the \texttt{whatpizza} predicate. The \texttt{whatpizza}
93 predicate is a predicate that is a disjunction of all pizza types. In the
94 following queries, when the possible explanations, are given we can query for
95 every possible explanations to find out how the most likely world looks like:
96 \begin{minted}[fontsize=\footnotesize]{prolog}
97 ailog: predict whatpizza.
98 Answer: P(whatpizza|Obs)=[0.19251740120000002,0.19278577620000004].
99 [ok,more,explanations,worlds,help]: explanations.
100 0: ass([],[basilicumcircle,circle,doublecircle,doublecircleOlives,noObserveError],9.5e-6)
101 1: ass([],[circle,doublecircle,doublecircleJalapenos,noObserveError,salamicircle],1.9e-5)
102 2: ass([],[blob,blobHam,blobMushrooms,circle,funghiham,noObserveError],3.3249999999999995e-6)
103 3: ass([],[basilicumcircle,circle,noObserveError,salamibasilicum,salamicircle],7.6e-5)
104 4: ass([],[basilicumcircle,circle,noObserveError],0.0019)
105 5: ass([],[blob,blobBasilicum,circle,noObserveError],9.5e-6)
106 [ok,more,how i,help]: how 4.
107 whatpizza <-
108 1: p_margarita
109 How? [Number,up,retry,ok,prompt,help]: up.
110 Answer: P(whatpizza|Obs)=[0.19251740120000002,0.19278577620000004].
111 [ok,more,explanations,worlds,help]: ok.
112 ailog: observe blob.
113 Answer: P(blob|Obs)=0.01.
114 [ok,more,explanations,worlds,help]: ok.
115 ailog: predict whatpizza.
116 Answer: P(whatpizza|Obs)=[0.28994000000000003,0.33126500000000003].
117 [ok,more,explanations,worlds,help]: explanations.
118 0: ass([],[blob,blobHam,blobMushrooms,circle,funghiham,noObserveError],3.3249999999999995e-6)
119 1: ass([],[basilicumcircle,blob,circle,noObserveError],1.9e-5)
120 2: ass([],[blob,blobBasilicum,circle,noObserveError],9.5e-6)
121 [ok,more,how i,help]: how 0.
122 whatpizza <-
123 1: p_funghi
124 How? [Number,up,retry,ok,prompt,help]: ok.
125 \end{minted}
126
127 \section{Reflections}