Class EvidenceReader
Provides a default implementation of IEvidenceReader, used in Bayes Server for tasks such as parameter learning.
Inherited Members
Namespace: BayesServer.Data
Assembly: BayesServer.Data.dll
Syntax
public sealed class EvidenceReader : IEvidenceReader, IDisposable, INotifyPropertyChanged
Remarks
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.
Constructors
EvidenceReader(IDataReader, IList<VariableReference>, ReaderOptions)
Initializes a new instance of the EvidenceReader class. This override is used when there is no temporal data.
Declaration
public EvidenceReader(IDataReader reader, IList<VariableReference> variables, ReaderOptions readerOptions)
Parameters
Type | Name | Description |
---|---|---|
IDataReader | reader | The data reader to read non temporal data. |
IList<VariableReference> | variables | The non temporal variables to read. |
ReaderOptions | readerOptions | Options for reading non temporal data. |
EvidenceReader(IDataReader, IList<VariableReference>, ReaderOptions, IDataReader, IList<VariableReference>, TemporalReaderOptions)
Initializes a new instance of the EvidenceReader class, supporting both temporal and non temporal data.
Declaration
public EvidenceReader(IDataReader reader, IList<VariableReference> variables, ReaderOptions readerOptions, IDataReader readerTemporal, IList<VariableReference> variablesTemporal, TemporalReaderOptions temporalReaderOptions)
Parameters
Type | Name | Description |
---|---|---|
IDataReader | reader | The data reader to read non temporal data. |
IList<VariableReference> | variables | The non temporal variables. |
ReaderOptions | readerOptions | Options for reading non temporal data. |
IDataReader | readerTemporal | The data reader to read temporal data. |
IList<VariableReference> | variablesTemporal | The temporal variables. |
TemporalReaderOptions | temporalReaderOptions | Options for reading temporal data. |
EvidenceReader(IDataReader, IList<VariableReference>, TemporalReaderOptions)
Initializes a new instance of the EvidenceReader class. This override is used when there is temporal data, but no non temporal data.
Declaration
public EvidenceReader(IDataReader readerTemporal, IList<VariableReference> variablesTemporal, TemporalReaderOptions temporalReaderOptions)
Parameters
Type | Name | Description |
---|---|---|
IDataReader | readerTemporal | The data reader to read temporal data. |
IList<VariableReference> | variablesTemporal | The temporal variables. |
TemporalReaderOptions | temporalReaderOptions | Options for reading temporal data. |
Properties
AutoReadTemporal
Determines whether any temporal data is read automatically.
Declaration
public bool AutoReadTemporal { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
When no temporal data is present, this option has no effect.
When true
(the default), BayesServer.Data.EvidenceReader.ReadTemporal is called automatically (in a loop),
each time BayesServer.Data.EvidenceReader.Read is called.
When false
, BayesServer.Data.EvidenceReader.ReadTemporal must be manually called (in a loop) to read any temporal data, after
each call to BayesServer.Data.EvidenceReader.Read. This allows temporal information to be extracted via TemporalReadInfo,
during the read process.
DataProgress
Gets the instance used to report progress on the number of cases read. Can be null.
Declaration
public Action<DataProgressEventArgs> DataProgress { get; set; }
Property Value
Type | Description |
---|---|
Action<DataProgressEventArgs> |
DataProgressInterval
Gets or sets a value which determines how often progress events are raised.
Declaration
public int DataProgressInterval { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
Progress will be raised each time this number of (unweighted) cases or temporal rows are read.
ReadInfo
Provides information about the last read of non temporal data.
Declaration
public ReadInfo ReadInfo { get; }
Property Value
Type | Description |
---|---|
ReadInfo |
TemporalReadInfo
Provides information about the last read of temporal data. Only valid when AutoReadTemporal is false
.
Declaration
public TemporalReadInfo TemporalReadInfo { get; }
Property Value
Type | Description |
---|---|
TemporalReadInfo |
UnweightedCaseCount
Gets the number of cases (unweighted) read so far. This counter is reset to zero when BayesServer.Data.EvidenceReader.Reset is called.
Declaration
public long UnweightedCaseCount { get; }
Property Value
Type | Description |
---|---|
Int64 |
WeightedCaseCount
Gets the number of cases (weighted) read so far. This counter is reset to zero when BayesServer.Data.EvidenceReader.Reset is called.
Declaration
public double WeightedCaseCount { get; }
Property Value
Type | Description |
---|---|
Double |
Methods
Dispose()
Declaration
public void Dispose()
Finalize()
Releases unmanaged resources and performs other cleanup operations before the EvidenceReader is reclaimed by garbage collection.
Declaration
protected void Finalize()
Read(IEvidence, IReadOptions)
Reads the next case (record). Read must be called to move to the first record.
Declaration
public bool Read(IEvidence evidence, IReadOptions readOptions)
Parameters
Type | Name | Description |
---|---|---|
IEvidence | evidence | The destination evidence. |
IReadOptions | readOptions | Read options. |
Returns
Type | Description |
---|---|
Boolean |
|
ReadTemporal(IEvidence, IReadOptions)
Reads the next temporal record, setting evidence.
Declaration
public bool ReadTemporal(IEvidence evidence, IReadOptions readOptions)
Parameters
Type | Name | Description |
---|---|---|
IEvidence | evidence | The evidence to update. |
IReadOptions | readOptions | Read options. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
This method can only be called if AutoReadTemporal is false
.
This method must be called in order to move to the first temporal record that corresponds to the current BayesServer.Data.EvidenceReader.Read.
Note that even if there is only temporal data, BayesServer.Data.EvidenceReader.Read must still be called.
This method should be called repeatedly until it returns false
, within each call to BayesServer.Data.EvidenceReader.Read, which should also
be called repeatedly.
See Also
Events
PropertyChanged
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
PropertyChangedEventHandler |