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
1 change: 1 addition & 0 deletions docs/api/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,6 @@ Available Datasets
datasets/pyhealth.datasets.ClinVarDataset
datasets/pyhealth.datasets.COSMICDataset
datasets/pyhealth.datasets.TCGAPRADDataset
datasets/pyhealth.datasets.DSADataset
datasets/pyhealth.datasets.splitter
datasets/pyhealth.datasets.utils
10 changes: 10 additions & 0 deletions docs/api/datasets/pyhealth.datasets.DSADataset.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pyhealth.datasets.DSADataset
===============================

The Daily and Sports Activities (DSA) dataset contains motion sensor data of
daily and sports activities. For more information see `Daily and Sports Activities <https://archive.ics.uci.edu/dataset/256/daily+and+sports+activities>`_. This dataset was contributed as part of the Prostate-VarBench benchmarking work (`arXiv:2511.09576 <https://arxiv.org/abs/2511.09576>`_).

.. autoclass:: pyhealth.datasets.DSADataset
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/api/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,4 @@ Available Tasks
Mutation Pathogenicity (COSMIC) <tasks/pyhealth.tasks.MutationPathogenicityPrediction>
Cancer Survival Prediction (TCGA) <tasks/pyhealth.tasks.CancerSurvivalPrediction>
Cancer Mutation Burden (TCGA) <tasks/pyhealth.tasks.CancerMutationBurden>
Activity Classification (DSA) <tasks/pyhealth.tasks.ActivityClassification>
7 changes: 7 additions & 0 deletions docs/api/tasks/pyhealth.tasks.ActivityClassification.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pyhealth.tasks.ActivityClassification
===================================

.. autoclass:: pyhealth.tasks.ActivityClassification
:members:
:undoc-members:
:show-inheritance:
49 changes: 49 additions & 0 deletions examples/dsa_activity_classification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
"""dsa_activity_classification.ipynb

# Activity Classification Using DSA Dataset

# Install PyHealth

You might need to restart kernel after running this section.
"""

!git clone https://github.com/ranyou/PyHealth.git
!cd PyHealth && pip install -e .

"""# Load Dataset"""

from pyhealth.datasets import DSADataset

dataset = DSADataset(download=True, root="./daily-and-sports-activities")
dataset.stats()

"""# Define Task"""

samples = dataset.set_task()

from pyhealth.datasets import get_dataloader, split_by_sample

train_dataset, val_dataset, test_dataset = split_by_sample(samples, [0.7, 0.1, 0.2])

train_loader = get_dataloader(train_dataset, batch_size=16, shuffle=True)
val_loader = get_dataloader(val_dataset, batch_size=16, shuffle=False)
test_loader = get_dataloader(test_dataset, batch_size=16, shuffle=False)

"""# Define Model"""

from pyhealth.models import RNN

model = RNN(samples)

"""# Train Model"""

from pyhealth.trainer import Trainer

trainer = Trainer(model=model, metrics=["accuracy"])
trainer.train(train_dataloader=train_loader, val_dataloader=val_loader, epochs=1)

"""# Evaluate Model"""

trainer.evaluate(test_loader)

1 change: 1 addition & 0 deletions pyhealth/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, *args, **kwargs):
from .cosmic import COSMICDataset
from .covid19_cxr import COVID19CXRDataset
from .dreamt import DREAMTDataset
from .dsa import DSADataset
from .ehrshot import EHRShotDataset
from .eicu import eICUDataset
from .isruc import ISRUCDataset
Expand Down
136 changes: 136 additions & 0 deletions pyhealth/datasets/configs/dsa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
version: "1.0"
tables:
activities:
file_path: "dsa-pyhealth.csv"
patient_id: "patient"
timestamp: null
attributes:
- "activity"
- "patient"
- "segment"
- "sensor"
- "0"
- "1"
- "2"
- "3"
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"
- "11"
- "12"
- "13"
- "14"
- "15"
- "16"
- "17"
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
- "24"
- "25"
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
- "36"
- "37"
- "38"
- "39"
- "40"
- "41"
- "42"
- "43"
- "44"
- "45"
- "46"
- "47"
- "48"
- "49"
- "50"
- "51"
- "52"
- "53"
- "54"
- "55"
- "56"
- "57"
- "58"
- "59"
- "60"
- "61"
- "62"
- "63"
- "64"
- "65"
- "66"
- "67"
- "68"
- "69"
- "70"
- "71"
- "72"
- "73"
- "74"
- "75"
- "76"
- "77"
- "78"
- "79"
- "80"
- "81"
- "82"
- "83"
- "84"
- "85"
- "86"
- "87"
- "88"
- "89"
- "90"
- "91"
- "92"
- "93"
- "94"
- "95"
- "96"
- "97"
- "98"
- "99"
- "100"
- "101"
- "102"
- "103"
- "104"
- "105"
- "106"
- "107"
- "108"
- "109"
- "110"
- "111"
- "112"
- "113"
- "114"
- "115"
- "116"
- "117"
- "118"
- "119"
- "120"
- "121"
- "122"
- "123"
- "124"
Loading