Context#

class Context[source]#

Contains all the data + properties the user has passed to a check/suite, and validates it seamlessly.

Parameters
train_datasetUnion[TextData, None] , default: None

TextData object, representing data an estimator was fitted on

test_datasetUnion[TextData, None] , default: None

TextData object, representing data an estimator predicts on

with_displaybool , default: True

flag that determines if checks will calculate display (redundant in some checks).

train_predUnion[TTextPred, None] , default: None

predictions on train dataset

test_predUnion[TTextPred, None] , default: None

predictions on test dataset

train_probaUnion[TTextProba, None] , default: None

probabilities on train dataset

test_probaUnion[TTextProba, None] , default: None

probabilities on test dataset

model_classesOptional[List] , default: None

list of classes known to the model

random_state: int, default 42

A seed to set for pseudo-random functions , primarily sampling.

__init__(train_dataset: Optional[TextData] = None, test_dataset: Optional[TextData] = None, with_display: bool = True, train_pred: Optional[Union[Sequence[int], Sequence[str], Sequence[Sequence[int]], Sequence[Sequence[str]]]] = None, test_pred: Optional[Union[Sequence[int], Sequence[str], Sequence[Sequence[int]], Sequence[Sequence[str]]]] = None, train_proba: Optional[Sequence[Sequence[float]]] = None, test_proba: Optional[Sequence[Sequence[float]]] = None, model_classes: Optional[List] = None, random_state: int = 42)[source]#
__new__(*args, **kwargs)#

Attributes

Context.common_datasets_properties

Return common for train and test datasets properties.

Context.model

Return model if exists, otherwise raise error.

Context.model_classes

Return ordered list of possible label classes for classification tasks.

Context.model_name

Return the name of the model.

Context.observed_classes

Return the observed classes in both train and test.

Context.task_type

Return task type if model & train_dataset & label exists.

Context.test

Return test if exists, otherwise raise error.

Context.train

Return train if exists, otherwise raise error.

Context.with_display

Return the with_display flag.

Methods

Context.assert_task_type(*expected_types)

Assert task_type matching given types.

Context.finalize_check_result(check_result, ...)

Run final processing on a check result which includes validation, conditions processing and sampling footnote.

Context.get_data_by_kind(kind)

Return the relevant Dataset by given kind.

Context.get_scorers([scorers, use_avg_defaults])

Return initialized & validated scorers if provided or default scorers otherwise.

Context.get_single_scorer([scorer, ...])

Return initialized & validated scorer if provided or a default scorer otherwise.

Context.have_test()

Return whether there is test_dataset dataset defined.

Context.infer_task_type(train_dataset, ...)

Infer the task type.

Context.is_multi_label_task()

Return whether the task is multi-label classification.

Context.raise_if_multi_label_task([check])

Raise an exception if it is a multi-label classification task.

Context.raise_if_token_classification_task([check])

Raise an exception if it is a token classification task.