sliceline 0.2.13__py3-none-any.whl → 0.2.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sliceline/slicefinder.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """
2
2
  The slicefinder module implements the Slicefinder class.
3
3
  """
4
+
4
5
  import logging
5
6
  from typing import Tuple, Union
6
7
 
@@ -377,7 +378,11 @@ class Slicefinder(BaseEstimator, TransformerMixin):
377
378
  slice_candidates = x_encoded @ slices.T == level
378
379
  slice_sizes = slice_candidates.sum(axis=0).A[0]
379
380
  slice_errors = errors @ slice_candidates
380
- max_slice_errors = slice_candidates.T.multiply(errors).max(axis=1).A
381
+ # Here we can't use the .A shorthand because it is not
382
+ # implemented in all scipy versions for coo_matrix objects
383
+ max_slice_errors = (
384
+ slice_candidates.T.multiply(errors).max(axis=1).toarray()
385
+ )
381
386
 
382
387
  # score of relative error and relative size
383
388
  slice_scores = self._score(
@@ -396,7 +401,11 @@ class Slicefinder(BaseEstimator, TransformerMixin):
396
401
  """Initialise 1-slices, i.e. slices with one predicate."""
397
402
  slice_sizes = x_encoded.sum(axis=0).A[0]
398
403
  slice_errors = errors @ x_encoded
399
- max_slice_errors = x_encoded.T.multiply(errors).max(axis=1).A[:, 0]
404
+ # Here we can't use the .A shorthand because it is not
405
+ # implemented in all scipy versions for coo_matrix objects
406
+ max_slice_errors = (
407
+ x_encoded.T.multiply(errors).max(axis=1).toarray()[:, 0]
408
+ )
400
409
 
401
410
  # working set of active slices (#attr x #slices) and top-k
402
411
  valid_slices_mask = (slice_sizes >= self.min_sup) & (slice_errors > 0)
@@ -426,7 +435,8 @@ class Slicefinder(BaseEstimator, TransformerMixin):
426
435
  self, slices: sp.csr_matrix, statistics: np.ndarray
427
436
  ) -> Tuple[sp.csr_matrix, np.ndarray]:
428
437
  """Prune invalid slices.
429
- Do not affect overall pruning effectiveness due to handling of missing parents."""
438
+ Do not affect overall pruning effectiveness due to handling of missing parents.
439
+ """
430
440
  valid_slices_mask = (statistics[:, 3] >= self.min_sup) & (
431
441
  statistics[:, 1] > 0
432
442
  )
@@ -438,7 +448,9 @@ class Slicefinder(BaseEstimator, TransformerMixin):
438
448
  ) -> np.ndarray:
439
449
  """Join compatible slices according to `level`."""
440
450
  slices_int = slices.astype(int)
441
- join = (slices_int @ slices_int.T).A == level - 2
451
+ # Here we can't use the .A shorthand because it is not
452
+ # implemented in all scipy versions for coo_matrix objects
453
+ join = (slices_int @ slices_int.T).toarray() == level - 2
442
454
  return np.triu(join, 1) * join
443
455
 
444
456
  @staticmethod
@@ -501,7 +513,10 @@ class Slicefinder(BaseEstimator, TransformerMixin):
501
513
  sub_pair_candidates = pair_candidates[:, start:end]
502
514
  # sub_p should not contain multiple True on the same line
503
515
  i = sub_pair_candidates.argmax(axis=1).T + np.any(
504
- sub_pair_candidates.A, axis=1
516
+ # Here we can't use the .A shorthand because it is not
517
+ # implemented in all scipy versions for coo_matrix objects
518
+ sub_pair_candidates.toarray(),
519
+ axis=1,
505
520
  )
506
521
  ids = ids + i.A * np.prod(dom[(j + 1) : dom.shape[0]])
507
522
  return ids
sliceline/validation.py CHANGED
@@ -330,7 +330,6 @@ def check_array(
330
330
  estimator=None,
331
331
  input_name="",
332
332
  ):
333
-
334
333
  """Input validation on an array, list, sparse matrix or similar.
335
334
 
336
335
  By default, the input is checked to be a non-empty 2D array containing
@@ -1,25 +1,19 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sliceline
3
- Version: 0.2.13
3
+ Version: 0.2.15
4
4
  Summary: ✂️ Fast slice finding for Machine Learning model debugging.
5
5
  Home-page: https://github.com/DataDome/sliceline
6
6
  License: BSD-3-Clause
7
7
  Author: Antoine de Daran
8
- Requires-Python: >=3.7,<3.12
8
+ Requires-Python: >=3.9,<3.12
9
9
  Classifier: License :: OSI Approved :: BSD License
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
11
  Classifier: Programming Language :: Python :: 3.9
14
12
  Classifier: Programming Language :: Python :: 3.10
15
13
  Classifier: Programming Language :: Python :: 3.11
16
- Requires-Dist: numpy (>=1.21,<2.0) ; python_version < "3.9"
17
- Requires-Dist: numpy (>=1.25,<2.0) ; python_version >= "3.9"
18
- Requires-Dist: scikit-learn (>=1,<2) ; python_version < "3.8"
19
- Requires-Dist: scikit-learn (>=1.3,<2.0) ; python_version >= "3.8" and python_version < "3.9"
20
- Requires-Dist: scikit-learn (>=1.4,<2.0) ; python_version >= "3.9"
21
- Requires-Dist: scipy (>=1,<2) ; python_version < "3.9"
22
- Requires-Dist: scipy (>=1.12,<2.0) ; python_version >= "3.9"
14
+ Requires-Dist: numpy (>=1.25,<2.0)
15
+ Requires-Dist: scikit-learn (>=1.5.0,<2.0.0)
16
+ Requires-Dist: scipy (>=1.12,<2.0)
23
17
  Project-URL: Documentation, https://sliceline.readthedocs.io/en/stable/
24
18
  Project-URL: Repository, https://github.com/DataDome/sliceline
25
19
  Description-Content-Type: text/x-rst
@@ -67,7 +61,7 @@ for a more thorough tutorial:
67
61
  🛠 Installation
68
62
  ---------------
69
63
 
70
- Sliceline is intended to work with **Python 3.7 or above**. Installation
64
+ Sliceline is intended to work with **Python 3.9 or above**. Installation
71
65
  can be done with ``pip``:
72
66
 
73
67
  .. code:: sh
@@ -0,0 +1,7 @@
1
+ sliceline/__init__.py,sha256=jEIUmQtv4W_eZuH63KQ8tAFoRZxyN3O8bRZ__FlMJr0,65
2
+ sliceline/slicefinder.py,sha256=eC_WiVVxoUh1idFfqG23J1VRYbpWNn8brULzLXcrT-A,26388
3
+ sliceline/validation.py,sha256=-RkCpRdANNeaJyrdj7zFn4xs1X1xIXitKwRoL_B5EAk,30794
4
+ sliceline-0.2.15.dist-info/LICENSE,sha256=AbeN2ySrCt8VUJukqcQIYutROwZh3W2u0UU1d7EnbZs,1531
5
+ sliceline-0.2.15.dist-info/METADATA,sha256=G5uG6UOyzFg-jkuzzx-zQhdNX9-GLkhx158V6Sg1lSA,3715
6
+ sliceline-0.2.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
+ sliceline-0.2.15.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.8.1
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,7 +0,0 @@
1
- sliceline/__init__.py,sha256=jEIUmQtv4W_eZuH63KQ8tAFoRZxyN3O8bRZ__FlMJr0,65
2
- sliceline/slicefinder.py,sha256=KFf3ysPUKfwcuxK1ZSD7MdhN9Dvr3j6JGmI3SXRI1xY,25745
3
- sliceline/validation.py,sha256=EQfrUvNpqy0NK_zHMaTmvRuvG6O2-J_3IlF6ehBcEyI,30795
4
- sliceline-0.2.13.dist-info/LICENSE,sha256=AbeN2ySrCt8VUJukqcQIYutROwZh3W2u0UU1d7EnbZs,1531
5
- sliceline-0.2.13.dist-info/METADATA,sha256=ZRTIscXW_ySdmynOwfGEHvsCROhtoAl5oFOwVAm0keo,4160
6
- sliceline-0.2.13.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
7
- sliceline-0.2.13.dist-info/RECORD,,