|
| 1 | +Snips NLU Metrics |
| 2 | +================= |
| 3 | + |
| 4 | +.. image:: https://travis-ci.org/snipsco/snips-nlu-metrics.svg?branch=master |
| 5 | + :target: https://travis-ci.org/snipsco/snips-nlu-metrics |
| 6 | + |
| 7 | +Python package to compute metrics on a NLU/ASR parsing pipeline |
| 8 | + |
| 9 | +Install |
| 10 | +------- |
| 11 | + |
| 12 | +.. code-block:: console |
| 13 | +
|
| 14 | + pip install snips_nlu_metrics |
| 15 | +
|
| 16 | +
|
| 17 | +Pure NLU Metrics API |
| 18 | +-------------------- |
| 19 | + |
| 20 | +.. code-block:: python |
| 21 | +
|
| 22 | + from snips_nlu_metrics import ( |
| 23 | + compute_train_test_nlu_metrics, compute_cross_val_nlu_metrics) |
| 24 | + from snips_nlu import SnipsNLUEngine as NLUTrainingEngine |
| 25 | + from snips_nlu_rust import NLUEngine as NLUInferenceEngine |
| 26 | +
|
| 27 | +
|
| 28 | + tt_metrics = compute_train_test_nlu_metrics(train_dataset="path/to/train_dataset.json", |
| 29 | + test_dataset="path/to/test_dataset.json", |
| 30 | + training_engine_class=NLUTrainingEngine, |
| 31 | + inference_engine_class=NLUInferenceEngine) |
| 32 | +
|
| 33 | + cv_metrics = compute_cross_val_nlu_metrics(dataset="path/to/dataset.json", |
| 34 | + training_engine_class=NLUTrainingEngine, |
| 35 | + inference_engine_class=NLUInferenceEngine, |
| 36 | + nb_folds=5) |
| 37 | +
|
| 38 | +End-to-End Metrics API |
| 39 | +---------------------- |
| 40 | + |
| 41 | +The metrics API lets you compute metrics on a full end-to-end ASR + NLU pipeline. |
| 42 | +To do that, you will need to implement an engine class that inherits or satisfy |
| 43 | +the API of the following ``Engine`` abstract class: |
| 44 | + |
| 45 | +.. code-block:: python |
| 46 | +
|
| 47 | + from abc import ABCMeta, abstractmethod |
| 48 | +
|
| 49 | + class Engine(object): |
| 50 | + """ |
| 51 | + Abstract class which represents an engine that can be used in the metrics |
| 52 | + API. All engine classes must inherit from `Engine` or satisfy its API. |
| 53 | + """ |
| 54 | + __metaclass__ = ABCMeta |
| 55 | +
|
| 56 | + @abstractmethod |
| 57 | + def fit(self, dataset): |
| 58 | + pass |
| 59 | +
|
| 60 | + @abstractmethod |
| 61 | + def parse(self, text): |
| 62 | + pass |
| 63 | +
|
| 64 | +Here is how you can use the end-to-end metrics API, if you have a ``EndToEndEngine`` that inherits from ``Engine``: |
| 65 | + |
| 66 | +.. code-block:: python |
| 67 | +
|
| 68 | + from snips_nlu_metrics import compute_train_test_metrics, compute_cross_val_metrics |
| 69 | +
|
| 70 | +
|
| 71 | + tt_metrics = compute_train_test_metrics(train_dataset="path/to/train_dataset.json", |
| 72 | + test_dataset="path/to/test_dataset.json", |
| 73 | + engine_class=EndToEndEngine) |
| 74 | +
|
| 75 | + cv_metrics = compute_cross_val_metrics(dataset="path/to/dataset.json", |
| 76 | + engine_class=EndToEndEngine, |
| 77 | + nb_folds=5) |
0 commit comments