Constructor
new Classifier(settings)
Constructor of the class.
Initialize the basic properties and structure of any classifier.
Parameters:
Name | Type | Description |
---|---|---|
settings |
Object | Settings for initializing the instance. |
- Source:
Methods
addLabel(label) → {Array.<String>}
Adds a new label to the observation tree. If the label already exists,
return the existing one without creating it again.
Parameters:
Name | Type | Description |
---|---|---|
label |
String | Label to be created or getted. |
- Source:
Returns:
List of observations assigned to this label.
- Type
- Array.<String>
addObservation(observation, label)
Adds a new observation to the classifier.
Parameters:
Name | Type | Description |
---|---|---|
observation |
String | Observation to be added. |
label |
String | Label of the observation. |
- Source:
classifyObservation()
Classify one observation.
- Source:
clear()
Clears the content of the instance.
This is done by initializing the observations object, the labels array
and the observation count.
- Source:
createClassificationMatrix() → {Array.<Array.<Number>>}
Creates a matrix filled with zeros, that relate every single observation
with every single label.
- Source:
Returns:
A bidimensional array where x is the observation
and y is the label, filled to zeros.
- Type
- Array.<Array.<Number>>
getBestClassification(observation) → {Object}
Given an observation, get the label and score of the best classification.
Parameters:
Name | Type | Description |
---|---|---|
observation |
String | Observation to be classified. |
- Source:
Returns:
Best classification of the observation.
- Type
- Object
getClassifications(observation) → {Array.<Object>}
Get all the labels and score for each label from one observation.
Parameters:
Name | Type | Description |
---|---|---|
observation |
String | Observation to be classified. |
- Source:
Returns:
Sorted array of classifications, that means label and the score.
- Type
- Array.<Object>
recalculateObservationCount()
Iterate all the observations to calculate the total observation count.
- Source:
removeObservation(observation, label)
Removes an observation. The label of the observation can be passed or
can be omitted. When omitted, it loops over all labels tryin to remove
the given observation.
Parameters:
Name | Type | Description |
---|---|---|
observation |
String | Observation to be removed. |
label |
String | Label of the observation, or undefined to iterate over all labels. |
- Source:
removeObservationByLabel(observation, label)
Removes an observation from the observation list of a label.
Parameters:
Name | Type | Description |
---|---|---|
observation |
String | Observation to be removed. |
label |
String | Label where we want the observation to be removed. |
- Source: