Skip to main content

seq is a seq eval package

Project description

seq is a seq eval package

# -*- 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)

Project details


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.1.2-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file seqmetric-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: seqmetric-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.8.9

File hashes

Hashes for seqmetric-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e09d32c237a48fd24e54e107fbf76ded7a45bc77a40a6cc8902052d26befbec4
MD5 763c97c58dda7dbd856550960ed74ed1
BLAKE2b-256 36369107293afb123fd604be3298d3f7e1b26ec2653449cfee4bf55a7bd35c3a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page