Skip to content
Draft
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
2 changes: 1 addition & 1 deletion tutorials/tsfresh/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ipykernel==6.29.5
numpy==1.26.4
pandas==2.2.3
matplotlib==3.9.4
scipy==1.13.1
scipy>=1.14.0

# tsfresh.
tsfresh==0.20.3
Expand Down
59 changes: 36 additions & 23 deletions tutorials/tsfresh/tsfresh_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "3aa7ce61",
"metadata": {
"id": "3aa7ce61",
Expand All @@ -92,53 +92,56 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "17e69980",
"metadata": {
"id": "17e69980",
"lines_to_next_cell": 2
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Dataset ready at: uci_har_data/UCI HAR Dataset\n"
]
}
],
"source": [
"import pathlib.Path as path\n",
"from pathlib import Path\n",
"import zipfile\n",
"\n",
"import numpy as np\n",
"import requests\n",
"import tqdm.tqdm as tq_vis\n",
"from tqdm import tqdm\n",
"\n",
"np.random.seed(42)\n",
"\n",
"DATA_URL = \"https://archive.ics.uci.edu/ml/machine-learning-databases/00240/UCI%20HAR%20Dataset.zip\"\n",
"DATA_DIR = path(\"./uci_har_data\")\n",
"\n",
"\n",
"# ## 2) Download the UCI HAR dataset\n",
"#\n",
"# If the dataset hasn't been downloaded, this function will download it.\n",
"\n",
"DATA_DIR = Path(\"./uci_har_data\") # ✅ corrected here\n",
"\n",
"def fetch_data(url=DATA_URL, out_dir=DATA_DIR):\n",
" out_dir.mkdir(parents=True, exist_ok=True)\n",
" zip_path = out_dir / \"UCI_HAR_Dataset.zip\"\n",
"\n",
" if not zip_path.exists():\n",
" resp = requests.get(url, stream=True, timeout=20)\n",
" resp.raise_for_status()\n",
" total = int(resp.headers.get(\"content-length\", 0))\n",
" with (\n",
" open(zip_path, \"wb\") as f,\n",
" tq_vis(total=total, unit=\"B\", unit_scale=True) as pbar,\n",
" ):\n",
" with open(zip_path, \"wb\") as f, tqdm(total=total, unit=\"B\", unit_scale=True, desc=\"Downloading\") as pbar:\n",
" for chunk in resp.iter_content(chunk_size=8192):\n",
" if chunk:\n",
" f.write(chunk)\n",
" pbar.update(len(chunk))\n",
" with zipfile.ZipFile(zip_path, \"r\") as zf:\n",
" zf.extractall(out_dir)\n",
" return out_dir / \"UCI HAR Dataset\"\n",
"\n",
" extract_path = out_dir / \"UCI HAR Dataset\"\n",
" if not extract_path.exists():\n",
" with zipfile.ZipFile(zip_path, \"r\") as zf:\n",
" zf.extractall(out_dir)\n",
"\n",
"har_root = fetch_data()"
" return extract_path\n",
"\n",
"har_root = fetch_data()\n",
"print(f\"Dataset ready at: {har_root}\")"
]
},
{
Expand Down Expand Up @@ -435,11 +438,21 @@
"main_language": "python"
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.13"
}
},
"nbformat": 4,
Expand Down