Documente Academic
Documente Profesional
Documente Cultură
Dorel Lucanu
PA 2016/2017
Plan
DEX 2009
probabilist: 2. Adj. Care foloses, te calculul probabilităt, ilor.
probabilistic: adj. 1. Cu caracter de probabilitate. 2. Referitor la
teoria probabilităt, ilor, la calculul probabilităt, ilor.
Evidence
• Tall center forward
• Inexperienced goalie
• Strong wind
Inference algorithm
Query
• Will a goal be scored?
Answer
5. The system returns the • Yes: 20%; No: 80%
3. You tell the system
answer as probabilities. what outcome you
want to know.
4. The system uses the inference
algorithm to predict the outcome.
Figure 1.2 How a probabilistic reasoning system predicts the outcome of a corner kick
Termeni fundamentali
The inference
algorithm uses Evidence
the model to
answer queries, Inference algorithm
given evidence. Queries
Probabilistic
reasoning system
Evidence
• Preconditions
Corner-kick model
° Tall center forward
° Inexperienced goalie
° Strong wind
• Outcome
° A goal was scored
The inference Inference algorithm
algorithm reasons Query
about the query, • How good is the goalie?
given all known
preconditions
and outcomes.
Answer
• Poor: 50%; Average: 30%;
Good: 20% The query is a possible
cause of the outcome.
Figure 1.4 By altering the query and evidence, the system can now infer why a goal was
scored.
D. Lucanu LPP: Introducere
feature of probabilistic reasoning, whichOutline
I’ll repeat throughout the book: the
directionCeofeste Programarea
reasoning probabilistăfollow
doesn’t necessarily (PP)? the direction of the model.
O scurtă introducere ı̂n Figaro
■ Learn from past events to better predict future events. Now fast-forward another 10
minutes. The same team has won another corner kick. Everything is similar to
before in this new situation—tall center forward, inexperienced goalie—but
Luând ı̂n considerare evident, a ultimului corner, sistemul de
now the wind has died down. Using probabilistic reasoning, you can use what
happened in the previous kick to help you predict what will happen on the next
rat, ionament probabilist poate prezice mai bine ce se va
kick. Figure 1.5 shows how to do this. The evidence includes all evidence from
last time (making a note that it was from last time), as well as the new informa-
ı̂ntâmpla la următorul corner (fig. 1.5, p. 9)
tion about the current situation. In answering the query about whether a goal
Evidence
Probabilistic • Previous corner kick
reasoning system ° Tall center forward
° Inexperienced goalie
Corner-kick model ° Strong wind
° A goal was scored
The inference • Current corner kick
algorithm reasons ° Tall center forward
about the previous ° Inexperienced goalie
situations to infer ° Weak wind
factors (like the skill level Inference algorithm
of the goalie) that hold Query
in the new situation. • Will a goal be scored
this time?
Figure 1.5 By taking into account evidence from the outcome of the last corner kick, the
probabilistic reasoning system can produce a better prediction
D. Lucanu of the next LPP:
corner Introducere
kick.
Outline
Ce este Programarea probabilistă (PP)?
O scurtă introducere ı̂n Figaro
Învăt, area unui model probabilist (mai bun) (fig. 1.6, p.11)
What is probabilistic programming? 11
Original corner-
kick model Past experience 1
• Tall center forward
• Inexperienced goalie
• Strong wind
Past experience 2
Past experience 3
The learning algorithm Learning algorithm Etc.
uses the original model
and the data to produce
a new model. Before
The evidence is provided
After about a new situation.
New corner-
kick model
New evidence
• Tall center forward
• Inexperienced goalie
• Weak wind
The inference algorithm Inference algorithm
uses the new model to
answer queries about Query
the new situation. • Will a goal be scored
this time?
Answer
• Yes: 15%; No: 85%
Figure 1.6 You can use a learning algorithm to learn a new model based on a set of experiences.
This new model can then be used for future inferences.
D. Lucanu LPP: Introducere
ure 1.3 to highlight the differences between the two systems. The main change is that
Outline
Ce este Programarea probabilistă (PP)?
models are expressed as programs
O scurtă introducereinı̂naFigaro
programming language rather than as a
mathematical construct like a Bayesian network. As a result of this change, evidence,
queries, and answers all apply to variables in the program. Evidence might specify par-
Relatia dintre sistemele de rationament probabilist s, i
ticular
, values for program variables, queries ask ,for the values of program variables,
and answers are probabilities of different values of the query variables. In addition, a
sistemele de programare probabilistă (fig. 1.6, p.12)
probabilistic programming system typically comes with a suite of inference algorithms.
These algorithms apply to programs written in the language.
The probabilistic
programming system Evidence
provides a suite of
Inference algorithm
inference algorithms
that apply to models Queries
written in the language.
Figure 1.7 A probabilistic programming system is a probabilistic reasoning system that uses a
programming language to represent probabilistic models.
No goal
Near miss
Figure 1.8 A probabilistic program defines a process of randomly generating outputs, given inputs.
D. Lucanu LPP: Introducere
Outline
Ce este Programarea probabilistă (PP)?
O scurtă introducere ı̂n Figaro
De ce PP?
I expresivitate
”Probabilistic reasoning + Turing-complete = probabilistic
programming”
I rat, ionament probabilist mai bun
I simulare mai bună (execut, ie + analiză)
Plan
Inference is invoked by
a Scala function call.
Answers The queries request information
The answers provide the about the values of elements.
probabilities of different
values of elements.
D. Lucanu LPP: Introducere
Outline
Ce este Programarea probabilistă (PP)?
O scurtă introducere ı̂n Figaro
De ce Scala
Today’s weather
Sunny 0.2
Today’s greeting
Tomorrow’s weather
Tomorrow’s greeting
p. 22-23
object HelloWorld {
val sunnyToday = Flip(0.2)
val greetingToday = If(sunnyToday,
Select(0.6 -> "Hello, world!", 0.4 -> "Howdy, universe!"),
Select(0.2 -> "Hello, world!", 0.8 -> "Oh no, not again")) Define the
val sunnyTomorrow = If(sunnyToday, Flip(0.8), Flip(0.05)) model
val greetingTomorrow = If(sunnyTomorrow,
Select(0.6 -> "Hello, world!", 0.4 -> "Howdy, universe!"),
Select(0.2 -> "Hello, world!", 0.8 -> "Oh no, not again"))
def predict() {
val result = VariableElimination.probability(greetingToday, Predict
today’s
"Hello, world!")
greeting using
println("Today’s greeting is \"Hello, world!\" " +
an inference
"with probability " + result + ".")
algorithm
}
def learnAndPredict() {
greetingToday.observe("Hello, world!") Learn from
val result = VariableElimination.probability(greetingTomorrow, observing that
"Hello, world!") today’s greeting is
println("If today's greeting is \"Hello, world!\", " +
“Hello, world!” to
predict tomorrow’s
"tomorrow's greeting will be \"Hello, world!\" " +
greeting using an
"with probability " + result + ".")
inference algorithm
}
I’ll wait until the next chapter to explain this code in detail. For now, I want to point
out that it solves the two problems with the Java code. First, the model definition
describes exactly the structure of the model, in correspondence with table 1.1. You
define four variables: sunnyToday, greetingToday
D. Lucanu , LPP: Introducere , and greeting-
sunnyTomorrow