Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.8.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
- id: black
args: [--line-length=128, --verbose]
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
rev: 7.3.0
hooks:
- id: flake8
args: [--max-line-length=128, '--exclude=./.*,build,dist,official*,torch_ecg,references,*.ipynb', '--ignore=E501,W503,E203,F841,E402,E231', --count, --statistics, --show-source]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 7.0.0
hooks:
- id: isort
args: [--profile=black, --line-length=128]
3 changes: 1 addition & 2 deletions CPSC2020_challenge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import math
import time
Expand Down
3 changes: 1 addition & 2 deletions cfg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
from copy import deepcopy
Expand Down
3 changes: 1 addition & 2 deletions data_reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import argparse
import logging
Expand Down
3 changes: 1 addition & 2 deletions metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

from numbers import Real
from typing import Any, List, Optional, Sequence, Tuple, Union
Expand Down
3 changes: 1 addition & 2 deletions metrics_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

from typing import Any, List, Optional, Tuple, Union

Expand Down
3 changes: 1 addition & 2 deletions model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import sys
from copy import deepcopy
Expand Down
3 changes: 1 addition & 2 deletions phase_one_legacy/CPSC2020_challenge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

from numbers import Real
from typing import Tuple
Expand Down
3 changes: 1 addition & 2 deletions phase_one_legacy/CPSC2020_challenge_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import argparse
import os
Expand Down
3 changes: 1 addition & 2 deletions phase_one_legacy/cfg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
from copy import deepcopy
Expand Down
3 changes: 1 addition & 2 deletions phase_one_legacy/data_reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import argparse
import logging
Expand Down
3 changes: 1 addition & 2 deletions phase_one_legacy/models/dl_models/train_model_dl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
import sys
Expand Down
3 changes: 1 addition & 2 deletions phase_one_legacy/models/load_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
import pickle
Expand Down
3 changes: 1 addition & 2 deletions saved_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
from typing import Optional, Tuple, Union
Expand Down
3 changes: 1 addition & 2 deletions signal_processing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"""
"""
""" """
9 changes: 3 additions & 6 deletions train.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import argparse
import logging
Expand Down Expand Up @@ -436,17 +435,15 @@ def evaluate_crnn(
head_labels = all_labels[:head_num, ...]
head_labels_classes = [np.array(classes)[np.where(row)] for row in head_labels]
for n in range(head_num):
print(
f"""
print(f"""
----------------------------------------------
scalar prediction: {[round(n, 3) for n in head_scalar_preds[n].tolist()]}
binary prediction: {head_bin_preds[n].tolist()}
labels: {head_labels[n].astype(int).tolist()}
predicted classes: {head_preds_classes[n].tolist()}
label classes: {head_labels_classes[n].tolist()}
----------------------------------------------
"""
)
""")

auroc, auprc, accuracy, f_measure, f_beta_measure, g_beta_measure = eval_score(
classes=classes,
Expand Down
14 changes: 4 additions & 10 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,7 @@ def init_logger(log_dir: str, log_file: Optional[str] = None, mode: str = "a", v
return logger


CPSC_STATS = pd.read_csv(
StringIO(
"""rec,AF,len_h,N_beats,V_beats,S_beats,total_beats
CPSC_STATS = pd.read_csv(StringIO("""rec,AF,len_h,N_beats,V_beats,S_beats,total_beats
A01,No,25.89,109062,0,24,109086
A02,Yes,22.83,98936,4554,0,103490
A03,Yes,24.70,137249,382,0,137631
Expand All @@ -938,19 +936,15 @@ def init_logger(log_dir: str, log_file: Optional[str] = None, mode: str = "a", v
A07,No,23.11,73325,15150,3481,91956
A08,Yes,25.46,115518,2793,0,118311
A09,No,25.84,88229,2,1462,89693
A10,No,23.64,72821,169,9071,82061"""
)
)
A10,No,23.64,72821,169,9071,82061"""))


# columns truth, rows pred
OFFICIAL_LOSS_DF = pd.read_csv(
StringIO(
""",N_true,S_true,V_true
StringIO(""",N_true,S_true,V_true
N_pred,0,5,5
S_pred,1,0,5
V_pred,1,5,0"""
),
V_pred,1,5,0"""),
index_col=0,
)
OFFICIAL_LOSS_MAT = OFFICIAL_LOSS_DF.values
Loading