Skip to content

Commit

Permalink
no_lru (#1631)
Browse files Browse the repository at this point in the history
  • Loading branch information
JKL98ISR committed Jun 15, 2022
1 parent 9dbb763 commit 19fec99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 9 additions & 5 deletions deepchecks/tabular/dataset.py
Expand Up @@ -11,7 +11,6 @@
"""The dataset module containing the tabular Dataset class and its functions."""
# pylint: disable=inconsistent-quotes,protected-access
import typing as t
from functools import lru_cache

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -101,6 +100,7 @@ class Dataset:
_max_categorical_ratio: float
_max_categories: int
_label_type: t.Optional[TaskType]
_classes: t.Tuple[str, ...]

def __init__(
self,
Expand Down Expand Up @@ -245,6 +245,8 @@ def __init__(
self._max_categorical_ratio = max_categorical_ratio
self._max_categories = max_categories

self._classes = None

if self._label_name in self.features:
raise DeepchecksValueError(f'label column {self._label_name} can not be a feature column')

Expand Down Expand Up @@ -740,7 +742,6 @@ def numerical_features(self) -> t.List[Hashable]:
return list(self._numerical_features)

@property
@lru_cache(maxsize=128)
def classes(self) -> t.Tuple[str, ...]:
"""Return the classes from label column in sorted list. if no label column defined, return empty list.
Expand All @@ -749,9 +750,12 @@ def classes(self) -> t.Tuple[str, ...]:
t.Tuple[str, ...]
Sorted classes
"""
if self.label_name is not None:
return tuple(sorted(self.data[self.label_name].dropna().unique().tolist()))
return tuple()
if self._classes is None:
if self.label_name is not None:
self._classes = tuple(sorted(self.data[self.label_name].dropna().unique().tolist()))
else:
self._classes = tuple()
return self._classes

@property
def columns_info(self) -> t.Dict[Hashable, str]:
Expand Down
2 changes: 0 additions & 2 deletions deepchecks/utils/features.py
Expand Up @@ -15,7 +15,6 @@

import time
import typing as t
from functools import lru_cache

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -212,7 +211,6 @@ def _built_in_importance(
return None, None


@lru_cache(maxsize=32)
def _calc_permutation_importance(
model: t.Any,
dataset: 'tabular.Dataset',
Expand Down

0 comments on commit 19fec99

Please sign in to comment.