|
38 | 38 | "name": "stdout", |
39 | 39 | "output_type": "stream", |
40 | 40 | "text": [ |
41 | | - "CPU times: user 6 s, sys: 1.23 s, total: 7.23 s\n", |
42 | | - "Wall time: 8.33 s\n" |
| 41 | + "CPU times: user 6.19 s, sys: 1.27 s, total: 7.46 s\n", |
| 42 | + "Wall time: 9.01 s\n" |
43 | 43 | ] |
44 | 44 | } |
45 | 45 | ], |
|
48 | 48 | "import malaya" |
49 | 49 | ] |
50 | 50 | }, |
| 51 | + { |
| 52 | + "cell_type": "markdown", |
| 53 | + "metadata": {}, |
| 54 | + "source": [ |
| 55 | + "### Models accuracy\n", |
| 56 | + "\n", |
| 57 | + "We use `sklearn.metrics.classification_report` for accuracy reporting, check at https://malaya.readthedocs.io/en/latest/models-accuracy.html#emotion-analysis" |
| 58 | + ] |
| 59 | + }, |
| 60 | + { |
| 61 | + "cell_type": "markdown", |
| 62 | + "metadata": {}, |
| 63 | + "source": [ |
| 64 | + "### labels supported\n", |
| 65 | + "\n", |
| 66 | + "Default labels for emotion module." |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "execution_count": 2, |
| 72 | + "metadata": {}, |
| 73 | + "outputs": [ |
| 74 | + { |
| 75 | + "data": { |
| 76 | + "text/plain": [ |
| 77 | + "['anger', 'fear', 'happy', 'love', 'sadness', 'surprise']" |
| 78 | + ] |
| 79 | + }, |
| 80 | + "execution_count": 2, |
| 81 | + "metadata": {}, |
| 82 | + "output_type": "execute_result" |
| 83 | + } |
| 84 | + ], |
| 85 | + "source": [ |
| 86 | + "malaya.emotion.label" |
| 87 | + ] |
| 88 | + }, |
| 89 | + { |
| 90 | + "cell_type": "markdown", |
| 91 | + "metadata": {}, |
| 92 | + "source": [ |
| 93 | + "### Example texts\n", |
| 94 | + "\n", |
| 95 | + "Copy pasted from random tweets." |
| 96 | + ] |
| 97 | + }, |
51 | 98 | { |
52 | 99 | "cell_type": "code", |
53 | 100 | "execution_count": 2, |
|
413 | 460 | "malaya.emotion.available_transformer()" |
414 | 461 | ] |
415 | 462 | }, |
416 | | - { |
417 | | - "cell_type": "markdown", |
418 | | - "metadata": {}, |
419 | | - "source": [ |
420 | | - "Make sure you can check accuracy chart from here first before select a model, https://malaya.readthedocs.io/en/latest/Accuracy.html#emotion-analysis\n", |
421 | | - "\n", |
422 | | - "**You might want to use Tiny-Albert, a very small size, 22.4MB, but the accuracy is still on the top notch.**" |
423 | | - ] |
424 | | - }, |
425 | 463 | { |
426 | 464 | "cell_type": "markdown", |
427 | 465 | "metadata": {}, |
|
726 | 764 | "\n", |
727 | 765 | "```python\n", |
728 | 766 | "def predict_words(\n", |
729 | | - " self, string: str, method: str = 'last', visualization: bool = True\n", |
| 767 | + " self,\n", |
| 768 | + " string: str,\n", |
| 769 | + " method: str = 'last',\n", |
| 770 | + " bins_size: float = 0.05,\n", |
| 771 | + " visualization: bool = True,\n", |
730 | 772 | "):\n", |
731 | 773 | " \"\"\"\n", |
732 | 774 | " classify words.\n", |
|
740 | 782 | " * ``'last'`` - attention from last layer.\n", |
741 | 783 | " * ``'first'`` - attention from first layer.\n", |
742 | 784 | " * ``'mean'`` - average attentions from all layers.\n", |
| 785 | + " bins_size: float, optional (default=0.05)\n", |
| 786 | + " default bins size for word distribution histogram.\n", |
743 | 787 | " visualization: bool, optional (default=True)\n", |
744 | 788 | " If True, it will open the visualization dashboard.\n", |
745 | 789 | "\n", |
746 | 790 | " Returns\n", |
747 | 791 | " -------\n", |
748 | | - " result: dict\n", |
| 792 | + " dictionary: results\n", |
749 | 793 | " \"\"\"\n", |
750 | 794 | "```\n", |
751 | 795 | "\n", |
|
0 commit comments