accumulateEvidence | R Documentation |
The function accumulateEvidence
combines the evidence in the
EvidenceSet
with the exiting beliefs in the
StudentRecord
, updating the student record. The
function handleEvidence
is a wrapper around this which takes
care of finding and updating the evidence sets.
accumulateEvidence(eng, rec, evidMess, debug = 0)
handleEvidence(eng, evidMess, srser = NULL, debug = 0)
eng |
The |
rec |
The |
srser |
A serialized version of the student record for the no-database version of the model. |
evidMess |
An |
debug |
An integer flag. If greater than 1, then
|
The function accumulateEvidence
performs the following steps:
Update the student record to associate it with the new
evidence (updateRecord
).
Update the student model with the new evidence
(updateSM
).
Update the statistics for the new student model
(updateStats
).
Update the history for the new evidence
(updateHist
).
Announce the availablity of new statistics
(announceStats
).
Save the updated student record (saveSR
).
The function handleEvidence
is a wrapper around
accumulateEvidence
which finds the student record. Note for
BNEngineNDB
, it is expected that the student record will
be passed in as a serialized object (see
getRecordForUser
). It performs the following steps:
Fetch the student record for the uid
associated with the evidence set
(getRecordForUser
).
Mark the evidence as belonging to this student record
(logEvidence
).
Update the record by calling accumulateEvidence
.
Mark the evidence as processed (markAsProcessed
).
If an error is encountered, then the error message is added to the evidence set.
The modified StudentRecord
which was just
processed. If an error occurs during the call to
accumulateEvidence
both function will return an object of class
try-error
instead of the student record.
The functions handleEvidence
, accumulateEvidence
and
many of the functions they call use the
flog.logger
protocol. The default
logging level of INFO will give messages in response to the
announcements and warnings when an error occur. The DEBUG and TRACE
levels will provide more information about the details of the update
algorithm.
The body of accumulateEvidence
is wrapped in
withFlogging
which captures and logs errors.
This function returns an object of class try-error
when an
error occurs. Although handleEvidence
does not use the
flogging error handler, it will still pass on the try-error
if
one is generated.
The debug
argument can be used to pause execution. Basically,
recover()
will be called between every step. This
only happens in interactive mode as it just does not make sense in
batch model.
There is a bug in version 5.04 of Netica which causes the absorbNodes function when called with a node that does not have display information to generate an internal Netica error. This has been fixed with version 6.07, which is currently in beta release (Linux only).
To work around, make sure that either all nodes do not have display information, or that all do.
Russell Almond
Almond, Mislevy, Steinberg, Yan and Williamson (2015). Bayesian Networks in Educational Assessment. Springer. Especially Chapters 5 and 13.
Classes:
BNEngine
BNEngineMongo
, BNEngineNDB
StudentRecord
,
EvidenceSet
Main Loop Functions:
mainLoop
,
getRecordForUser
,
logEvidence
,
updateRecord
,
updateSM
,
updateStats
,
updateHist
,
announceStats
,
saveSR
## Requires database setup, also PNetica
library(RNetica) ## 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("Physics")
configStats(eng,stattab)
setupDefaultSR(eng)
sr0 <- getRecordForUser(eng,"S1")
eap0 <- stat(sr0,"Physics_EAP")
e1 <- EvidenceSet(uid="S1",app="Test",context="PPcompEM",
obs=list("CompensatoryObs"="Right"))
e1 <- logEvidence(eng,sr0,e1)
sr1 <- accumulateEvidence(eng,sr0,e1)
stopifnot(!is(sr1,'try-error'))
stopifnot(m_id(sr1)!=m_id(sr0),sr1@prev_id==m_id(sr0))
stopifnot(seqno(sr1)==1L, seqno(e1)==1L)
eap1 <- stat(sr1,"Physics_EAP")
stopifnot(abs(eap1-eap0) > .001)
stopifnot(nrow(history(sr1,"Physcis"))==2L)
## handle Evidence.
sr1.ser <- as.json(sr1)
e2 <- EvidenceSet(uid="S2",app="Test",context="PPconjEM",
obs=list("ConjunctiveObs"="Wrong"))
sr2 <- handleEvidence(eng,e2,jsonlite::fromJSON(sr1.ser))
stopifnot(!is(sr2,'try-error'))
eap2 <- stat(sr2,"Physics_EAP")
stopifnot(uid(sr2)==uid(sr1),
m_id(sr1)==sr2@prev_id,
nrow(history(sr2,"Physics"))==3L,
abs(eap1-eap2) > .001)
## <<HERE>> Need test with Mongo engine.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.