| updateHist | R Documentation |
The StudentRecord object can track the history of
zero or more Pnode in the student model
(sm). The history is a data frame with columns
corresponding to the states of the variables and the rows
corresponding to the EvidenceSets absorbed into
the student record. The function updateHist add a new row to
each history corresponding to the evidence set. The function
baselineHist creates the initial row.
updateHist(eng, rec, evidMess, debug = 0)
baselineHist(eng, rec)
eng |
The |
rec |
The |
evidMess |
The |
debug |
An integer flag. If bigger than 1, then a call to
|
A history tracks a single node in the student model as it changes in response to the incomming evidence sets. The history for a node is data frame with columns representing variable states and rows representing evidence sets (evidence from different scoring windows or tasks).
The function baselineHist is called as part of
setupDefaultSR. This initializes a history data frame
for each node in the histNodes field of the
BNEngine. It inserts a first row, which is
always given the name “*Baseline*”. The values in the first
row are the marginal distribution of those nodes
(PnodeMargin).
The function updateHist adds row to each history table. The
name of the row corresponds to the context field
of the EvidenceSet. The value is the curent
marginal distribution for the history nodes.
The function history retrieves the history. The functions
woeHist and woeBal in
the CPTtools-package describe possible
applications for the history function.
Both functions return the modified StudentRecord
With the Netica implementation, the student model needs to be compiled
(PnetCompile(sm(rec))) before the
baselineHist function is run.
This is probably true of updateHist as well, but
updateSM recompiles the network.
Russell Almond
Madigan, Mosurski and Almond, (1997). Graphical explanation in belief networks. Journal of Computational and Graphical Statistics, 6, 160–181.
Almond, Kim, Shute and Ventura (2013). Debugging the evidence chain. Proceeings of the 2013 UAI Application Workshops (UAI2013AW). 1–10. CEUR workshop proceedings, vol 1024. http://ceur-ws.org/Vol-1024/paper-01.pdf
Classes:
BNEngine, EvidenceSet
StudentRecord
Functions in EABN:
accumulateEvidence, updateStats,
updateSM, history
Peanut Functions:
PnodeMargin
CPTtools Functions
woeHist, woeBal
## Requires PNetica
library(PNetica) ## Must load to setup Netica DLL
app <- "ecd://epls.coe.fsu.edu/EITest"
sess <- RNetica::NeticaSession()
RNetica::startSession(sess)
config.dir <- file.path(library(help="Peanut")$path, "auxdata")
net.dir <- file.path(library(help="PNetica")$path,"testnets")
netman <- read.csv(file.path(config.dir, "Mini-PP-Nets.csv"),
row.names=1, stringsAsFactors=FALSE)
stattab <- read.csv(file.path(config.dir, "Mini-PP-Statistics.csv"),
as.is=TRUE)
Nethouse <- PNetica::BNWarehouse(netman,session=sess,
address=net.dir)
cl <- new("CaptureListener")
listeners <- list("cl"=cl)
ls <- ListenerSet(sender= paste("EAEngine[",app,"]"),
db=MongoDB(noMongo=TRUE), listeners=listeners)
eng <- newBNEngineNDB(app=app,warehouse=Nethouse,
listenerSet=ls,manifest=netman,
profModel="miniPP_CM",
histNodes="Physics",
statmat=stattab,
activeTest="EAActive.txt")
## Standard initialization methods.
loadManifest(eng,netman)
eng$setHistNodes(character())
configStats(eng,stattab)
setupDefaultSR(eng)
sr1 <- getRecordForUser(eng,"S1")
history(sr1,"Physics")
stopifnot(is.null(history(sr1,"Physics")))
## Now set up history.
eng$setHistNodes("Physics")
PnetCompile(sm(sr1))
sr1 <- baselineHist(eng,sr1)
history(sr1,"Physics")
stopifnot(nrow(history(sr1,"Physics"))==1L)
e1 <- EvidenceSet(uid="S1",app="Test",context="PPcompEM",
obs=list("CompensatoryObs"="Right"))
sr1 <- updateSM(eng,sr1,e1)
sr1 <- updateHist(eng,sr1,e1)
e2 <- EvidenceSet(uid="S1",app="Test",context="PPconjEM",
obs=list("ConjunctiveObs"="Wrong"))
sr1 <- updateSM(eng,sr1,e2)
sr1 <- updateHist(eng,sr1,e2)
history(sr1,"Physics")
stopifnot(nrow(history(sr1,"Physcis"))==3L)
woeHist(history(sr1,"Physics"),pos="High",neg=c("Medium","Low"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.