Dataset Viewer
Duplicate
The dataset viewer is not available for this split.
Cannot load the dataset split (in streaming mode) to extract the first rows.
Error code:   StreamingRowsError
Exception:    CastError
Message:      Couldn't cast
_data_files: list<item: struct<filename: string>>
  child 0, item: struct<filename: string>
      child 0, filename: string
_fingerprint: string
_format_columns: null
_format_kwargs: struct<>
_format_type: null
_output_all_columns: bool
_split: null
features: list<item: string>
  child 0, item: string
created_at: string
num_observations: int64
beat: struct<vectormesh_version: string, model_tag: string, vectorizer_type: string, tensordtype: int64, h (... 110 chars omitted)
  child 0, vectormesh_version: string
  child 1, model_tag: string
  child 2, vectorizer_type: string
  child 3, tensordtype: int64
  child 4, hidden_size: int64
  child 5, context_size: null
  child 6, stride: null
  child 7, offsets_supported: null
  child 8, chunk_sizes: struct<187: int64>
      child 0, 187: int64
to
{'beat': {'vectormesh_version': Value('string'), 'model_tag': Value('string'), 'vectorizer_type': Value('string'), 'tensordtype': Value('int64'), 'hidden_size': Value('int64'), 'context_size': Value('null'), 'stride': Value('null'), 'offsets_supported': Value('null'), 'chunk_sizes': {'187': Value('int64')}}, 'features': List(Value('string')), 'created_at': Value('string'), 'num_observations': Value('int64')}
because column names don't match
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/src/worker/utils.py", line 149, in get_rows_or_raise
                  return get_rows(
                      dataset=dataset,
                  ...<4 lines>...
                      column_names=column_names,
                  )
                File "/src/libs/libcommon/src/libcommon/utils.py", line 272, in decorator
                  return func(*args, **kwargs)
                File "/src/services/worker/src/worker/utils.py", line 129, in get_rows
                  rows_plus_one = list(itertools.islice(safe_iter(ds, dataset=dataset), rows_max_number + 1))
                File "/src/services/worker/src/worker/utils.py", line 544, in safe_iter
                  yield from ds.decode(False) if ds.features else ds
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 3052, in __iter__
                  for key, example in ex_iterable:
                                      ^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2559, in __iter__
                  for key, pa_table in self._iter_arrow():
                                       ~~~~~~~~~~~~~~~~^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2584, in _iter_arrow
                  for key, pa_table in self.ex_iterable._iter_arrow():
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 558, in _iter_arrow
                  for key, pa_table in iterator:
                                       ^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 440, in _iter_arrow
                  for key, pa_table in self.generate_tables_fn(**gen_kwags):
                                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 361, in _generate_tables
                  self._cast_table(pa_table, json_field_paths=json_field_paths),
                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 132, in _cast_table
                  pa_table = table_cast(pa_table, self.info.features.arrow_schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2381, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2309, in cast_table_to_schema
                  raise CastError(
                  ...<3 lines>...
                  )
              datasets.table.CastError: Couldn't cast
              _data_files: list<item: struct<filename: string>>
                child 0, item: struct<filename: string>
                    child 0, filename: string
              _fingerprint: string
              _format_columns: null
              _format_kwargs: struct<>
              _format_type: null
              _output_all_columns: bool
              _split: null
              features: list<item: string>
                child 0, item: string
              created_at: string
              num_observations: int64
              beat: struct<vectormesh_version: string, model_tag: string, vectorizer_type: string, tensordtype: int64, h (... 110 chars omitted)
                child 0, vectormesh_version: string
                child 1, model_tag: string
                child 2, vectorizer_type: string
                child 3, tensordtype: int64
                child 4, hidden_size: int64
                child 5, context_size: null
                child 6, stride: null
                child 7, offsets_supported: null
                child 8, chunk_sizes: struct<187: int64>
                    child 0, 187: int64
              to
              {'beat': {'vectormesh_version': Value('string'), 'model_tag': Value('string'), 'vectorizer_type': Value('string'), 'tensordtype': Value('int64'), 'hidden_size': Value('int64'), 'context_size': Value('null'), 'stride': Value('null'), 'offsets_supported': Value('null'), 'chunk_sizes': {'187': Value('int64')}}, 'features': List(Value('string')), 'created_at': Value('string'), 'num_observations': Value('int64')}
              because column names don't match

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Heartbeats, PTB Diagnostic ECG: raw (187, 1) sequences

Single ECG heartbeats from the PTB Diagnostic ECG Database, labelled normal or abnormal (myocardial infarction), as a vectormesh cache. There is no encoder: every row holds the signal itself, ready for a sequence model.

Built for the MADS MachineLearning course.

What a row is

One heartbeat: 187 steps sampled at 125 Hz (about 1.5 s), amplitudes scaled to [0, 1], and zero-padded at the end when the beat is shorter than 187 steps. The trailing zeros are padding, not signal.

column type
beat float32 (187, 1), a fixed-shape Array2D the signal as (sequence, channel)
label int 0 normal, 1 abnormal
source_idx int the row in the course's source files (see provenance)

The beat itself is the vector, so there is nothing to look up elsewhere: the cache holds the whole signal. source_idx only records which row of the course's source files a beat came from.

A DataLoader over the cache gives X of shape (batch, 187, 1).

model_tag raw: the steps unchanged, no encoder
hidden_size 1 (one channel)
tensordtype 2, (sequence, channel), every sequence 187 steps
rows 11.641 train / 2.911 test
download 18 MB train / 4 MB test
built with vectormesh 0.14.0, 2026-11-14
licence ODC-By 1.0

Classes

label class train test
0 normal 3.240 806
1 abnormal 8.401 2.105
total 11.641 2.911

The classes are unbalanced, about 28% normal to 72% abnormal in both splits.

The splits are not fully disjoint: 2 test beats equal a train beat, and train holds 5 beats that repeat another train beat.

Load it

import torch
from torch.utils.data import DataLoader
from vectormesh import VectorCache
from vectormesh.data import Collate, OneHot

train = VectorCache.from_hub("pttrn-io/heartbeats-ptb-raw", split="train")
test = VectorCache.from_hub("pttrn-io/heartbeats-ptb-raw", split="test")
train.metadata  # read this before writing any model code

onehot = OneHot(num_classes=2, label_col="label", target_col="onehot")
collate = Collate(embedding_col="beat", target_col="onehot", padder=torch.stack)


def labelled(cache):
    # map in plain Python format: in torch format every row is converted to a tensor
    # and back, about five times slower
    return cache.dataset.with_format(None).map(onehot).with_format("torch")


loader = DataLoader(labelled(train), batch_size=64, shuffle=True, collate_fn=collate)
X, y = next(iter(loader))  # X (64, 187, 1), y (64, 2)

Pin revision= to a commit for anything graded. This is a save_to_disk layout, not parquet: load_dataset() will not read it, VectorCache.load() and VectorCache.from_hub() will.

Validation

There is no validation split. Carve one from train, and leave test alone until the end:

from sklearn.model_selection import train_test_split

trainset = labelled(train)
labels = train.dataset.with_format(None)["label"]
fit_idx, val_idx = train_test_split(
    list(range(len(labels))), test_size=0.2, stratify=labels, random_state=42
)
fit, val = trainset.select(fit_idx), trainset.select(val_idx)

fitloader = DataLoader(fit, batch_size=64, shuffle=True, collate_fn=collate)
valloader = DataLoader(val, batch_size=64, shuffle=False, collate_fn=collate)
testloader = DataLoader(
    labelled(test), batch_size=64, shuffle=False, collate_fn=collate
)

Provenance

  1. PTB Diagnostic ECG Database on PhysioNet (https://physionet.org/content/ptbdb/1.0.0/, doi:10.13026/C28C71): 15-lead ECG recordings from the Physikalisch-Technische Bundesanstalt, Berlin.
  2. Kachuee, Fazeli and Sarrafzadeh (2018) cut the recordings into single beats, downsampled to 125 Hz, scaled to [0, 1] and zero-padded to a fixed length.
  3. Kaggle, "ECG Heartbeat Categorization Dataset" (https://www.kaggle.com/datasets/shayanfazeli/heartbeat) publishes those beats as ptbdb_normal.csv (4.046 beats) and ptbdb_abnormal.csv (10.506 beats), with no train/test split.
  4. raoulg/mads-exam-24 (a private course repository, commit 6652bd8f) holds them as data/heart_train.parq and data/heart_test.parq: both classes together, shuffled and split into train and test. source_idx is a row's position in those files.

This cache keeps every row of both files, in file order.

How it was built

scripts/build_heartbeat_cache.py in https://github.com/raoulg/MADS-MachineLearning-course, which checks every cached beat and label against its source row.

Licence and attribution

Contains information from the PTB Diagnostic ECG Database, which is made available under the ODC Attribution License (Open Data Commons Attribution License v1.0). This cache is a derived database of it and is shared under the same licence. The Kaggle page states no licence of its own; ODC-By applies as the licence of the source database.

When you use it, cite:

Downloads last month
61

Paper for pttrn-io/heartbeats-ptb-raw