TNaiveBayes Class

TComponent→TClassifier→TStatisticClassifier→TNaiveBayes

type TNaiveBayes = class(TStatisticClassifier)

Implementation of the "Naive Bayes" classification algorithm.

The classifier uses the Laplace estimate of the prior probabilities and m-estimate of the probability. Naive Bayes is still the most succesfull classifier for "statistics":"single example" classification case. It outperformes neural networks and machine learning algorithms in most of the real life cases, despite its inability to detect and account for non-linearities present in the learn datasets. This does not mean that it is not sensitive to presence of non-linearities, but the occurence of such non-linearities which could significantly affect the classification accuracy in the real world test databases is very rare. The drawback of Naive Bayes is its inability to process real values natively. All real valued attributes have to be converted to a discrete representation. This requires, that the entire "knowledge" database is known in advance.

Constructors

NameDescription
CreateCreate the component.

Properties

NameTypeDescription
AttributeCountintegerTotal number of attributes.
AttributeEnabledbooleanSet the value at index to True/False, to enable/disable the corresponding attribute.
ClassesTBClassesListPointer to list of classes with attribute descriptions and stored learned data.
DiscreteAttributeCountintegerTotal number of discrete valued attributes or fields holding discreting values in the dataset.
FloatAttributeCountintegerTotal number of real valued attributes or fields holding real values in the dataset.
IndexesZeroBasedbooleanSet to True, if Class indexes are zero based.
MintegerThe M parameter is used by the M estimate of the probability.
MissingDiscreteIndexintegerSpecifies the value indicating a "missing value" (no entry) for discrete attributes in the dataset.
MissingFloatValuestringSpecifies the value indicating a "missing value" (no entry) for real valued attributes in the dataset.
NormalizeAttributeCountbooleanIf true, the number of attributes compared will be normalized between comparisons.
OnClassifyTestTOnClassifyTestCalled by PrePrune, PostPrune and Prune methods and ClassifyTest methods.
OnFirstRecordTNotifyEventCalled by LearnData method and K-NN to request the positioning to the first record.
OnIndexNextRecordTIndexNextRecordCalled by LearnData method and K-NN to browse through the learn dataset.
OnLastRecordTNotifyEventCalled by LearnData method and K-NN when the last record is fetched.
OnNameNextRecordTNameNextRecordCalled by LearnData method and K-NN to browse through the learn data set.
OnPopPositionTPopBookmarkCalled by LearnData method and K-NN to restore the current position of the dataset.
OnPushPositionTPushBookmarkCalled by LearnData method and K-NN to save the current position of the dataset.
RejectProbabilitydoubleIf the response of all classes is below RejectProbability the example will not be classified to any of the known classes.

Methods

NameDescription
AssignAttributeStateCopies the attribute Enabled fields from Source.
AttributeQualityReturns an array of attribute indexes sorted by quality.
ClassesNameGet the name of the class at Index.
ClassifyDetermine the most probable class to which the example with values of discrete attributes in DiscreteRecord and values of real valued attributes in FloatRecord belongs to.
ClassifyResponseDetermine the response of all classe for the example with values of discrete attributes in DiscreteRecord and values of real valued attributes in FloatRecord.
ClassifyTestPerforms the classification on the test data, by calling the OnClassifyTest event.
ClassIndexGet the index of the class with Name.
ClearClear all learned data and all class descriptions.
DestroyDestroy the component.
DisableAttributesDisable real valued and discrete attributes for all classes.
DisableDiscreteAttributesDisable discrete attributes for all classes.
DisableFloatAttributesDisable real valued attributes for all classes.
EnableAttributesEnable real valued and discrete attributes for all classes.
EnableDiscreteAttributesEnable discrete attributes for all classes.
EnableFloatAttributesEnable real valued attributes for all classes.
EntropyReturns the average information entropy.
LearnLearn a new record belonging to class with ClassName.
LearnDataCall this method to perform the learn operation on the learn data.
LearnIndexLearn a new record belonging to class with ClassIndex.
LoadFromFileLoad the component from file named FileName.
LoadFromStream
MaxDiscreteEntropyReturns the maximum entropy of the discrete attribute at AttributeIndex.
MaxEntropyReturns the maximum entropy found to be of the attribute at Index.
MaxFloatEntropyReturns the maximum entropy of the real valued attribute at AttributeIndex.
MaxPriorProbabilityReturns the index of the class, which has the highest count of examples and thus the highest prior probability, with ClassIndex.
MissingFloatNumberReturns numerical representation of MissingFloatValue.
PostPrunePruning disables some attributes, to improve classification accuracy.
PrePrunePruning disables some attributes, to improve classificaiton accuracy.
PrunePerforms pre-pruning and post-pruning and enables only those attributes giving best classification accuracy towards the test dataset.
ResetReset all learned data including attribute weights and attribute Enabled fields, but keep the class descriptions.
SaveToFileSave the component to file named FileName.
SaveToStream
SoftResetReset all learned data except attribute weights and attribute Enabled fields and keep the class descriptions.
SortIndexRecordSort an array of TIndexRecords.