# seqeval
seqeval is a Python framework for sequence labeling evaluation.
seqeval can evaluate the performance of chunking tasks such as named-entity recognition, part-of-speech tagging, semantic role labeling and so on.
This is well-tested by using the Perl script [conlleval](https://www.clips.uantwerpen.be/conll2002/ner/bin/conlleval.txt),
which can be used for measuring the performance of a system that has processed the CoNLL-2000 shared task data.
## Support features
seqeval supports following schemes:
- IOB1
- IOB2
- IOE1
- IOE2
- IOBES(only in strict mode)
- BILOU(only in strict mode)
and following metrics:
| metrics | description |
|---|---|
| accuracy_score(y\_true, y\_pred) | Compute the accuracy. |
| precision_score(y\_true, y\_pred) | Compute the precision. |
| recall_score(y\_true, y\_pred) | Compute the recall. |
| f1_score(y\_true, y\_pred) | Compute the F1 score, also known as balanced F-score or F-measure. |
| classification_report(y\_true, y\_pred, digits=2) | Build a text report showing the main classification metrics. `digits` is number of digits for formatting output floating point values. Default value is `2`. |
## Usage
seqeval supports the two evaluation modes. You can specify the following mode to each metrics:
- default
- strict
The default mode is compatible with [conlleval](https://www.clips.uantwerpen.be/conll2002/ner/bin/conlleval.txt). If you want to use the default mode, you don't need to specify it:
```python
>>> from seqeval.metrics import accuracy_score
>>> from seqeval.metrics import classification_report
>>> from seqeval.metrics import f1_score
>>> y_true = [['O', 'O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]
>>> y_pred = [['O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]
>>> f1_score(y_true, y_pred)
0.50
>>> classification_report(y_true, y_pred)
precision recall f1-score support
MISC 0.00 0.00 0.00 1
PER 1.00 1.00 1.00 1
micro avg 0.50 0.50 0.50 2
macro avg 0.50 0.50 0.50 2
weighted avg 0.50 0.50 0.50 2
```
In strict mode, the inputs are evaluated according to the specified schema. The behavior of the strict mode is different from the default one which is designed to simulate conlleval. If you want to use the strict mode, please specify `mode='strict'` and `scheme` arguments at the same time:
```python
>>> from seqeval.scheme import IOB2
>>> classification_report(y_true, y_pred, mode='strict', scheme=IOB2)
precision recall f1-score support
MISC 0.00 0.00 0.00 1
PER 1.00 1.00 1.00 1
micro avg 0.50 0.50 0.50 2
macro avg 0.50 0.50 0.50 2
weighted avg 0.50 0.50 0.50 2
```
A minimum case to explain differences between the default and strict mode:
```python
>>> from seqeval.metrics import classification_report
>>> from seqeval.scheme import IOB2
>>> y_true = [['B-NP', 'I-NP', 'O']]
>>> y_pred = [['I-NP', 'I-NP', 'O']]
>>> classification_report(y_true, y_pred)
precision recall f1-score support
NP 1.00 1.00 1.00 1
micro avg 1.00 1.00 1.00 1
macro avg 1.00 1.00 1.00 1
weighted avg 1.00 1.00 1.00 1
>>> classification_report(y_true, y_pred, mode='strict', scheme=IOB2)
precision recall f1-score support
NP 0.00 0.00 0.00 1
micro avg 0.00 0.00 0.00 1
macro avg 0.00 0.00 0.00 1
weighted avg 0.00 0.00 0.00 1
```
## Installation
To install seqeval, simply run:
```bash
pip install seqeval
```
## License
[MIT](https://github.com/chakki-works/seqeval/blob/master/LICENSE)
## Citation
```tex
@misc{seqeval,
title={{seqeval}: A Python framework for sequence labeling evaluation},
url={https://github.com/chakki-works/seqeval},
note={Software available from https://github.com/chakki-works/seqeval},
author={Hiroki Nakayama},
year={2018},
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/chakki-works/seqeval",
"name": "seqeval",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Hironsan",
"author_email": "hiroki.nakayama.py@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9d/2d/233c79d5b4e5ab1dbf111242299153f3caddddbb691219f363ad55ce783d/seqeval-1.2.2.tar.gz",
"platform": "",
"description": "# seqeval\n\nseqeval is a Python framework for sequence labeling evaluation.\nseqeval can evaluate the performance of chunking tasks such as named-entity recognition, part-of-speech tagging, semantic role labeling and so on.\n\nThis is well-tested by using the Perl script [conlleval](https://www.clips.uantwerpen.be/conll2002/ner/bin/conlleval.txt),\nwhich can be used for measuring the performance of a system that has processed the CoNLL-2000 shared task data.\n\n## Support features\n\nseqeval supports following schemes:\n\n- IOB1\n- IOB2\n- IOE1\n- IOE2\n- IOBES(only in strict mode)\n- BILOU(only in strict mode)\n\nand following metrics:\n\n| metrics | description |\n|---|---|\n| accuracy_score(y\\_true, y\\_pred) | Compute the accuracy. |\n| precision_score(y\\_true, y\\_pred) | Compute the precision. |\n| recall_score(y\\_true, y\\_pred) | Compute the recall. |\n| f1_score(y\\_true, y\\_pred) | Compute the F1 score, also known as balanced F-score or F-measure. |\n| classification_report(y\\_true, y\\_pred, digits=2) | Build a text report showing the main classification metrics. `digits` is number of digits for formatting output floating point values. Default value is `2`. |\n\n## Usage\n\nseqeval supports the two evaluation modes. You can specify the following mode to each metrics:\n\n- default\n- strict\n\nThe default mode is compatible with [conlleval](https://www.clips.uantwerpen.be/conll2002/ner/bin/conlleval.txt). If you want to use the default mode, you don't need to specify it:\n\n```python\n>>> from seqeval.metrics import accuracy_score\n>>> from seqeval.metrics import classification_report\n>>> from seqeval.metrics import f1_score\n>>> y_true = [['O', 'O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]\n>>> y_pred = [['O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]\n>>> f1_score(y_true, y_pred)\n0.50\n>>> classification_report(y_true, y_pred)\n precision recall f1-score support\n\n MISC 0.00 0.00 0.00 1\n PER 1.00 1.00 1.00 1\n\n micro avg 0.50 0.50 0.50 2\n macro avg 0.50 0.50 0.50 2\nweighted avg 0.50 0.50 0.50 2\n```\n\nIn strict mode, the inputs are evaluated according to the specified schema. The behavior of the strict mode is different from the default one which is designed to simulate conlleval. If you want to use the strict mode, please specify `mode='strict'` and `scheme` arguments at the same time:\n\n```python\n>>> from seqeval.scheme import IOB2\n>>> classification_report(y_true, y_pred, mode='strict', scheme=IOB2)\n precision recall f1-score support\n\n MISC 0.00 0.00 0.00 1\n PER 1.00 1.00 1.00 1\n\n micro avg 0.50 0.50 0.50 2\n macro avg 0.50 0.50 0.50 2\nweighted avg 0.50 0.50 0.50 2\n```\n\nA minimum case to explain differences between the default and strict mode:\n\n```python\n>>> from seqeval.metrics import classification_report\n>>> from seqeval.scheme import IOB2\n>>> y_true = [['B-NP', 'I-NP', 'O']]\n>>> y_pred = [['I-NP', 'I-NP', 'O']]\n>>> classification_report(y_true, y_pred)\n precision recall f1-score support\n NP 1.00 1.00 1.00 1\n micro avg 1.00 1.00 1.00 1\n macro avg 1.00 1.00 1.00 1\nweighted avg 1.00 1.00 1.00 1\n>>> classification_report(y_true, y_pred, mode='strict', scheme=IOB2)\n precision recall f1-score support\n NP 0.00 0.00 0.00 1\n micro avg 0.00 0.00 0.00 1\n macro avg 0.00 0.00 0.00 1\nweighted avg 0.00 0.00 0.00 1\n```\n\n## Installation\n\nTo install seqeval, simply run:\n\n```bash\npip install seqeval\n```\n\n## License\n\n[MIT](https://github.com/chakki-works/seqeval/blob/master/LICENSE)\n\n## Citation\n\n```tex\n@misc{seqeval,\n title={{seqeval}: A Python framework for sequence labeling evaluation},\n url={https://github.com/chakki-works/seqeval},\n note={Software available from https://github.com/chakki-works/seqeval},\n author={Hiroki Nakayama},\n year={2018},\n}\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Testing framework for sequence labeling",
"version": "1.2.2",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "8b722ecf75550c587f79f2425e3a4d40",
"sha256": "f28e97c3ab96d6fcd32b648f6438ff2e09cfba87f05939da9b3970713ec56e6f"
},
"downloads": -1,
"filename": "seqeval-1.2.2.tar.gz",
"has_sig": false,
"md5_digest": "8b722ecf75550c587f79f2425e3a4d40",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 43605,
"upload_time": "2020-10-24T00:24:54",
"upload_time_iso_8601": "2020-10-24T00:24:54.926204Z",
"url": "https://files.pythonhosted.org/packages/9d/2d/233c79d5b4e5ab1dbf111242299153f3caddddbb691219f363ad55ce783d/seqeval-1.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-10-24 00:24:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "chakki-works",
"github_project": "seqeval",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "seqeval"
}