dnn-locate is a Python module for discriminative features localization based on neural networks.
Project description
🎯 dnn-locate: Data-adaptive discriminative feature localization with statistically guaranteed interpretation
dnn-locate is a Python module for discriminative features localization given a fitted discriminator model, including neural networks. dnn-locate has the following key features:
- Adaptive discriminative features. For different instances, dnn-locate is able to provide adaptive discriminative features.
- Sparse discriminative features. The discriminative features provided by dnn-locate is sparse.
- Statistically guaranteed interpretation in R-square (R2). dnn-locate is able to effectively localize the discriminative features with a target R2 of prediction.
You can find more information for dnn-locate:
- GitHub repo: https://github.com/statmlben/dnn-inference
- PyPi: https://pypi.org/project/dnn-locate/
Magic activation function
We achieve the (1)-(3) by using the Magic activation: tanh
+relu
+softmax
from keras import backend as K
def tanh_relu(x, tau, axis_=(1,2)):
z = tau*K.softmax(x, axis=axis_)
z = backend.tanh(backend.relu(z))
return z
tanh_relu(x)
satisfies that: (i) tanh_relu(x) <= 1
; (ii) Σ tanh_relu(x) <= tau
, that is, each element if controlled by 1, and the sum of all elements is controlled by tau
.
Installation
Dependencies
dnn-locate
requires: Python>=3.8 + requirements.txt
pip install -r requirements.txt
User installation
Install dnn-locate
using pip
pip install dnn-locate
pip install git+https://github.com/statmlben/dnn-locate.git
Example in ECG significant signals localization
- The 'x-axis' is for different R2 explained by the detected features. From left to right, R2 = [50%, 60%, 70%, 80%].
- The y-axis is for different instances, each row is for a one instance. The corresponding label is included in the title of each subfigure.
See full ECG localization report here.
Conclusion
-
The localized regions of ECG complexes in sinus rhythm are most informative in distinguishing presence of ventricular ectopic beats from supraventricular ectopic beats in a particular individual. The localized regions lie in the QRS complex, which correlates with ventricular depolarization or electrical propagation in the ventricles. Ion channel aberrations and structural abnormalities in the ventricles can affect electrical conduction in the ventricles, manifesting with subtle anomalies in the QRS complex in sinus rhythm that may not be discernible by the naked eye but is detectable by the convolutional auto-encoder. Of note, as the $R^2$ increases from 10% to 88%, the highlighted color bar is progressively broader, covering a higher proportion of the QRS complex. The foregoing observations are sensible: the regions of interest resided in the QRS complex are biologically plausible and consistent with cardiac electrophysiological principles.
-
As the R2 increases from 80% to 84% and finally 88%, the blue bar progressively highlights the P wave of ECG complexes in sinus rhythm. This observation is consistent with our understanding of the mechanistic underpinnings of atrial depolarization, which correlates with the P wave. Ion channel alterations and structural changes in the atria can affect electrical conduction in the atria manifesting with subtle anomalies in the P wave in sinus rhythm that may not be discernible by the naked eye but are detectable by the convolutional auto-encoder.
-
Collectively, the examples underscore the fact that the discriminative regions of interest identified by our proposed method are biologically plausible and consistent with cardiac electrophysiological principles while locating subtle anomalies in the P wave and QRS complex that may not be discernible by the naked eye. By inspecting our results with an ECG clinician (Dr. Lin Yee Chen), the localized discriminative features of the ECG are consistent with medical interpretation in ECG diagnosis.
Notebook
Replication
If you want to replicate the experiments in our papers, please check the code.
Reference
If you use this code please 🌟 star the repository and cite the following paper:
@article{dai2022locate,
title={Data-adaptive discriminative feature localization with statistically guaranteed interpretation},
author={Dai, Ben and Shen, Xiaotong and Chen, Lin Yee and Li, Chunlin and Pan, Wei},
journal={Annals of Applied Statistics},
year={2022},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file dnn-locate-0.2.tar.gz
.
File metadata
- Download URL: dnn-locate-0.2.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ade92ea7e783940926510897c6ffe59e7df7e081d8909427d90f8ad52f42a39 |
|
MD5 | f823b43a120da98ce6fe5f68610173b4 |
|
BLAKE2b-256 | d0d6aa67f8e05618d708d4b7981dcc4b34aea9f9bd2d4687a0ae6d46d39f8cb8 |