ner-metrics


Namener-metrics JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/PL97/NER_eval
SummaryA simple Python snippets for NER evaluation
upload_time2023-09-27 06:14:33
maintainer
docs_urlNone
authorLe Peng
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## NER_eval
A simple implementation of strict/lenient matching to evaluate NER performance (precision, recall, F1-score) in 60 lines!

This script currently only supports the IOB2 format with both strict and lenient modes.

## Installation
```bash
pip install ner_metrics
```
or
```bash
pip install git+https://github.com/PL97/NER_eval.git
```


## Usage

```python
from ner_metrics import classification_report

y_true = ['B-PER', 'I-PER', 'O', 'B-ORG', 'B-ORG', 'O', 'O', 'B-PER', 'I-PER', 'O']
y_pred = ['O', 'B-PER', 'O', 'B-ORG', 'B-ORG', 'I-ORG', 'O', 'B-PER', 'I-PER', 'O']
classification_report(tags_true=y_true, tags_pred=y_pred, mode="lenient") # for lenient match

classification_report(tags_true=y_true, tags_pred=y_pred, mode="strict") # for strict match

```
Expected output
```
tag(lenient): PER        precision:1.0   recall:1.0      f1-score:1.0
tag(strict): PER         precision:0.5   recall:0.5      f1-score:0.5
tag(lenient): ORG        precision:1.0   recall:1.0      f1-score:1.0
tag(strict): ORG         precision:0.5   recall:0.5      f1-score:0.5
```
The results are also saved to *evaluation.json*

## How to cite this work

If you find this git repo useful, please consider citing it using the snippet below:
```bibtex
@misc{ner_eval,
    author={Le Peng},
    title={ner_metrics: A Simple Python Snippets for NER Evaluation},
    howpublished={\url{https://github.com/PL97/NER_eval}},
    year={2022}
}

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PL97/NER_eval",
    "name": "ner-metrics",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Le Peng",
    "author_email": "peng0347@umn.edu",
    "download_url": "https://files.pythonhosted.org/packages/43/0e/79dfa5a7e8f4d44356894029e21177e737ff2ce751ae9881c67fa036d852/ner_metrics-0.1.2.tar.gz",
    "platform": null,
    "description": "## NER_eval\nA simple implementation of strict/lenient matching to evaluate NER performance (precision, recall, F1-score) in 60 lines!\n\nThis script currently only supports the IOB2 format with both strict and lenient modes.\n\n## Installation\n```bash\npip install ner_metrics\n```\nor\n```bash\npip install git+https://github.com/PL97/NER_eval.git\n```\n\n\n## Usage\n\n```python\nfrom ner_metrics import classification_report\n\ny_true = ['B-PER', 'I-PER', 'O', 'B-ORG', 'B-ORG', 'O', 'O', 'B-PER', 'I-PER', 'O']\ny_pred = ['O', 'B-PER', 'O', 'B-ORG', 'B-ORG', 'I-ORG', 'O', 'B-PER', 'I-PER', 'O']\nclassification_report(tags_true=y_true, tags_pred=y_pred, mode=\"lenient\") # for lenient match\n\nclassification_report(tags_true=y_true, tags_pred=y_pred, mode=\"strict\") # for strict match\n\n```\nExpected output\n```\ntag(lenient): PER        precision:1.0   recall:1.0      f1-score:1.0\ntag(strict): PER         precision:0.5   recall:0.5      f1-score:0.5\ntag(lenient): ORG        precision:1.0   recall:1.0      f1-score:1.0\ntag(strict): ORG         precision:0.5   recall:0.5      f1-score:0.5\n```\nThe results are also saved to *evaluation.json*\n\n## How to cite this work\n\nIf you find this git repo useful, please consider citing it using the snippet below:\n```bibtex\n@misc{ner_eval,\n    author={Le Peng},\n    title={ner_metrics: A Simple Python Snippets for NER Evaluation},\n    howpublished={\\url{https://github.com/PL97/NER_eval}},\n    year={2022}\n}\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple Python snippets for NER evaluation",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/PL97/NER_eval"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c61a576c4cf8fade70cc01395343796ba014493d729bbea3a3676f7903d61b2",
                "md5": "7eef736d65f1ebd6169eef9af46a2817",
                "sha256": "8e1674eac5aaf66ea932d14159bb1c2125f85a20caba17c4db376b9c76bfc875"
            },
            "downloads": -1,
            "filename": "ner_metrics-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7eef736d65f1ebd6169eef9af46a2817",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4145,
            "upload_time": "2023-09-27T06:14:31",
            "upload_time_iso_8601": "2023-09-27T06:14:31.438128Z",
            "url": "https://files.pythonhosted.org/packages/8c/61/a576c4cf8fade70cc01395343796ba014493d729bbea3a3676f7903d61b2/ner_metrics-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "430e79dfa5a7e8f4d44356894029e21177e737ff2ce751ae9881c67fa036d852",
                "md5": "f73819de48a4d91ae02dd3f0c0452fb0",
                "sha256": "4e949963bf5fb9569ec23cd0faf1f285105c5e9aedb39b0256c94d03c0ae8700"
            },
            "downloads": -1,
            "filename": "ner_metrics-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "f73819de48a4d91ae02dd3f0c0452fb0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3754,
            "upload_time": "2023-09-27T06:14:33",
            "upload_time_iso_8601": "2023-09-27T06:14:33.470376Z",
            "url": "https://files.pythonhosted.org/packages/43/0e/79dfa5a7e8f4d44356894029e21177e737ff2ce751ae9881c67fa036d852/ner_metrics-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-27 06:14:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PL97",
    "github_project": "NER_eval",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ner-metrics"
}
        
Elapsed time: 0.26884s