StudentRecordSet | R Documentation |
A StudentRecordSet
is a collection of collection
of StudentRecord
objects. It is always connected
to a PnetWarehouse
and could be connected to a
database as well.
StudentRecordSet(app = "default", warehouse = NULL,
db=MongoDB("StudentRecords","EARecords"),...)
app |
A character scalar providing a guid for the application. |
warehouse |
An object of type |
db |
A |
... |
Other arguments for future extensions. |
A StudentRecordSet
is a collection of student recrods. It
contains a PnetWarehouse
which contains the
student models and possibly a database containing the student records.
The StudentRecordSet
operates in two modes, depending on the
value of db
. If db
references a
MongoDB-class
database, then the
StudentRecordSet
set will save student records (including
serialized Bayes nets) to the database and restore them on demmand.
This facilitates scoring across several sessions.
If the db
argument has the noMongo
flag, no
database connection will be created. Instead, the calls to the
getSR
function should pass in a serialized version of
the student record function. If no serialized record is available, a
new record will be created.
An object of class StudentRecordSet
.
Russell Almond
StudentRecordSet
, StudentRecord
,
getSR
, saveSR
, newSR
,
clearSRs
library(PNetica)
##Start with manifest
sess <- RNetica::NeticaSession()
RNetica::startSession(sess)
## BNWarehouse is the PNetica Net Warehouse.
## This provides an example network manifest.
config.dir <- file.path(library(help="Peanut")$path, "auxdata")
netman1 <- read.csv(file.path(config.dir,"Mini-PP-Nets.csv"),
row.names=1, stringsAsFactors=FALSE)
net.dir <- file.path(library(help="PNetica")$path, "testnets")
Nethouse <- PNetica::BNWarehouse(manifest=netman1,session=sess,key="Name",
address=net.dir)
## Setup to test without Mongo
SRS <- StudentRecordSet(app="Test",warehouse=Nethouse,
db=mongo::MongoDB(noMongo=TRUE))
stopifnot(!mdbAvailable((SRS$recorddb())))
## Setup default SR
dsr <- StudentRecord("*DEFAULT*",app="Test",
context="*Baseline*")
sm(dsr) <- WarehouseSupply(Nethouse,"miniPP_CM")
PnetCompile(sm(dsr))
## dsr <- updateStats(eng,dsr)
statmat <- read.csv(file.path(config.dir,"Mini-PP-Statistics.csv"),
stringsAsFactors=FALSE)
rownames(statmat) <- statmat$Name
statlist <- sapply(statmat$Name,function (st)
Statistic(statmat[st,"Fun"],statmat[st,"Node"],st))
names(statlist) <- statmat$Name
dsr@stats <- lapply(statlist,
function (stat) calcStat(stat,sm(dsr)))
names(dsr@stats) <- names(statlist)
dsr@hist <- lapply(c("Physics"),
function (nd)
EABN:::uphist(sm(dsr),nd,NULL,"*Baseline*"))
names(dsr@hist) <- "Physics"
SRS$defaultSR <- dsr
saveSR(SRS, dsr)
## Make a new Student Record for a student.
sr1 <- newSR(SRS,"S1")
stopifnot(uid(sr1)=="S1",app(sr1)==app(dsr),
all.equal(stats(dsr),stats(sr1),.0002))
sr1a <- getSR(SRS,"S1")
clearSRs(SRS)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.