public final class DefaultEvidenceReader extends Object implements EvidenceReader
EvidenceReader
, used in Bayes Server for tasks such as parameter learning.
If temporal data (e.g. time series data) is present, it must be sorted by case identifier and then time.
If non temporal data is present, it must be sorted by case identifier, if present.
Constructor and Description |
---|
DefaultEvidenceReader(DataReader reader,
List<VariableReference> variables,
ReaderOptions readerOptions)
Initializes a new instance of the
DefaultEvidenceReader class. |
DefaultEvidenceReader(DataReader reader,
List<VariableReference> variables,
ReaderOptions readerOptions,
DataReader readerTemporal,
List<VariableReference> variablesTemporal,
TemporalReaderOptions temporalReaderOptions)
Initializes a new instance of the
DefaultEvidenceReader class, supporting both temporal and non temporal data. |
DefaultEvidenceReader(DataReader readerTemporal,
List<VariableReference> variablesTemporal,
TemporalReaderOptions temporalReaderOptions)
Initializes a new instance of the
DefaultEvidenceReader class. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes any resources associated with the data such as database connections, files etc...
|
protected void |
finalize() |
boolean |
getAutoReadTemporal()
Determines whether any temporal data is read automatically.
|
DataProgress |
getDataProgress()
Gets the instance used to report progress on the number of cases read.
|
int |
getDataProgressInterval()
Gets a value which determines how often progress events are raised.
|
ReadInfo |
getReadInfo()
Provides information about the last read of non temporal data.
|
TemporalReadInfo |
getTemporalReadInfo()
Provides information about the last read of temporal data.
|
long |
getUnweightedCaseCount()
Gets the number of cases (unweighted) read so far.
|
double |
getWeightedCaseCount()
Gets the number of cases (weighted) read so far.
|
boolean |
read(Evidence evidence,
ReadOptions readOptions)
Reads the next case (record).
|
boolean |
readTemporal(Evidence evidence,
ReadOptions readOptions)
Reads the next temporal record, setting evidence.
|
void |
setAutoReadTemporal(boolean value)
Determines whether any temporal data is read automatically.
|
void |
setDataProgress(DataProgress value)
Gets the instance used to report progress on the number of cases read.
|
void |
setDataProgressInterval(int value)
Sets a value which determines how often progress events are raised.
|
public DefaultEvidenceReader(DataReader reader, List<VariableReference> variables, ReaderOptions readerOptions)
DefaultEvidenceReader
class. This override is used when there is no temporal data.reader
- The data reader to read non temporal data.variables
- The non temporal variables to read.readerOptions
- Options for reading non temporal data.public DefaultEvidenceReader(DataReader readerTemporal, List<VariableReference> variablesTemporal, TemporalReaderOptions temporalReaderOptions)
DefaultEvidenceReader
class. This override is used when there is temporal data, but no non temporal data.readerTemporal
- The data reader to read temporal data.variablesTemporal
- The temporal variables.temporalReaderOptions
- Options for reading temporal data.public DefaultEvidenceReader(DataReader reader, List<VariableReference> variables, ReaderOptions readerOptions, DataReader readerTemporal, List<VariableReference> variablesTemporal, TemporalReaderOptions temporalReaderOptions)
DefaultEvidenceReader
class, supporting both temporal and non temporal data.reader
- The data reader to read non temporal data.variables
- The non temporal variables.readerOptions
- Options for reading non temporal data.readerTemporal
- The data reader to read temporal data.variablesTemporal
- The temporal variables.temporalReaderOptions
- Options for reading temporal data.protected void finalize() throws Throwable
public DataProgress getDataProgress()
public void setDataProgress(DataProgress value)
public int getDataProgressInterval()
public void setDataProgressInterval(int value)
public boolean getAutoReadTemporal()
When no temporal data is present, this option has no effect.
When true
(the default), readTemporal(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
is called automatically (in a loop), each time read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
is called.
When false
, readTemporal(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
must be manually called (in a loop) to read any temporal data, after each call to read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
. This allows temporal information to be extracted via TemporalReadInfo
, during the read process.
public void setAutoReadTemporal(boolean value)
When no temporal data is present, this option has no effect.
When true
(the default), readTemporal(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
is called automatically (in a loop), each time read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
is called.
When false
, readTemporal(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
must be manually called (in a loop) to read any temporal data, after each call to read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
. This allows temporal information to be extracted via TemporalReadInfo
, during the read process.
public ReadInfo getReadInfo()
public TemporalReadInfo getTemporalReadInfo()
getAutoReadTemporal()
is false
.public void close()
close
in interface EvidenceReader
close
in interface Closeable
close
in interface AutoCloseable
public boolean read(Evidence evidence, ReadOptions readOptions)
read
in interface EvidenceReader
evidence
- The destination evidence.readOptions
- Read options.true
if a case was sucessfully read, false
if no more cases (records) were present.public long getUnweightedCaseCount()
com.bayesserver.data.DefaultEvidenceReader#reset
is called.public double getWeightedCaseCount()
com.bayesserver.data.DefaultEvidenceReader#reset
is called.public boolean readTemporal(Evidence evidence, ReadOptions readOptions)
This method can only be called if getAutoReadTemporal()
is false
.
This method must be called in order to move to the first temporal record that corresponds to the current read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
.
Note that even if there is only temporal data, read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
must still be called.
This method should be called repeatedly until it returns false
, within each call to read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
, which should also be called repeatedly.
evidence
- The evidence to update.readOptions
- Read options.true
if the read was successful, false
if there is no more temporal data for this case.read(com.bayesserver.inference.Evidence, com.bayesserver.data.ReadOptions)
,
TemporalReadInfo
Copyright © 2021. All rights reserved.