Skip to main content

BIO and BEISO evaluation library

Project description

bioeval

License: MIT

CoNLL-2000 style evaluation of data using BIO and BEISO representation for mutli-token entities (i.e. chunks).

Change Log

  • bioeval now supports pandas DataFame objects through bioeval.evaluate_df.

Example:

import pandas as pd
from bioeval import evaluate_df

# form and POS tags are not necessary
df = pd.DataFrame(
    [
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-foo','guesstag': 'B-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'I-foo','guesstag': 'I-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'O','guesstag': 'O'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-bar','guesstag': 'B-bar'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-foo','guesstag': 'B-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'O','guesstag': 'O'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-foo','guesstag': 'B-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'I-foo','guesstag': 'I-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-bar','guesstag': 'B-bar'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'I-bar','guesstag': 'I-bar'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'O','guesstag': 'O'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-foo','guesstag': 'B-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-bar','guesstag': 'I-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'B-foo','guesstag': 'B-foo'},
        {'form': 'foo', 'pos': 'bar', 'chunktag': 'I-foo','guesstag': 'B-foo'}
    ]
)

f1, pr, re = evaluate_df(df, 'chunktag', 'guesstag')

print(f1)
>>> 62.5

Input format

chunk = {
    ((1, 'Gold', 'N', 'B-NP'),),
    ((2, 'is', 'V', 'B-MV'),),
    ((3, 'green', 'J', 'B-AP'),),
    ((4, '.', '.', 'B-NP'),),
    (
        (5, 'The', 'D', 'B-NP'),
        (6, 'red', 'J', 'I-NP'),
        (7, 'square', 'N', 'I-NP')
    ),
    ((8, 'is', 'V', 'B-MV'),),
    (
        (9, 'very', 'A', 'B-AP'),
        (10, 'boring', 'J', 'I-AP')
    ),
    ((8, '.', '.', 'O'),)
}

Install

In the root folder execute:

pip install -r requirements.txt .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bioeval-1.1.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

bioeval-1.1.1-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

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