Open In Colab View Notebook on GitHub

Medical transcript classification [scikit-learn]

Giskard is an open-source framework for testing all ML models, from LLMs to tabular models. Don’t hesitate to give the project a star on GitHub ⭐️ if you find it useful!

In this notebook, you’ll learn how to create comprehensive test suites for your model in a few lines of code, thanks to Giskard’s open-source Python library.

Use-case:

Outline:

  • Detect vulnerabilities automatically with Giskard’s scan

  • Automatically generate & curate a comprehensive test suite to test your model beyond accuracy-related metrics

Install dependencies

Make sure to install the giskard

[ ]:
%pip install giskard --upgrade

We also install the project-specific dependencies for this tutorial.

[ ]:
%pip install nltk

Import libraries

[1]:
import string
from pathlib import Path
from urllib.request import urlretrieve

import nltk
import pandas as pd
from nltk.corpus import stopwords
from nltk.stem.snowball import SnowballStemmer
from sklearn.ensemble import RandomForestClassifier
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics import classification_report
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import FunctionTransformer
from typing import Iterable

from giskard import Dataset, Model, scan, testing

Define constants

[2]:
# Constants.
LABELS_LIST = [
    'Neurosurgery',
    'ENT - Otolaryngology',
    'Discharge Summary',
    'General Medicine',
    'Gastroenterology',
    'Neurology',
    'SOAP / Chart / Progress Notes',
    'Obstetrics / Gynecology',
    'Urology'
]

TEXT_COLUMN_NAME = "transcription"
TARGET_COLUMN_NAME = "medical_specialty"

RANDOM_SEED = 8888

# Data.
DATA_URL = "ftp://sys.giskard.ai/pub/unit_test_resources/medical_transcript_classification_dataset/mtsamples.csv"
DATA_PATH = Path.home() / ".giskard" / "medical_transcript_classification_dataset" / "mtsamples.csv"

Dataset preparation

Download NLTK stopwords corpus

[ ]:
# Download list of english stopwords.
nltk.download('stopwords')

Load data

[4]:
def fetch_from_ftp(url: str, file: Path) -> None:
    """Helper to fetch data from the FTP server."""
    if not file.parent.exists():
        file.parent.mkdir(parents=True, exist_ok=True)

    if not file.exists():
        print(f"Downloading data from {url}")
        urlretrieve(url, file)

    print(f"Data was loaded!")


def load_data() -> pd.DataFrame:
    """Load and initially preprocess data."""
    fetch_from_ftp(DATA_URL, DATA_PATH)

    df = pd.read_csv(DATA_PATH)

    # Drop useless columns.
    df = df.drop(columns=['Unnamed: 0', "description", "sample_name", "keywords"])

    # Trim text.
    df = df.apply(lambda x: x.str.strip())

    # Filter samples by label.
    df = df[df[TARGET_COLUMN_NAME].isin(LABELS_LIST)]

    # Drop rows with no transcript.
    df = df[df[TEXT_COLUMN_NAME].notna()]

    return df
[ ]:
transcript_df = load_data()

Train-test split

[6]:
X_train, X_test, y_train, y_test = train_test_split(transcript_df[[TEXT_COLUMN_NAME]],
                                                    transcript_df[TARGET_COLUMN_NAME],
                                                    random_state=RANDOM_SEED)

Wrap dataset with Giskard

To prepare for the vulnerability scan, make sure to wrap your dataset using Giskard’s Dataset class. More details here.

[ ]:
raw_data = pd.concat([X_test, y_test], axis=1)
giskard_dataset = Dataset(
    df=raw_data,
    # A pandas.DataFrame that contains the raw data (before all the pre-processing steps) and the actual ground truth variable (target).
    name="medical_transcript_dataset",  # Ground truth variable.
    target=TARGET_COLUMN_NAME  # Optional.
)

Model building

Define preprocessing steps

[8]:
stemmer = SnowballStemmer("english")
stop_words = stopwords.words("english")


def preprocess_text(df: pd.DataFrame) -> pd.DataFrame:
    """Preprocess text."""
    # Lower.
    df[TEXT_COLUMN_NAME] = df[TEXT_COLUMN_NAME].apply(lambda x: x.lower())

    # Remove punctuation.
    df[TEXT_COLUMN_NAME] = df[TEXT_COLUMN_NAME].apply(lambda x: x.translate(str.maketrans('', '', string.punctuation)))

    # Tokenize.
    df[TEXT_COLUMN_NAME] = df[TEXT_COLUMN_NAME].apply(lambda x: x.split())

    # Stem.
    df[TEXT_COLUMN_NAME] = df[TEXT_COLUMN_NAME].apply(lambda x: [stemmer.stem(word) for word in x])

    # Remove stop-words.
    df[TEXT_COLUMN_NAME] = df[TEXT_COLUMN_NAME].apply(
        lambda x: ' '.join([word for word in x if word not in stop_words]))

    return df


def adapt_vectorizer_input(df: pd.DataFrame) -> Iterable:
    """Adapt input for the vectorizers.

    The problem is that vectorizers accept iterable, not DataFrame, but Series. Thus, we need to ravel dataframe with text have input single dimension.
    Issue reference: https://stackoverflow.com/questions/50665240/valueerror-found-input-variables-with-inconsistent-numbers-of-samples-1-3185"""

    df = df.iloc[:, 0]
    return df


text_preprocessor = FunctionTransformer(preprocess_text)
vectorizer_input_adapter = FunctionTransformer(adapt_vectorizer_input)

Build estimator

[ ]:
pipeline = Pipeline(steps=[
    ("text_preprocessor", text_preprocessor),
    ("vectorizer_input_adapter", vectorizer_input_adapter),
    ("vectorizer", CountVectorizer(ngram_range=(1, 1))),
    ("estimator", RandomForestClassifier(random_state=RANDOM_SEED))
])

pipeline.fit(X_train, y_train)
y_pred = pipeline.predict(X_test)

print(classification_report(y_test, y_pred))

Wrap model with Giskard

To prepare for the vulnerability scan, make sure to wrap your model using Giskard’s Model class. You can choose to either wrap the prediction function (preferred option) or the model object. More details here.

[ ]:
# Wrap the prediction function
def prediction_function(df):
    return pipeline.predict_proba(df)


giskard_model = Model(
    model=prediction_function,
    # A prediction function that encapsulates all the data pre-processing steps and that could be executed with the dataset used by the scan.
    model_type="classification",  # Either regression, classification or text_generation.
    name="medical_transcript_classification",  # Optional.
    classification_labels=pipeline.classes_,  # Their order MUST be identical to the prediction_function's output order.
    feature_names=[TEXT_COLUMN_NAME]  # Default: all columns of your dataset.
)

# Validate wrapped model.
print(classification_report(y_test, pipeline.classes_[giskard_model.predict(giskard_dataset).raw_prediction]))

Detect vulnerabilities in your model

Scan your model for vulnerabilities with Giskard

Giskard’s scan allows you to detect vulnerabilities in your model automatically. These include performance biases, unrobustness, data leakage, stochasticity, underconfidence, ethical issues, and more. For detailed information about the scan feature, please refer to our scan documentation.

[ ]:
results = scan(giskard_model, giskard_dataset)
[12]:
display(results)

Generate comprehensive test suites automatically for your model

Generate test suites from the scan

The objects produced by the scan can be used as fixtures to generate a test suite that integrate all detected vulnerabilities. Test suites allow you to evaluate and validate your model’s performance, ensuring that it behaves as expected on a set of predefined test cases, and to identify any regressions or issues that might arise during development or updates.

[14]:
test_suite = results.generate_test_suite("My first test suite")
test_suite.run()
2024-05-29 13:49:53,802 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:53,804 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (371, 2) executed in 0:00:00.009591
2024-05-29 13:49:54,057 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,048 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (371, 2) executed in 0:00:00.998800
2024-05-29 13:49:55,051 pid:66538 MainThread giskard.utils.logging_utils INFO     Perturb and predict data executed in 0:00:01.259399
2024-05-29 13:49:55,051 pid:66538 MainThread giskard.utils.logging_utils INFO     Compare and predict the data executed in 0:00:00.000281
Executed 'Invariance to “Add typos”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'transformation_function': <giskard.scanner.robustness.text_transformations.TextTypoTransformation object at 0x16ac02200>, 'threshold': 0.95, 'output_sensitivity': 0.05}:
               Test failed
               Metric: 0.9
                - [INFO] 371 rows were perturbed

2024-05-29 13:49:55,070 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,071 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (60, 2) executed in 0:00:00.005307
Executed 'Overconfidence on data slice “`transcription` contains "temperature"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176666d70>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.73


2024-05-29 13:49:55,090 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,091 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (97, 2) executed in 0:00:00.006231
Executed 'Overconfidence on data slice “`transcription` contains "dr"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176664670>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.73


2024-05-29 13:49:55,111 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,112 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (76, 2) executed in 0:00:00.007671
Executed 'Overconfidence on data slice “`transcription` contains "weight"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176ef35e0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.72


2024-05-29 13:49:55,132 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,132 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (65, 2) executed in 0:00:00.006201
Executed 'Overconfidence on data slice “`transcription` contains "having"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176ef3ee0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.72


2024-05-29 13:49:55,151 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,152 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (71, 2) executed in 0:00:00.005367
Executed 'Overconfidence on data slice “`transcription` contains "today"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176fb60e0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.72


2024-05-29 13:49:55,172 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,173 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (80, 2) executed in 0:00:00.005348
Executed 'Overconfidence on data slice “`transcription` contains "follow"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1765f3a30>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.7


2024-05-29 13:49:55,191 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,192 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (191, 2) executed in 0:00:00.008549
Executed 'Overconfidence on data slice “`transcription` contains "blood"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176691270>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.7


2024-05-29 13:49:55,213 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,214 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (70, 2) executed in 0:00:00.007286
Executed 'Overconfidence on data slice “`transcription` contains "distress"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17678f070>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.69


2024-05-29 13:49:55,236 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,237 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (126, 2) executed in 0:00:00.007065
Executed 'Overconfidence on data slice “`transcription` contains "stable"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1765ffee0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.68


2024-05-29 13:49:55,257 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,258 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (93, 2) executed in 0:00:00.006464
Executed 'Overconfidence on data slice “`transcription` contains "mg"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f7fbe0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.68


2024-05-29 13:49:55,270 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,271 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (214, 2) executed in 0:00:00.009823
Executed 'Overconfidence on data slice “`text_length(transcription)` >= 2145.000”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.text_slicer.MetadataSliceFunction object at 0x1767b1330>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.68


2024-05-29 13:49:55,291 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,292 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (85, 2) executed in 0:00:00.006814
Executed 'Overconfidence on data slice “`transcription` contains "discharge"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176718eb0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.67


2024-05-29 13:49:55,312 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,313 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (101, 2) executed in 0:00:00.007278
Executed 'Overconfidence on data slice “`transcription` contains "hospital"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176690c70>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.67


2024-05-29 13:49:55,334 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,335 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (52, 2) executed in 0:00:00.006081
Executed 'Overconfidence on data slice “`transcription` contains "continue"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1766a7bb0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.67


2024-05-29 13:49:55,354 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,355 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (76, 2) executed in 0:00:00.005812
Executed 'Overconfidence on data slice “`transcription` contains "vital"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1760639a0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}:
               Test failed
               Metric: 0.67


2024-05-29 13:49:55,374 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,375 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (22, 2) executed in 0:00:00.005195
Executed 'Precision on data slice “`transcription` contains "xyz"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17703d9c0>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.32


2024-05-29 13:49:55,397 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,398 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (30, 2) executed in 0:00:00.004141
Executed 'Precision on data slice “`transcription` contains "subjective"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17678d5a0>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.37


2024-05-29 13:49:55,417 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,418 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (64, 2) executed in 0:00:00.005701
Executed 'Precision on data slice “`transcription` contains "admission"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f8c670>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.38


2024-05-29 13:49:55,438 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,439 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (65, 2) executed in 0:00:00.005455
Executed 'Precision on data slice “`transcription` contains "daily"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17673be80>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.38


2024-05-29 13:49:55,460 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,462 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (23, 2) executed in 0:00:00.006355
Executed 'Precision on data slice “`transcription` contains "coronary"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f9ce80>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.39


2024-05-29 13:49:55,482 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,484 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (23, 2) executed in 0:00:00.005071
Executed 'Precision on data slice “`transcription` contains "aspirin"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f9d600>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.39


2024-05-29 13:49:55,505 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,506 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (48, 2) executed in 0:00:00.005088
Executed 'Precision on data slice “`transcription` contains "followup"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176666a10>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.4


2024-05-29 13:49:55,526 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,528 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (20, 2) executed in 0:00:00.005684
Executed 'Precision on data slice “`transcription` contains "lung"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1760120e0>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.4


2024-05-29 13:49:55,549 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,550 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (50, 2) executed in 0:00:00.006254
Executed 'Precision on data slice “`transcription` contains "count"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176646980>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.4


2024-05-29 13:49:55,581 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,593 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (29, 2) executed in 0:00:00.016641
Executed 'Precision on data slice “`transcription` contains "function"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f5c400>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.41


2024-05-29 13:49:55,648 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,649 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (24, 2) executed in 0:00:00.008552
Executed 'Precision on data slice “`transcription` contains "abc"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17703e5c0>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.42


2024-05-29 13:49:55,679 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,681 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (31, 2) executed in 0:00:00.007550
Executed 'Precision on data slice “`transcription` contains "improved"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17703fdc0>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.42


2024-05-29 13:49:55,703 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,704 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (52, 2) executed in 0:00:00.006033
Executed 'Precision on data slice “`transcription` contains "continue"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176739300>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.42


2024-05-29 13:49:55,725 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,726 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (85, 2) executed in 0:00:00.006033
Executed 'Precision on data slice “`transcription` contains "discharge"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1765f1d50>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.42


2024-05-29 13:49:55,862 pid:66538 MainThread giskard.datasets.base INFO     Casting dataframe columns from {'transcription': 'object'} to {'transcription': 'object'}
2024-05-29 13:49:55,863 pid:66538 MainThread giskard.utils.logging_utils INFO     Predicted dataset with shape (23, 2) executed in 0:00:00.005574
Executed 'Precision on data slice “`transcription` contains "greater"”' with arguments {'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176ef0940>, 'threshold': 0.5787061994609164}:
               Test failed
               Metric: 0.43


2024-05-29 13:49:55,866 pid:66538 MainThread giskard.core.suite INFO     Executed test suite 'My first test suite'
2024-05-29 13:49:55,866 pid:66538 MainThread giskard.core.suite INFO     result: failed
2024-05-29 13:49:55,866 pid:66538 MainThread giskard.core.suite INFO     Invariance to “Add typos” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'transformation_function': <giskard.scanner.robustness.text_transformations.TextTypoTransformation object at 0x16ac02200>, 'threshold': 0.95, 'output_sensitivity': 0.05}): {failed, metric=0.9029649595687331}
2024-05-29 13:49:55,867 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "temperature"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176666d70>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.7333333333333333}
2024-05-29 13:49:55,867 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "dr"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176664670>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.7254901960784313}
2024-05-29 13:49:55,867 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "weight"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176ef35e0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.71875}
2024-05-29 13:49:55,867 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "having"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176ef3ee0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.71875}
2024-05-29 13:49:55,868 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "today"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176fb60e0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.717948717948718}
2024-05-29 13:49:55,868 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "follow"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1765f3a30>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.7027027027027027}
2024-05-29 13:49:55,869 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "blood"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176691270>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.6973684210526315}
2024-05-29 13:49:55,869 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "distress"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17678f070>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.6944444444444444}
2024-05-29 13:49:55,870 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "stable"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1765ffee0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.6808510638297872}
2024-05-29 13:49:55,870 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "mg"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f7fbe0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.68}
2024-05-29 13:49:55,870 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`text_length(transcription)` >= 2145.000” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.text_slicer.MetadataSliceFunction object at 0x1767b1330>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.6756756756756757}
2024-05-29 13:49:55,870 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "discharge"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176718eb0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.673469387755102}
2024-05-29 13:49:55,871 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "hospital"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176690c70>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.6666666666666666}
2024-05-29 13:49:55,871 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "continue"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1766a7bb0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.6666666666666666}
2024-05-29 13:49:55,871 pid:66538 MainThread giskard.core.suite INFO     Overconfidence on data slice “`transcription` contains "vital"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1760639a0>, 'threshold': 0.6524137931034483, 'p_threshold': 0.2468526289804987}): {failed, metric=0.6666666666666666}
2024-05-29 13:49:55,871 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "xyz"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17703d9c0>, 'threshold': 0.5787061994609164}): {failed, metric=0.3181818181818182}
2024-05-29 13:49:55,872 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "subjective"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17678d5a0>, 'threshold': 0.5787061994609164}): {failed, metric=0.36666666666666664}
2024-05-29 13:49:55,873 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "admission"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f8c670>, 'threshold': 0.5787061994609164}): {failed, metric=0.375}
2024-05-29 13:49:55,873 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "daily"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17673be80>, 'threshold': 0.5787061994609164}): {failed, metric=0.38461538461538464}
2024-05-29 13:49:55,873 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "coronary"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f9ce80>, 'threshold': 0.5787061994609164}): {failed, metric=0.391304347826087}
2024-05-29 13:49:55,873 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "aspirin"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f9d600>, 'threshold': 0.5787061994609164}): {failed, metric=0.391304347826087}
2024-05-29 13:49:55,873 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "followup"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176666a10>, 'threshold': 0.5787061994609164}): {failed, metric=0.3958333333333333}
2024-05-29 13:49:55,874 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "lung"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1760120e0>, 'threshold': 0.5787061994609164}): {failed, metric=0.4}
2024-05-29 13:49:55,874 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "count"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176646980>, 'threshold': 0.5787061994609164}): {failed, metric=0.4}
2024-05-29 13:49:55,875 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "function"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176f5c400>, 'threshold': 0.5787061994609164}): {failed, metric=0.41379310344827586}
2024-05-29 13:49:55,875 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "abc"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17703e5c0>, 'threshold': 0.5787061994609164}): {failed, metric=0.4166666666666667}
2024-05-29 13:49:55,876 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "improved"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x17703fdc0>, 'threshold': 0.5787061994609164}): {failed, metric=0.41935483870967744}
2024-05-29 13:49:55,876 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "continue"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176739300>, 'threshold': 0.5787061994609164}): {failed, metric=0.4230769230769231}
2024-05-29 13:49:55,877 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "discharge"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x1765f1d50>, 'threshold': 0.5787061994609164}): {failed, metric=0.4235294117647059}
2024-05-29 13:49:55,878 pid:66538 MainThread giskard.core.suite INFO     Precision on data slice “`transcription` contains "greater"” ({'model': <giskard.models.function.PredictionFunctionModel object at 0x109889240>, 'dataset': <giskard.datasets.base.Dataset object at 0x16ac01570>, 'slicing_function': <giskard.slicing.slice.QueryBasedSliceFunction object at 0x176ef0940>, 'threshold': 0.5787061994609164}): {failed, metric=0.43478260869565216}
[14]:
close Test suite failed.
Test Invariance to “Add typos”
Measured Metric = 0.90296 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
transformation_function Add typos
threshold 0.95
output_sensitivity 0.05
Test Overconfidence on data slice “`transcription` contains "temperature"”
Measured Metric = 0.73333 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "temperature"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "dr"”
Measured Metric = 0.72549 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "dr"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "weight"”
Measured Metric = 0.71875 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "weight"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "having"”
Measured Metric = 0.71875 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "having"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "today"”
Measured Metric = 0.71795 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "today"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "follow"”
Measured Metric = 0.7027 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "follow"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "blood"”
Measured Metric = 0.69737 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "blood"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "distress"”
Measured Metric = 0.69444 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "distress"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "stable"”
Measured Metric = 0.68085 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "stable"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "mg"”
Measured Metric = 0.68 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "mg"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`text_length(transcription)` >= 2145.000”
Measured Metric = 0.67568 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `text_length(transcription)` >= 2145.000
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "discharge"”
Measured Metric = 0.67347 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "discharge"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "hospital"”
Measured Metric = 0.66667 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "hospital"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "continue"”
Measured Metric = 0.66667 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "continue"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Overconfidence on data slice “`transcription` contains "vital"”
Measured Metric = 0.66667 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "vital"
threshold 0.6524137931034483
p_threshold 0.2468526289804987
Test Precision on data slice “`transcription` contains "xyz"”
Measured Metric = 0.31818 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "xyz"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "subjective"”
Measured Metric = 0.36667 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "subjective"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "admission"”
Measured Metric = 0.375 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "admission"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "daily"”
Measured Metric = 0.38462 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "daily"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "coronary"”
Measured Metric = 0.3913 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "coronary"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "aspirin"”
Measured Metric = 0.3913 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "aspirin"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "followup"”
Measured Metric = 0.39583 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "followup"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "lung"”
Measured Metric = 0.4 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "lung"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "count"”
Measured Metric = 0.4 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "count"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "function"”
Measured Metric = 0.41379 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "function"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "abc"”
Measured Metric = 0.41667 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "abc"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "improved"”
Measured Metric = 0.41935 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "improved"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "continue"”
Measured Metric = 0.42308 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "continue"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "discharge"”
Measured Metric = 0.42353 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "discharge"
threshold 0.5787061994609164
Test Precision on data slice “`transcription` contains "greater"”
Measured Metric = 0.43478 close Failed
model medical_transcript_classification
dataset medical_transcript_dataset
slicing_function `transcription` contains "greater"
threshold 0.5787061994609164

Customize your suite by loading objects from the Giskard catalog

The Giskard open source catalog will enable to load:

  • Tests such as metamorphic, performance, prediction & data drift, statistical tests, etc

  • Slicing functions such as detectors of toxicity, hate, emotion, etc

  • Transformation functions such as generators of typos, paraphrase, style tune, etc

To create custom tests, refer to this page.

For demo purposes, we will load a simple unit test (test_f1) that checks if the test F1 score is above the given threshold. For more examples of tests and functions, refer to the Giskard catalog.

[ ]:
test_suite.add_test(testing.test_f1(model=giskard_model, dataset=giskard_dataset, threshold=0.7)).run()