compositional-explanations 0.0.1__tar.gz → 0.0.2__tar.gz

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.
Files changed (22) hide show
  1. {compositional_explanations-0.0.1/src/compositional_explanations.egg-info → compositional_explanations-0.0.2}/PKG-INFO +8 -7
  2. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/README.md +5 -3
  3. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/pyproject.toml +4 -4
  4. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2/src/compositional_explanations.egg-info}/PKG-INFO +8 -7
  5. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations.egg-info/SOURCES.txt +0 -1
  6. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations.egg-info/requires.txt +1 -1
  7. compositional_explanations-0.0.1/src/compositional_explanations/__init__.py +0 -0
  8. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/LICENSE +0 -0
  9. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/setup.cfg +0 -0
  10. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations/beam.py +0 -0
  11. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations/formula.py +0 -0
  12. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations/metrics.py +0 -0
  13. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations/optimal.py +0 -0
  14. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations/optimal_sample_heuristic.py +0 -0
  15. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations/optimal_sum_heuristic.py +0 -0
  16. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations/path_heuristic.py +0 -0
  17. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations.egg-info/dependency_links.txt +0 -0
  18. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/compositional_explanations.egg-info/top_level.txt +0 -0
  19. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/utils/constants.py +0 -0
  20. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/utils/general_utils.py +0 -0
  21. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/utils/mask_utils.py +0 -0
  22. {compositional_explanations-0.0.1 → compositional_explanations-0.0.2}/src/utils/optimal_utils.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: compositional_explanations
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Package to compute Compositional Explanations both in their optimal and beam format.
5
5
  Author-email: Biagio La Rosa <bilarosa@ucsc.edu>
6
6
  License: MIT
@@ -13,8 +13,7 @@ Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: numpy>=1.22.2
15
15
  Requires-Dist: scipy>=1.10.1
16
- Requires-Dist: torch>=1.14.0
17
- Dynamic: license-file
16
+ Requires-Dist: torch>=1.13.1
18
17
 
19
18
 
20
19
  # Compositional Explanations Package
@@ -22,18 +21,20 @@ This package provides functions to compute compositional explanations for a give
22
21
 
23
22
  The package assumes you are able to provide the following inputs:
24
23
  - `bitmaps`: A boolean tensor representing the bitmap to be explained for a given neuron. The bitmap represents the activation of the neuron for a set of inputs. A cell is 1 if the neuron is activated for that feature or whole input, and 0 otherwise.
25
- - `masks`: A list of boolean tensors representing the masks for each feature. Each mask represents whether a given concept/feature is annotated in the given position or samples. A cell is 1 if the feature is present in that position or sample, and 0 otherwise.
24
+ - `masks`: A list of boolean tensors (or csr sparse matrices from the scipy library) representing the masks for each feature. Each mask represents whether a given concept/feature is annotated in the given position or samples. A cell is 1 if the feature is present in that position or sample, and 0 otherwise.
26
25
  - `disjoint_info`: A boolean tensor representing the disjointness of the masks. The tensor is of shape (num_masks, num_masks) and indicates whether two masks are disjoint (i.e., they do not overlap). A cell is 1 if the two masks are disjoint, and 0 otherwise.
27
26
  - `length`: An integer representing the maximum length of the explanation formula. The formula is a combination of masks that best explains the bitmap.
28
27
  - `beam_size`: An integer representing the beam size for the beam search method. This parameter controls the number of candidate explanations to consider at each step of the search.
29
28
  - `device`: A string representing the device to run the computations on. Highly suggested to use a GPU for faster computations.
30
- - `cache_dir`: A string representing the directory to cache heuristic informaation for the given masks. This is useful for large datasets where computing the heuristics can be time-consuming. Default is None, which means no caching will be used.
29
+ - `cache_dir`: A string representing the directory to cache heuristic information for the given masks. This is useful for large datasets where computing the heuristics can be time-consuming. Default is None, which means no caching will be used.
31
30
 
32
- Useful functions include:
31
+ The functions provided in this package are:
33
32
  - `optimal.compute_optimal_explanations(bitmaps, masks, disjoint_info, length, device, cache_dir)`: Computes the optimal explanation formula for the given bitmap and masks. This method can be slow (~1 hour per neuron) for high complexity scenarios.
34
33
  - `beam.compute_beam_explanations(bitmaps, masks, disjoint_info, length, beam_size, device, cache_dir)`: Computes the explanation formula for the given bitmap and masks using a beam search method. This method is faster than the optimal method but cannot guarantee the optimality of the explanation. It is recommended to use this method for large datasets or when a faster computation is needed.
35
34
  - `metrics.compute_iou_from_masks(formula, masks, bitmaps)`: Computes the Intersection over Union (IoU) metric for the given explanation formula, masks, and bitmap. The IoU metric measures the overlap between the explanation masks and the bitmap, providing a measure of how well the explanation captures the bitmap's activation.
36
35
 
36
+ Note that all the functions take named arguments.
37
+
37
38
  ## Example usage of the compositional_explanations package
38
39
 
39
40
  ```python
@@ -4,18 +4,20 @@ This package provides functions to compute compositional explanations for a give
4
4
 
5
5
  The package assumes you are able to provide the following inputs:
6
6
  - `bitmaps`: A boolean tensor representing the bitmap to be explained for a given neuron. The bitmap represents the activation of the neuron for a set of inputs. A cell is 1 if the neuron is activated for that feature or whole input, and 0 otherwise.
7
- - `masks`: A list of boolean tensors representing the masks for each feature. Each mask represents whether a given concept/feature is annotated in the given position or samples. A cell is 1 if the feature is present in that position or sample, and 0 otherwise.
7
+ - `masks`: A list of boolean tensors (or csr sparse matrices from the scipy library) representing the masks for each feature. Each mask represents whether a given concept/feature is annotated in the given position or samples. A cell is 1 if the feature is present in that position or sample, and 0 otherwise.
8
8
  - `disjoint_info`: A boolean tensor representing the disjointness of the masks. The tensor is of shape (num_masks, num_masks) and indicates whether two masks are disjoint (i.e., they do not overlap). A cell is 1 if the two masks are disjoint, and 0 otherwise.
9
9
  - `length`: An integer representing the maximum length of the explanation formula. The formula is a combination of masks that best explains the bitmap.
10
10
  - `beam_size`: An integer representing the beam size for the beam search method. This parameter controls the number of candidate explanations to consider at each step of the search.
11
11
  - `device`: A string representing the device to run the computations on. Highly suggested to use a GPU for faster computations.
12
- - `cache_dir`: A string representing the directory to cache heuristic informaation for the given masks. This is useful for large datasets where computing the heuristics can be time-consuming. Default is None, which means no caching will be used.
12
+ - `cache_dir`: A string representing the directory to cache heuristic information for the given masks. This is useful for large datasets where computing the heuristics can be time-consuming. Default is None, which means no caching will be used.
13
13
 
14
- Useful functions include:
14
+ The functions provided in this package are:
15
15
  - `optimal.compute_optimal_explanations(bitmaps, masks, disjoint_info, length, device, cache_dir)`: Computes the optimal explanation formula for the given bitmap and masks. This method can be slow (~1 hour per neuron) for high complexity scenarios.
16
16
  - `beam.compute_beam_explanations(bitmaps, masks, disjoint_info, length, beam_size, device, cache_dir)`: Computes the explanation formula for the given bitmap and masks using a beam search method. This method is faster than the optimal method but cannot guarantee the optimality of the explanation. It is recommended to use this method for large datasets or when a faster computation is needed.
17
17
  - `metrics.compute_iou_from_masks(formula, masks, bitmaps)`: Computes the Intersection over Union (IoU) metric for the given explanation formula, masks, and bitmap. The IoU metric measures the overlap between the explanation masks and the bitmap, providing a measure of how well the explanation captures the bitmap's activation.
18
18
 
19
+ Note that all the functions take named arguments.
20
+
19
21
  ## Example usage of the compositional_explanations package
20
22
 
21
23
  ```python
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["setuptools"]
2
+ requires = ["setuptools==75.3.4", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "compositional_explanations"
7
- version = "0.0.1"
7
+ version = "0.0.2"
8
8
  authors = [
9
9
  { name="Biagio La Rosa", email="bilarosa@ucsc.edu" },
10
10
  ]
@@ -15,14 +15,14 @@ classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
16
  "Operating System :: OS Independent",
17
17
  ]
18
+ license = { text = "MIT" }
18
19
 
19
20
  dependencies = [
20
21
  "numpy>=1.22.2",
21
22
  "scipy>=1.10.1",
22
- "torch>=1.14.0",
23
+ "torch>=1.13.1",
23
24
  ]
24
25
 
25
- license = {text = "MIT"}
26
26
 
27
27
  [project.urls]
28
28
  Homepage = "https://github.com/aiea-lab/optimal-compositional-explanations"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: compositional_explanations
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Package to compute Compositional Explanations both in their optimal and beam format.
5
5
  Author-email: Biagio La Rosa <bilarosa@ucsc.edu>
6
6
  License: MIT
@@ -13,8 +13,7 @@ Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: numpy>=1.22.2
15
15
  Requires-Dist: scipy>=1.10.1
16
- Requires-Dist: torch>=1.14.0
17
- Dynamic: license-file
16
+ Requires-Dist: torch>=1.13.1
18
17
 
19
18
 
20
19
  # Compositional Explanations Package
@@ -22,18 +21,20 @@ This package provides functions to compute compositional explanations for a give
22
21
 
23
22
  The package assumes you are able to provide the following inputs:
24
23
  - `bitmaps`: A boolean tensor representing the bitmap to be explained for a given neuron. The bitmap represents the activation of the neuron for a set of inputs. A cell is 1 if the neuron is activated for that feature or whole input, and 0 otherwise.
25
- - `masks`: A list of boolean tensors representing the masks for each feature. Each mask represents whether a given concept/feature is annotated in the given position or samples. A cell is 1 if the feature is present in that position or sample, and 0 otherwise.
24
+ - `masks`: A list of boolean tensors (or csr sparse matrices from the scipy library) representing the masks for each feature. Each mask represents whether a given concept/feature is annotated in the given position or samples. A cell is 1 if the feature is present in that position or sample, and 0 otherwise.
26
25
  - `disjoint_info`: A boolean tensor representing the disjointness of the masks. The tensor is of shape (num_masks, num_masks) and indicates whether two masks are disjoint (i.e., they do not overlap). A cell is 1 if the two masks are disjoint, and 0 otherwise.
27
26
  - `length`: An integer representing the maximum length of the explanation formula. The formula is a combination of masks that best explains the bitmap.
28
27
  - `beam_size`: An integer representing the beam size for the beam search method. This parameter controls the number of candidate explanations to consider at each step of the search.
29
28
  - `device`: A string representing the device to run the computations on. Highly suggested to use a GPU for faster computations.
30
- - `cache_dir`: A string representing the directory to cache heuristic informaation for the given masks. This is useful for large datasets where computing the heuristics can be time-consuming. Default is None, which means no caching will be used.
29
+ - `cache_dir`: A string representing the directory to cache heuristic information for the given masks. This is useful for large datasets where computing the heuristics can be time-consuming. Default is None, which means no caching will be used.
31
30
 
32
- Useful functions include:
31
+ The functions provided in this package are:
33
32
  - `optimal.compute_optimal_explanations(bitmaps, masks, disjoint_info, length, device, cache_dir)`: Computes the optimal explanation formula for the given bitmap and masks. This method can be slow (~1 hour per neuron) for high complexity scenarios.
34
33
  - `beam.compute_beam_explanations(bitmaps, masks, disjoint_info, length, beam_size, device, cache_dir)`: Computes the explanation formula for the given bitmap and masks using a beam search method. This method is faster than the optimal method but cannot guarantee the optimality of the explanation. It is recommended to use this method for large datasets or when a faster computation is needed.
35
34
  - `metrics.compute_iou_from_masks(formula, masks, bitmaps)`: Computes the Intersection over Union (IoU) metric for the given explanation formula, masks, and bitmap. The IoU metric measures the overlap between the explanation masks and the bitmap, providing a measure of how well the explanation captures the bitmap's activation.
36
35
 
36
+ Note that all the functions take named arguments.
37
+
37
38
  ## Example usage of the compositional_explanations package
38
39
 
39
40
  ```python
@@ -1,7 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
- src/compositional_explanations/__init__.py
5
4
  src/compositional_explanations/beam.py
6
5
  src/compositional_explanations/formula.py
7
6
  src/compositional_explanations/metrics.py
@@ -1,3 +1,3 @@
1
1
  numpy>=1.22.2
2
2
  scipy>=1.10.1
3
- torch>=1.14.0
3
+ torch>=1.13.1