Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python-client/giskard/models/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from giskard.ml_worker.utils.logging import Timer
from giskard.path_utils import get_size
from giskard.settings import settings
from ..utils import np_types_to_native

MODEL_CLASS_PKL = "ModelClass.pkl"

Expand Down Expand Up @@ -111,7 +112,7 @@ def __init__(
name=name if name is not None else self.__class__.__name__,
model_type=model_type,
feature_names=list(feature_names) if feature_names else None,
classification_labels=classification_labels,
classification_labels=np_types_to_native(classification_labels),
loader_class=self.__class__.__name__,
loader_module=self.__module__,
classification_threshold=classification_threshold,
Expand Down
8 changes: 8 additions & 0 deletions python-client/giskard/models/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import itertools
from collections.abc import Iterator
from typing import List
import numpy as np


def map_to_tuples(data: Iterator):
Expand All @@ -10,3 +12,9 @@ def map_to_tuples(data: Iterator):
return data

return map(lambda x: (x,), data)


def np_types_to_native(some_list: List):
if some_list is not None:
return [i.item() if isinstance(i, np.generic) else i for i in some_list]
return some_list