FileCaseStream-class {RNetica} | R Documentation |
"FileCaseStream"
This object is subclass of CaseStream
so it is a
wrapper around a Netica stream which is used to read/write cases. In
this subclass, the case stream is associated with a Netica case file
(‘.cas’ extension). The function CaseFileStream
is the constructor. The function ReadFindings
reads the
findings from the stream and the function WriteFindings
writes them out.
Class "CaseStream"
, directly.
All reference classes extend and inherit methods from
"envRefClass"
. Note that because this is a reference
class unlike traditional S3 and S4 classes it can be destructively
modified. Also fields (slots) are accessed using the ‘$’
operator.
Note these should be regarded as read-only from user code.
Name
:Object of class character
used in printed
representation. Default is
basename(Case_Stream_Path)
.
Session
:Object of class NeticaSession
a link
to the session in which this case stream was created.
Netica_Case_Stream
:Object of class externalptr
a pointer to the case stream in Netica memory.
Case_Stream_Position
:Object of class integer
the number of the last read/writen record. This is NA
if
the end of the file has been reached.
Case_Stream_Lastid
:Object of class integer
the
ID number of the last read/written record.
Case_Stream_Lastfreq
:Object of class numeric
giving the frequence of the last read/written record. This is
used as a weight in learning applications.
open()
:Opens a connection too the file in Netica.
show()
:Provides a description of the field
initialize(Name, Session, Case_Stream_Path, ...)
:internal constructor; user code should use CaseFileStream
.
The following methods are inherited (from CaseStream
):
close ("CaseStream"), isActive ("CaseStream"), isOpen ("CaseStream"), show ("CaseStream"), clearErrors ("CaseStream"), reportErrors ("CaseStream"), initialize ("CaseStream")
In version 0.5 of RNetica, this class was renamed. It is now called
FileCaseStream
but the constructor is still called
CaseFileStream
(while previously the class and the
filename had the same name). This matches the usage of
FileCaseStream
and its constructor
CaseFileStream
. It is also now a reference class
instead of an informal S3 class. This is only likely to be a problem
for code that was using the hard coded class name.
Stream objects are fragile, and will not survive saving and restoring
an R session. However, the object retains information about itself,
so that calling OpenCaseStream
on the saved object, should
reopen the stream. Note that any position information will be lost.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: NewFileStream_ns(), DeleteStream_ns() http://homepage.stat.uiowa.edu/~luke/R/references/weakfinex.html
See CaseStream
for the superclass and
MemoryCaseStream
for a sibling class.
The function CaseFileStream
is the constructor.
OpenCaseStream
,
CaseFileDelimiter
, CaseFileMissingCode
,
WriteFindings
, ReadFindings
,
WithOpenCaseStream
sess <- NeticaSession() startSession(sess) abc <- CreateNetwork("ABC", session=sess) A <- NewDiscreteNode(abc,"A",c("A1","A2","A3","A4")) B <- NewDiscreteNode(abc,"B",c("B1","B2","B3")) C <- NewDiscreteNode(abc,"C",c("C1","C2")) AddLink(A,B) AddLink(A,C) AddLink(B,C) ## Outputfilename casefile <- tempfile("testcase",fileext=".cas") filestream <- CaseFileStream(casefile, session=sess) stopifnot(is.CaseFileStream(filestream), isCaseStreamOpen(filestream)) ## Case 1 NodeFinding(A) <- "A1" NodeFinding(B) <- "B1" NodeFinding(C) <- "C1" filestream <- WriteFindings(list(A,B,C),filestream,1001,1.0) stopifnot(getCaseStreamLastId(filestream)==1001, abs(getCaseStreamLastFreq(filestream)-1.0) <.0001) ## Close it filestream <- CloseCaseStream(filestream) stopifnot (is.CaseFileStream(filestream), !isCaseStreamOpen(filestream)) ## Reopen it filestream <- OpenCaseStream(filestream) stopifnot (is.CaseFileStream(filestream), isCaseStreamOpen(filestream)) ##Case 1 RetractNetFindings(abc) filestream <- ReadFindings(list(A,B,C),filestream,"FIRST") stopifnot(getCaseStreamLastId(filestream)==1001, abs(getCaseStreamLastFreq(filestream)-1.0) <.0001) ##Clean Up CloseCaseStream(filestream) DeleteNetwork(abc) stopSession(sess)