Class AbstractDataIndexer
Abstract class for collecting event and context counts used in training.
public abstract class AbstractDataIndexer : IDataIndexer
- Inheritance
-
AbstractDataIndexer
- Implements
- Derived
- Inherited Members
Fields
CUTOFF_DEFAULT
public const int CUTOFF_DEFAULT = 5
Field Value
CUTOFF_PARAM
public const string CUTOFF_PARAM = "Cutoff"
Field Value
SORT_DEFAULT
public const bool SORT_DEFAULT = true
Field Value
SORT_PARAM
public const string SORT_PARAM = "sort"
Field Value
contexts
The integer contexts associated with each unique event.
protected int[][] contexts
Field Value
- int[][]
numTimesEventsSeen
The number of times an event occured in the training data.
protected int[] numTimesEventsSeen
Field Value
- int[]
outcomeLabels
The names of the outcomes.
protected string[] outcomeLabels
Field Value
- string[]
outcomeList
The integer outcome associated with each unique event.
protected int[] outcomeList
Field Value
- int[]
predCounts
The number of times each predicate occured.
protected int[] predCounts
Field Value
- int[]
predLabels
The predicate/context names.
protected string[] predLabels
Field Value
- string[]
printMessages
protected bool printMessages
Field Value
reportMap
protected IDictionary<string, string>? reportMap
Field Value
trainingParameters
protected TrainingParameters trainingParameters
Field Value
Properties
Contexts
Gets the array of predicates seen in each event: a 2-D array whose first dimension is the event index and array this refers to contains the contexts for that event.
public virtual int[][] Contexts { get; }
Property Value
- int[][]
NumEvents
Gets the number of total events indexed.
public virtual int NumEvents { get; }
Property Value
NumTimesEventsSeen
Gets an array indexed by the event index indicating the number of times a particular event was seen.
public virtual int[] NumTimesEventsSeen { get; }
Property Value
- int[]
OutcomeLabels
Gets an array of outcome names indexed by outcome index.
public virtual string[] OutcomeLabels { get; }
Property Value
- string[]
OutcomeList
Gets an array indicating the outcome index for each event.
public virtual int[] OutcomeList { get; }
Property Value
- int[]
PredCounts
Gets an array of the count of each predicate in the events.
public virtual int[] PredCounts { get; }
Property Value
- int[]
PredLabels
Gets an array of predicate/context names indexed by context index. These indices are the value of the array returned by Contexts.
public virtual string[] PredLabels { get; }
Property Value
- string[]
Values
Gets the values associated with each event context, or null if
integer values are to be used.
public virtual float[][]? Values { get; }
Property Value
- float[][]
Methods
Display(string)
protected virtual void Display(string s)
Parameters
sstring
Index(IObjectStream<Event>)
Performs the data indexing. Make sure the Init(TrainingParameters, IDictionary<string, string>?) method is called first.
public abstract void Index(IObjectStream<Event> eventStream)
Parameters
eventStreamIObjectStream<Event>a stream of events
Exceptions
- IOException
if there is an error during reading
Index(IObjectStream<Event?>, IDictionary<string, int>)
protected virtual IList<ComparableEvent?> Index(IObjectStream<Event?> events, IDictionary<string, int> predicateIndex)
Parameters
eventsIObjectStream<Event>predicateIndexIDictionary<string, int>
Returns
Init(TrainingParameters, IDictionary<string, string>?)
Sets parameters used during the data indexing.
public virtual void Init(TrainingParameters indexingParameters, IDictionary<string, string>? reportMap)
Parameters
indexingParametersTrainingParametersreportMapIDictionary<string, string>the map to which report entries are written.
SortAndMerge(IList<ComparableEvent?>, bool)
Sorts and uniques the array of comparable events and return the number of unique events. This method will alter the eventsToCompare array -- it does an in place sort, followed by an in place edit to remove duplicates.
protected virtual int SortAndMerge(IList<ComparableEvent?> eventsToCompare, bool sort)
Parameters
eventsToCompareIList<ComparableEvent>a ComparableEvent list
sortboolwhether to sort and merge duplicates
Returns
- int
The number of unique events in the specified list.
Exceptions
- InsufficientTrainingDataException
if not enough events are provided
ToIndexedStringArray(IDictionary<string, int>)
Utility method for creating a string array from a map whose keys are labels to be stored in the array and whose values are the indices at which the corresponding labels should be inserted.
protected static string[] ToIndexedStringArray(IDictionary<string, int> labelToIndexMap)
Parameters
labelToIndexMapIDictionary<string, int>
Returns
- string[]
Update(string[], IDictionary<string, int>)
Updates the set of predicates and counter with the specified event contexts.
protected static void Update(string[] ec, IDictionary<string, int> counter)
Parameters
ecstring[]The contexts/features which occur in a event.
counterIDictionary<string, int>The predicate counters.