Skip to main content

classy.scripts.model.describe

Functions​

get_random_color​

def get_random_color() ‑> str

get_ui_metrics​

def get_ui_metrics(
    task: str,
    tokenize: Optional[str],
) ‑> List[UIMetric]

Method that chooses the metrics to display based on the task and on the tokenization.

Args​
task
one of Sequence, Sentence-pair, Token and QA
tokenize
the tokenizer language. Must be a valid language code for sacremoses. None means no tokenization
Returns​

the list of UIMetrics selected based on task and tokenization

init_layout​

def init_layout(
    task: str,
    dataset_path: str,
    metrics: Iterable[UIMetric],
)

main​

def main()

parse_args​

def parse_args()

Classes​

AnswerPositionUIMetric​

class AnswerPositionUIMetric()

UIMetric to compute the distribution of the position of the answers in the context.

description​

def description(
    self,
) ‑> Union[str, List[str], None]

is_writable​

def is_writable(
    self,
) ‑> bool

title​

def title(
    self,
) ‑> Union[str, List[str], None]

update_metric​

def update_metric(
    self,
    dataset_sample: QASample,
) ‑> None

write_body​

def write_body(
    self,
) ‑> None

ClassSpecificInputLenUIMetric​

class ClassSpecificInputLenUIMetric()

The class specific variant of "InputLenUIMetric". It computes all the stats of the InputLenUIMetric but for each class separated.

__init__​

def __init__(
    title_format: str,
    description_format: str,
)

description​

def description(
    self,
) ‑> Union[str, List[str], None]

is_writable​

def is_writable(
    self,
) ‑> bool

title​

def title(
    self,
) ‑> Union[str, List[str], None]

update_metric​

def update_metric(
    self,
    dataset_sample,
) ‑> None

write_body​

def write_body(
    self,
) ‑> None

write_metric​

def write_metric(
    self,
) ‑> None

InfoBoxUIMetric​

class InfoBoxUIMetric()

Base class for metrics that knows how to update themselves with an iterable of dataset samples and how to update the streamlit page on the base of the computed metric.

is_writable​

def is_writable(
    self,
) ‑> bool

write_metric​

def write_metric(
    self,
) ‑> None

InputLenUIMetric​

class InputLenUIMetric()

Simple metric to compute Avg, Max and Min length on the passed sequences (e.g. QA contexts). The length can be computed both on the number of characters and on the number of tokens depending on the input dataset_sample type.

__init__​

def __init__(
    title: str,
    description: str,
)

description​

def description(
    self,
) ‑> Union[str, List[str], None]

is_writable​

def is_writable(
    self,
) ‑> bool

title​

def title(
    self,
) ‑> Optional[str]

update_metric​

def update_metric(
    self,
    dataset_sample: Union[str, List[str], Tuple[List[str], ClassySample]],
) ‑> None

Update the metrics lengths store

Args​
dataset_sample
can be - str: a text sequence - List[str]: list of tokens - Tuple[List[str], ClassySample]: a tuple containing a list of tokens along with the original_sample
Returns​

None

write_body​

def write_body(
    self,
) ‑> None

LabelsUIMetric​

class LabelsUIMetric()

UIMetrics to compute the classes distribution in the dataset both counting them (histogram) and computing their frequency (pie chart).

description​

def description(
    self,
) ‑> Union[str, List[str], None]

is_writable​

def is_writable(
    self,
) ‑> bool

title​

def title(
    self,
) ‑> str

update_metric​

def update_metric(
    self,
    dataset_sample: Union[SequenceSample, SentencePairSample, TokensSample],
) ‑> None

write_body​

def write_body(
    self,
) ‑> None

LambdaWrapperUIMetric​

class LambdaWrapperUIMetric()

UIMetric wrapper that let you define a lambda function as an indirection between the dataset_sample and the update_metric. e.g. "lambda dataset_sample: tokenize(dataset_sample.sequence)" in order to pass the input already tokenized.

__init__​

def __init__(
    ui_metric: Union[UIMetric, List[UIMetric]],
    dataset_sample_modifier,
)

description​

def description(
    self,
) ‑> Union[str, List[str], None]

is_writable​

def is_writable(
    self,
) ‑> bool

title​

def title(
    self,
) ‑> Union[str, List[str], None]

update_metric​

def update_metric(
    self,
    dataset_sample: Union[ClassySample, str],
) ‑> None

write_body​

def write_body(
    self,
) ‑> None

write_metric​

def write_metric(
    self,
) ‑> None

UIMetric​

class UIMetric()

Base class for metrics that knows how to update themselves with an iterable of dataset samples and how to update the streamlit page on the base of the computed metric.

Subclasses (6)

description​

def description(
    self,
) ‑> Union[str, List[str], None]

is_writable​

def is_writable(
    self,
) ‑> bool

title​

def title(
    self,
) ‑> Union[str, List[str], None]

update_metric​

def update_metric(
    self,
    dataset_sample: Union[ClassySample, str],
) ‑> None

write_body​

def write_body(
    self,
) ‑> None

write_metric​

def write_metric(
    self,
) ‑> None

UIMetricsManager​

class UIMetricsManager()

Manager that takes care of instantiating the metrics, updating the metrics on the dataset samples and write them

__init__​

def __init__(
    task: str,
    dataset_path: str,
    tokenize: str,
)

update_metrics​

def update_metrics(
    self,
    task: str,
    dataset_path: str,
) ‑> None

write_metrics​

def write_metrics(
    self,
) ‑> None