|
7 | 7 | * [.model](#Classifier+model) : <code>Model</code> |
8 | 8 | * [.train([input], label)](#Classifier+train) ⇒ <code>this</code> |
9 | 9 | * [.predict(input, [maxMatches], [minimumConfidence])](#Classifier+predict) ⇒ <code>Array</code> |
| 10 | + * [.splitWords(input)](#Classifier+splitWords) ⇒ <code>Array</code> |
| 11 | + * [.tokenize(input)](#Classifier+tokenize) ⇒ <code>Object</code> |
| 12 | + * [.vectorize(tokens)](#Classifier+vectorize) ⇒ <code>Object</code> |
| 13 | + * [.cosineSimilarity(v1, v2)](#Classifier+cosineSimilarity) ⇒ <code>float</code> |
10 | 14 |
|
11 | 15 | <a name="new_Classifier_new"></a> |
12 | 16 |
|
13 | 17 | ### new Classifier([model]) |
14 | 18 |
|
15 | 19 | | Param | Type | Default | Description | |
16 | 20 | | --- | --- | --- | --- | |
17 | | -| [model] | <code>Model</code> \| <code>Object</code> | | | |
18 | | -| [model.nGramMin] | <code>int</code> | <code>1</code> | Minimum n-gram size | |
19 | | -| [model.nGramMax] | <code>int</code> | <code>1</code> | Maximum n-gram size | |
20 | | -| [model.minimumConfidence] | <code>int</code> \| <code>float</code> | <code>0.2</code> | Minimum confidence required for predictions | |
21 | | -| [model.vocabulary] | <code>Array</code> \| <code>Set</code> \| <code>false</code> | <code>[]</code> | Terms mapped to indexes in the model data entries, set to false to store terms directly in the data entries | |
22 | | -| [model.data] | <code>int</code> | <code>{}</code> | Key-value store containing all training data | |
| 21 | +| [model] | `Model` \| `Object` | | | |
| 22 | +| [model.nGramMin] | `int` | `1` | Minimum n-gram size | |
| 23 | +| [model.nGramMax] | `int` | `1` | Maximum n-gram size | |
| 24 | +| [model.minimumConfidence] | `int` \| `float` | `0.2` | Minimum confidence required for predictions | |
| 25 | +| [model.vocabulary] | `Array` \| `Set` \| `false` | `[]` | Terms mapped to indexes in the model data, set to `false` to store terms directly in the data entries | |
| 26 | +| [model.data] | `Object` | `{}` | Key-value store of labels and training data vectors | |
23 | 27 |
|
24 | 28 | <a name="Classifier+model"></a> |
25 | 29 |
|
26 | | -### classifier.model : <code>Model</code> |
| 30 | +### classifier.model : `Model` |
27 | 31 | Model instance |
28 | 32 |
|
29 | 33 | <a name="Classifier+train"></a> |
30 | 34 |
|
31 | | -### classifier.train([input], label) ⇒ <code>this</code> |
| 35 | +### classifier.train([input], label) ⇒ `this` |
32 | 36 | Train the current model using an input string (or array of strings) and a corresponding label |
33 | 37 |
|
34 | 38 | | Param | Type | Description | |
35 | 39 | | --- | --- | --- | |
36 | | -| [input] | <code>string</code> \| <code>Array.<string></code> | String, or an array of strings | |
37 | | -| label | <code>string</code> | Corresponding label | |
| 40 | +| input | `string` \| `Array` | String, or an array of strings | |
| 41 | +| label | `string` | Corresponding label | |
38 | 42 |
|
39 | 43 | <a name="Classifier+predict"></a> |
40 | 44 |
|
41 | | -### classifier.predict(input, [maxMatches], [minimumConfidence]) ⇒ <code>Array</code> |
| 45 | +### classifier.predict(input, [maxMatches], [minimumConfidence]) ⇒ `Array` |
42 | 46 | Return an array of one or more Prediction instances |
43 | 47 |
|
44 | 48 | | Param | Type | Default | Description | |
45 | 49 | | --- | --- | --- | --- | |
46 | | -| input | <code>string</code> | | Input string to make a prediction from | |
47 | | -| [maxMatches] | <code>int</code> | <code>1</code> | Maximum number of predictions to return | |
48 | | -| [minimumConfidence] | <code>float</code> | <code>null</code> | Minimum confidence required to include a prediction | |
| 50 | +| input | `string` | | Input string to make a prediction from | |
| 51 | +| [maxMatches] | `int` | `1` | Maximum number of predictions to return | |
| 52 | +| [minimumConfidence] | `float` | `null` | Minimum confidence required to include a prediction | |
| 53 | + |
| 54 | +<a name="Classifier+splitWords"></a> |
| 55 | + |
| 56 | +### classifier.splitWords(input) ⇒ `Array` |
| 57 | +Split a string into an array of lowercase words, with all non-letter characters removed |
| 58 | + |
| 59 | +| Param | Type | |
| 60 | +| --- | --- | |
| 61 | +| input | `string` | |
| 62 | + |
| 63 | +<a name="Classifier+tokenize"></a> |
| 64 | + |
| 65 | +### classifier.tokenize(input) ⇒ `Object` |
| 66 | +Create an object literal of unique tokens (n-grams) as keys, and their |
| 67 | +respective occurrences as values based on an input string, or array of words |
| 68 | + |
| 69 | +| Param | Type | |
| 70 | +| --- | --- | |
| 71 | +| input | `string` \| `Array` | |
| 72 | + |
| 73 | +<a name="Classifier+vectorize"></a> |
| 74 | + |
| 75 | +### classifier.vectorize(tokens) ⇒ `Object` |
| 76 | +Convert a tokenized object into a new object with all keys (terms) |
| 77 | +translated to their index in the vocabulary (adding all terms to |
| 78 | +the vocabulary that do not already exist) |
| 79 | + |
| 80 | +| Param | Type | |
| 81 | +| --- | --- | |
| 82 | +| tokens | `Object` | |
| 83 | + |
| 84 | +<a name="Classifier+cosineSimilarity"></a> |
| 85 | + |
| 86 | +### classifier.cosineSimilarity(v1, v2) ⇒ `float` |
| 87 | +Return the cosine similarity between two vectors |
| 88 | + |
| 89 | +| Param | Type | |
| 90 | +| --- | --- | |
| 91 | +| v1 | `Object` | |
| 92 | +| v2 | `Object` | |
0 commit comments