neural-feature-importance 0.5.0__py3-none-any.whl → 0.5.2__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.
- neural_feature_importance-0.5.2.dist-info/METADATA +126 -0
- {neural_feature_importance-0.5.0.dist-info → neural_feature_importance-0.5.2.dist-info}/RECORD +4 -4
- neural_feature_importance-0.5.0.dist-info/METADATA +0 -10
- {neural_feature_importance-0.5.0.dist-info → neural_feature_importance-0.5.2.dist-info}/WHEEL +0 -0
- {neural_feature_importance-0.5.0.dist-info → neural_feature_importance-0.5.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: neural-feature-importance
|
3
|
+
Version: 0.5.2
|
4
|
+
Summary: Variance-based feature importance for Neural Networks using callbacks for Keras and PyTorch
|
5
|
+
Author: CR de Sá
|
6
|
+
Requires-Python: >=3.10
|
7
|
+
Description-Content-Type: text/markdown
|
8
|
+
Requires-Dist: numpy
|
9
|
+
Provides-Extra: tensorflow
|
10
|
+
Requires-Dist: tensorflow; extra == "tensorflow"
|
11
|
+
Provides-Extra: torch
|
12
|
+
Requires-Dist: torch; extra == "torch"
|
13
|
+
|
14
|
+
# neural-feature-importance
|
15
|
+
|
16
|
+
[](https://pypi.org/project/neural-feature-importance/)
|
17
|
+
[](https://pypi.org/project/neural-feature-importance/)
|
18
|
+
|
19
|
+
Variance-based feature importance for deep learning models.
|
20
|
+
|
21
|
+
`neural-feature-importance` implements the method described in
|
22
|
+
[CR de Sá, *Variance-based Feature Importance in Neural Networks*](https://doi.org/10.1007/978-3-030-33778-0_24).
|
23
|
+
It tracks the variance of the first trainable layer using Welford's algorithm
|
24
|
+
and produces normalized importance scores for each feature.
|
25
|
+
|
26
|
+
## Features
|
27
|
+
|
28
|
+
- `VarianceImportanceKeras` — drop-in callback for TensorFlow/Keras models
|
29
|
+
- `VarianceImportanceTorch` — helper class for PyTorch training loops
|
30
|
+
- `MetricThreshold` — early-stopping callback based on a monitored metric
|
31
|
+
- Example scripts to reproduce the experiments from the paper
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
```bash
|
36
|
+
pip install "neural-feature-importance[tensorflow]" # for Keras
|
37
|
+
pip install "neural-feature-importance[torch]" # for PyTorch
|
38
|
+
```
|
39
|
+
|
40
|
+
Retrieve the package version via:
|
41
|
+
|
42
|
+
```python
|
43
|
+
from neural_feature_importance import __version__
|
44
|
+
print(__version__)
|
45
|
+
```
|
46
|
+
|
47
|
+
## Quick start
|
48
|
+
|
49
|
+
### Keras
|
50
|
+
|
51
|
+
```python
|
52
|
+
from neural_feature_importance import VarianceImportanceKeras
|
53
|
+
from neural_feature_importance.utils import MetricThreshold
|
54
|
+
|
55
|
+
viann = VarianceImportanceKeras()
|
56
|
+
monitor = MetricThreshold(monitor="val_accuracy", threshold=0.95)
|
57
|
+
model.fit(X, y, validation_split=0.05, epochs=30, callbacks=[viann, monitor])
|
58
|
+
print(viann.feature_importances_)
|
59
|
+
```
|
60
|
+
|
61
|
+
### PyTorch
|
62
|
+
|
63
|
+
```python
|
64
|
+
from neural_feature_importance import VarianceImportanceTorch
|
65
|
+
|
66
|
+
tracker = VarianceImportanceTorch(model)
|
67
|
+
tracker.on_train_begin()
|
68
|
+
for epoch in range(num_epochs):
|
69
|
+
train_one_epoch(model, optimizer, dataloader)
|
70
|
+
tracker.on_epoch_end()
|
71
|
+
tracker.on_train_end()
|
72
|
+
print(tracker.feature_importances_)
|
73
|
+
```
|
74
|
+
|
75
|
+
## Example scripts
|
76
|
+
|
77
|
+
Run `compare_feature_importance.py` to train a small network on the Iris dataset
|
78
|
+
and compare the scores with a random forest baseline:
|
79
|
+
|
80
|
+
```bash
|
81
|
+
python compare_feature_importance.py
|
82
|
+
```
|
83
|
+
|
84
|
+
Run `full_experiment.py` to reproduce the experiments from the paper:
|
85
|
+
|
86
|
+
```bash
|
87
|
+
python full_experiment.py
|
88
|
+
```
|
89
|
+
|
90
|
+
## Development
|
91
|
+
|
92
|
+
After making changes, run the following checks:
|
93
|
+
|
94
|
+
```bash
|
95
|
+
python -m py_compile neural_feature_importance/callbacks.py
|
96
|
+
python -m py_compile "variance-based feature importance in artificial neural networks.ipynb" 2>&1 | head
|
97
|
+
jupyter nbconvert --to script "variance-based feature importance in artificial neural networks.ipynb" --stdout | head
|
98
|
+
```
|
99
|
+
|
100
|
+
## Citation
|
101
|
+
|
102
|
+
If you use this package in your research, please cite:
|
103
|
+
|
104
|
+
```bibtex
|
105
|
+
@inproceedings{DBLP:conf/dis/Sa19,
|
106
|
+
author = {Cl{\'a}udio Rebelo de S{\'a}},
|
107
|
+
editor = {Petra Kralj Novak and
|
108
|
+
Tomislav Smuc and
|
109
|
+
Saso Dzeroski},
|
110
|
+
title = {Variance-Based Feature Importance in Neural Networks},
|
111
|
+
booktitle = {Discovery Science - 22nd International Conference, {DS} 2019, Split,
|
112
|
+
Croatia, October 28-30, 2019, Proceedings},
|
113
|
+
series = {Lecture Notes in Computer Science},
|
114
|
+
volume = {11828},
|
115
|
+
pages = {306--315},
|
116
|
+
publisher = {Springer},
|
117
|
+
year = {2019},
|
118
|
+
url = {https://doi.org/10.1007/978-3-030-33778-0\_24},
|
119
|
+
doi = {10.1007/978-3-030-33778-0\_24},
|
120
|
+
timestamp = {Thu, 07 Nov 2019 09:20:36 +0100},
|
121
|
+
biburl = {https://dblp.org/rec/conf/dis/Sa19.bib},
|
122
|
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
123
|
+
}
|
124
|
+
```
|
125
|
+
|
126
|
+
We appreciate citations as they help the community discover this work.
|
{neural_feature_importance-0.5.0.dist-info → neural_feature_importance-0.5.2.dist-info}/RECORD
RENAMED
@@ -2,7 +2,7 @@ neural_feature_importance/__init__.py,sha256=z3Rve0a7QTAhEpCesDhSdbkOwfSsNZgiwDV
|
|
2
2
|
neural_feature_importance/callbacks.py,sha256=HMHsmVaqZOzy5NSbxN-8CWvq82vzgZgZD53zqp2nAz0,4811
|
3
3
|
neural_feature_importance/utils/__init__.py,sha256=dMjBUCx8DCoJKAEAnjj_daXfEu9Q5va1k8XupmWdZiE,114
|
4
4
|
neural_feature_importance/utils/monitors.py,sha256=LTz7oE0-WgZ50DHyHDnTwfzWSSWMnjWd0xlwt7BWKuU,1763
|
5
|
-
neural_feature_importance-0.5.
|
6
|
-
neural_feature_importance-0.5.
|
7
|
-
neural_feature_importance-0.5.
|
8
|
-
neural_feature_importance-0.5.
|
5
|
+
neural_feature_importance-0.5.2.dist-info/METADATA,sha256=W5HuRD-lpppfwv8DhQ26eevxiZUkL-vaevfQDLdbKak,4091
|
6
|
+
neural_feature_importance-0.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
neural_feature_importance-0.5.2.dist-info/top_level.txt,sha256=yP0Q-BG7hDLLu1H1_x5bGEKwkCso5NxxvScnlmICb-o,26
|
8
|
+
neural_feature_importance-0.5.2.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: neural-feature-importance
|
3
|
-
Version: 0.5.0
|
4
|
-
Summary: Variance-based feature importance for Neural Networks using callbacks for Keras and PyTorch
|
5
|
-
Author: CR de Sá
|
6
|
-
Requires-Dist: numpy
|
7
|
-
Provides-Extra: tensorflow
|
8
|
-
Requires-Dist: tensorflow; extra == "tensorflow"
|
9
|
-
Provides-Extra: torch
|
10
|
-
Requires-Dist: torch; extra == "torch"
|
{neural_feature_importance-0.5.0.dist-info → neural_feature_importance-0.5.2.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|