- Classifier
- new Classifier([model])
- .model :
Model
- .train(input, label) ⇒
this
- .predict(input, [maxMatches], [minimumConfidence]) ⇒
Array
- .splitWords(input) ⇒
Array
- .tokenize(input) ⇒
Object
- .vectorize(tokens) ⇒
Object
- .cosineSimilarity(v1, v2) ⇒
float
Param | Type | Default | Description |
---|---|---|---|
[model] | Model | Object |
||
[model.nGramMin] | int |
1 |
Minimum n-gram size |
[model.nGramMax] | int |
1 |
Maximum n-gram size |
[model.vocabulary] | Array | Set | false |
[] |
Terms mapped to indexes in the model data, set to false to store terms directly in the data entries |
[model.data] | Object |
{} |
Key-value store of labels and training data vectors |
Model instance
Train the current model using an input string (or array of strings) and a corresponding label
Param | Type | Description |
---|---|---|
input | string | Array |
String, or an array of strings |
label | string |
Corresponding label |
Return an array of one or more Prediction instances
Param | Type | Default | Description |
---|---|---|---|
input | string |
Input string to make a prediction from | |
[maxMatches] | int |
1 |
Maximum number of predictions to return |
[minimumConfidence] | float |
0.2 |
Minimum confidence required to include a prediction |
Split a string into an array of lowercase words, with all non-letter characters removed
Param | Type |
---|---|
input | string |
Create an object literal of unique tokens (n-grams) as keys, and their respective occurrences as values based on an input string, or array of words
Param | Type |
---|---|
input | string | Array |
Convert a tokenized object into a new object with all keys (terms) translated to their index in the returned vocabulary (which is also returned along with the object, with any new terms added to the end)
Param | Type |
---|---|
tokens | Object |
Return the cosine similarity between two vectors
Param | Type |
---|---|
v1 | Object |
v2 | Object |