Parent class and structures for the classifier classes.
Macros:
ClassifierEvaluation, class to memorise the result of evaluation of a classifier
Overall accuracy (in [0.0, 1.0], the higher the better) double accuracy;
Confusion matrix, such as confusionMatrix[i * n + j] is the number of times the i-th category has been predicted as the j-th category, where n is the number of possible categories CapyDatasetNbVals_t* confusionMatrix;
Return the evaluated accuracy of the classifier
Output and side effect(s):
Return the accuracy (in [0, 1]). double (*getAccuracy)(void);
Return the evaluated fitness of the classifier
Output and side effect(s):
Return the fitness (in [0, 1]). double (*getFitness)(void);
Classifier, parent class for all classifiers
Index of the predicted output in the dataset (default: 0) CapyDatasetNbField_t iOutput;
Train the classifier on a dataset
Input argument(s):
dataset: the dataset
Output and side effect(s):
The classifier is trained.
Exception(s):
May raise CapyExc_UnsupportedFormat void (*train)(CapyDataset const* const dataset);
Classify an input
Input argument(s):
inp: the input
Output and side effect(s):
Return the index of the category CapyDatasetNbVals_t (*predict)(CapyVec const* const inp);
Evaluate the classifier on a dataset
Input argument(s):
dataset: the dataset
Output and side effect(s):
Return the evaluation of the classifier. CapyClassifierEvaluation* (*evaluate)(CapyDataset const* const dataset);
Convert a CapyDataset into a CapyMat usable by the classifier
Input argument(s):
dataset: the dataset to be converted
Output and side effect(s):
Return a matrix formatted as necessary CapyMat (*cvtDatasetToMat)( CapyDataset const* const dataset);
Clone a classifier
Output and side effect(s):
Return a clone of the classifier. void* (*clone)(void);
Export the classifier as a C function
Input argument(s):
stream: the stream where to export
name: the name of the function
dataset: the training dataset
Output and side effect(s):
A ready to use C function implementing the classifier is written on the stream. See the comment exported with the function to know how to use the exported function. void (*exportToCFun)( FILE* const stream, char const* const name, CapyDataset const* const dataset);
Export the classifier as a HTML web app
Input argument(s):
stream: the stream where to export
title: the title of the web app
dataset: the training dataset
expectedAccuracy: the expected accuracy of the classifier (in [0,1])
Output and side effect(s):
A ready to use web app implementing the classifier is written on the stream. void (*exportToHtml)( FILE* const stream, char const* const title, CapyDataset const* const dataset, double const expectedAccuracy);
Enumerations:
None.
Typedefs:
CapyClassifierEvaluation declaration
Classifier structure
Struct CapyClassifierPrediction :
Struct CapyClassifierPrediction's properties:
Predicted category
Confidence of the prediction (in [0,+inf[, the higher the more confident)
Struct CapyClassifierPrediction's methods:
None.
Functions:
Create a CapyClassifierEvaluation
Output and side effect(s):
Return a CapyClassifierEvaluation
Allocate memory for a new CapyClassifierEvaluation and create it
Output and side effect(s):
Return a CapyClassifierEvaluation
Exception(s):
May raise CapyExc_MallocFailed.
Free the memory used by a CapyClassifierEvaluation* and reset '*that' to NULL
Input argument(s):
that: a pointer to the CapyClassifierEvaluation to free
Create a CapyClassifier
Output and side effect(s):
Return a CapyClassifier
Allocate memory for a new CapyClassifier and create it
Output and side effect(s):
Return a CapyClassifier
Exception(s):
May raise CapyExc_MallocFailed.
Free the memory used by a CapyClassifier* and reset '*that' to NULL
Input argument(s):
that: a pointer to the CapyClassifier to free