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