seq is a seq eval package
```py
# -*- coding: utf-8 -*-
import sys
import numpy as np
sys.path.append('..')
from seqmetric.scheme import IOBS,IOBES,IOB2
from seqmetric.metrics import classification_report,f1_score
#场景1
mode = 2
trues = [['O', 'O', 'B-MISC', 'I-MISC', 'B-MISC', 'O', 'O'], ['B-PER', 'I-PER', 'O']]
preds = [['O', 'O', 'B-MISC', 'I-MISC', 'B-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]
if mode == 0:
scheme = IOBES
elif mode == 1:
scheme = IOBS
else:
scheme = IOB2
f1 = f1_score(trues, preds, average='weighted',scheme=scheme)
report = classification_report(trues, preds, scheme=scheme,digits=4)
print(f1)
print(report)
from seqmetric.metrics import pointer_report,report_metric,get_report_from_string,spo_report
# 场景2
label_list = ['0','1']
trues = [
[(0 , 10,20 ),],
[(0 , 10,20)],
[],
[(1,100,201)]
] # label_id ,start ,end
preds = [
[(0 , 10,20 ),],
[],
[(1,100,200)],
[]
]
str_report = pointer_report(trues, preds, label_list)
print(str_report)
report = get_report_from_string(str_report)
print(report)
label_list = ['0','1']
trues = [
[(0, 10,0,20,30),],
[(1, 10, 0, 20, 30), ]
]
preds = [
[(0, 10, 0, 20, 30), ],
[
],
]
str_report = spo_report(trues,preds,label_list=label_list)
print(str_report)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ssbuild",
"name": "seqmetric",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3, <4",
"maintainer_email": "",
"keywords": "seqmetric,seq metric,seq,ner metric,metric,ner",
"author": "ssbuild",
"author_email": "9727464@qq.com",
"download_url": "",
"platform": "win32_AMD64",
"description": "seq is a seq eval package\n\n```py\n# -*- coding: utf-8 -*-\nimport sys\nimport numpy as np\nsys.path.append('..')\nfrom seqmetric.scheme import IOBS,IOBES,IOB2\nfrom seqmetric.metrics import classification_report,f1_score\n\n#\u573a\u666f1\nmode = 2\ntrues = [['O', 'O', 'B-MISC', 'I-MISC', 'B-MISC', 'O', 'O'], ['B-PER', 'I-PER', 'O']]\npreds = [['O', 'O', 'B-MISC', 'I-MISC', 'B-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]\n\nif mode == 0:\n scheme = IOBES\nelif mode == 1:\n scheme = IOBS\nelse:\n scheme = IOB2\nf1 = f1_score(trues, preds, average='weighted',scheme=scheme)\nreport = classification_report(trues, preds, scheme=scheme,digits=4)\nprint(f1)\nprint(report)\n\nfrom seqmetric.metrics import pointer_report,report_metric,get_report_from_string,spo_report\n\n# \u573a\u666f2\n\nlabel_list = ['0','1']\n\ntrues = [\n [(0 , 10,20 ),],\n [(0 , 10,20)],\n [],\n [(1,100,201)]\n ] # label_id ,start ,end\n\npreds = [\n [(0 , 10,20 ),],\n [],\n [(1,100,200)],\n []\n ]\n\nstr_report = pointer_report(trues, preds, label_list)\nprint(str_report)\n\n\n\nreport = get_report_from_string(str_report)\nprint(report)\n\n\n\nlabel_list = ['0','1']\ntrues = [\n [(0, 10,0,20,30),],\n [(1, 10, 0, 20, 30), ]\n]\n\npreds = [\n [(0, 10, 0, 20, 30), ],\n [\n ],\n]\n\nstr_report = spo_report(trues,preds,label_list=label_list)\nprint(str_report)\n```\n\n\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "seq is a seq eval package",
"version": "0.1.2",
"split_keywords": [
"seqmetric",
"seq metric",
"seq",
"ner metric",
"metric",
"ner"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "763c97c58dda7dbd856550960ed74ed1",
"sha256": "e09d32c237a48fd24e54e107fbf76ded7a45bc77a40a6cc8902052d26befbec4"
},
"downloads": -1,
"filename": "seqmetric-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "763c97c58dda7dbd856550960ed74ed1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3, <4",
"size": 17388,
"upload_time": "2022-11-25T09:26:07",
"upload_time_iso_8601": "2022-11-25T09:26:07.084422Z",
"url": "https://files.pythonhosted.org/packages/36/36/9107293afb123fd604be3298d3f7e1b26ec2653449cfee4bf55a7bd35c3a/seqmetric-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-11-25 09:26:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "seqmetric"
}