seq是一个基于序列评估包
Project description
seq是一个基于序列评估包
# -*- 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 pt_class_report
# 场景2
label_list = ['0','1']
#label_id 0 , 1
trues = [[(0 , 10,20 ),], [(0 , 10,20)]] # label_id ,start ,end
preds = [[(0 , 10,20 ),],[]]
report ,f1 = pt_class_report(trues,preds,label_list)
print(report ,f1)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
seqmetric-0.0.3-py3-none-any.whl
(16.4 kB
view hashes)
Close
Hashes for seqmetric-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bb93b0e40c5f4fc4d679e642225cc996bc67f8d7fe60eeeb8687a594e277002 |
|
MD5 | 50e66c4f55d874f3f41e3677979604e0 |
|
BLAKE2b-256 | 0e78527e45d29967dad2932cc1a8b7135a97539c802900ea80407d1fd295da86 |