Skip to content

Commit

Permalink
updated the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravarthik27 committed Oct 9, 2024
1 parent aace0f7 commit dc408e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
11 changes: 9 additions & 2 deletions langtest/transform/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import defaultdict
import pandas as pd
from abc import ABC, abstractmethod
from typing import Any, DefaultDict, Dict, List, Type
from typing import Any, DefaultDict, Dict, List, Type, Union

from langtest.modelhandler.modelhandler import ModelAPI
from langtest.transform.base import ITests
Expand Down Expand Up @@ -1213,9 +1213,16 @@ async def run(
return []

@staticmethod
def preprocess(y_true, y_pred):
def preprocess(y_true: List, y_pred: List):
"""
Preprocesses the input data for the degradation analysis.
Args:
y_true (List): The true labels.
y_pred (List): The predicted labels.
Returns:
Tuple[pd.Series, pd.Series]: The preprocessed true and predicted labels.
"""

if isinstance(y_true, list):
Expand Down
16 changes: 13 additions & 3 deletions langtest/utils/util_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,19 @@ def calculate_f1_score_multi_label(

def combine_labels(labels: List[str]) -> List[str]:
"""
Combines labels for degradation analysis.
input labels: ["B-ORG", "I-ORG", "B-PER", "I-PER"]
output labels: ["ORG", "PER"]
Combine labels by removing the BIO tags and keeping only the entity type.
Args:
labels (List[str]): List of strings or a string. Labels can be in the format of BIO tags.
Example: ["B-ORG", "I-ORG", "B-PER", "I-PER"]
Raises:
ValueError: If the input is not a list or a string.
Returns:
labels (List[str]): List of entity types without the BIO tags.
"""
try:
output_list = []
Expand Down

0 comments on commit dc408e8

Please sign in to comment.