FadeCPT {RNetica} | R Documentation |
This function fades a Netica conditional probability table associated with a node (that is, it makes it closer to uniform). This is used when learning conditional probabilities over time, so that newer observations will have more weight than older ones.
FadeCPT(node, degree = 0.2)
node |
A |
degree |
A scalar value between 0 and 1 providing the amount of fading to be done. A degree of 1 produces a uniform distribution and a degree of 0 leaves the CPT unchanged. |
This is essentially an exponential filter, with 1-degree
as the
retained weight. Calling it once with degree of 1-d and again
with degree 1-f is equivalent to calling it once with degree
1-df.
If prob
are the current probabilities associated with a row of
the CPT, and expr
is the current experience, then the new
probabilities will be newprob = normalize(prob* exper *
(1-degree) + degree)
, and the new experience will be the
normalization constant.
This function is often used together with LearnFindings
to down weight old cases when the conditional probabilities are thought
to be changing slowly over time.
This function returns the node object.
Frequently the degree is made time dependent. If dt
is the
time elapsed since the last observation, the degree is frequently an
expression like 1-expt(R,dt)
, where R
is a constant less
than 1 which controls how quickly the CPT is faded.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: FadeCPTable_bn()
NodeExperience
, NodeProbs
,
LearnFindings
sess <- NeticaSession() startSession(sess) aaa <- CreateNetwork("AAA", session=sess) A <- NewDiscreteNode(aaa,paste("A",1:5,sep=""),c("true","false")) for( i in 1:length(A)) { NodeProbs(A[[i]]) <- c(.8,.2) NodeExperience(A[[i]]) <- 10 } deg <- .2 expected <- NodeProbs(A[[1]])*10*(1-deg)+deg FadeCPT(A[[1]], deg) stopifnot( sum(abs(NodeProbs(A[[1]])-expected/sum(expected))) < .0001, abs(NodeExperience(A[[1]])-sum(expected)) < .001 ) ## Fading by deg then by deg2 is the same as fading by ## 1-(1-deg)*(1-deg2) deg2 <- .3 FadeCPT(A[[1]],deg2) FadeCPT(A[[2]], 1-(1-deg)*(1-deg2)) stopifnot ( sum(abs(NodeProbs(A[[1]]) - NodeProbs(A[[2]]))) < .0001 ) ## Fade by two time units. lambda <- .8 FadeCPT(A[[3]],1-lambda^2) ## Special cases FadeCPT(A[[4]],0) FadeCPT(A[[5]],1) stopifnot ( sum(abs(NodeProbs(A[[4]]) -c(.8,.2))) < .0001, sum(abs(NodeProbs(A[[5]]) -c(.5,.5))) < .0001 ) DeleteNetwork(aaa) stopSession(sess)