biosppy.ml.ecg_ml

biosppy.ml.ecg

This module provides classes for machine learning models specifically designed for ECG signal analysis or derived signals or features (e.g., RR intervals).

copyright:
  1. 2015-2026 by Instituto de Telecomunicacoes

license:

BSD 3-clause, see LICENSE for more details.

Classes

AFibDetection()

A class for detecting atrial fibrillation using a pre-trained Keras model from [Silva23].

class biosppy.ml.ecg_ml.AFibDetection[source]

Bases: KerasClassifier

A class for detecting atrial fibrillation using a pre-trained Keras model from [Silva23]. This model uses the RR interval sequence as input and applies a bidirectional LSTM architecture to classify the signal.

The signal should be provided as a one-dimensional array of RR intervals in milliseconds.

predict(signal, \*\*kwargs)[source]

Predicts whether the input RR interval sequence indicates atrial fibrillation.

Examples

>>> from biosppy.ml.ecg import AFibDetection
>>> afib_model = AFibDetection()
>>> rri_signal = [601., 593., 585., 601., 601., 609., ...]  # RR interval sequence (ms)
>>> result = afib_model.predict(rri_signal)

References

[Silva23]

R. Silva, L. Abrunhosa Rodrigues, A. Lourenço, H. Plácido da Silva, “Temporal Dynamics of Drowsiness Detection Using LSTM-Based Models”, International Work-Conference on Artificial Neural Networks, pp. 211-220, 2023.

predict(signal, **kwargs)[source]

Predict whether the input RR interval sequence indicates atrial fibrillation.

Parameters:

signal (array) – One-dimensional RR interval sequence, in milliseconds.

Returns:

afib (bool) – True if atrial fibrillation is detected, False otherwise.

Raises:
  • TypeError – If signal is None.

  • ValueError – If the signal is not one-dimensional.

  • ValueError – If the signal is shorter than the required window length.