{ "cells": [ { "cell_type": "markdown", "id": "058cad15-13fc-470a-8cbf-38ba779e8b44", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": 10, "id": "76fccd62-f056-442c-9115-ec606fa2ec8b", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from datasets import load_dataset" ] }, { "cell_type": "markdown", "id": "994b7360-11b8-4287-be08-455d9657fb08", "metadata": {}, "source": [ "## Download data" ] }, { "cell_type": "code", "execution_count": 3, "id": "24c937d0-ef81-47be-9115-630fdf30ae2c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2022-04-16 11:57:39-- https://zenodo.org/record/2603256/files/train.h5\n", "Resolving zenodo.org (zenodo.org)... 137.138.76.77\n", "Connecting to zenodo.org (zenodo.org)|137.138.76.77|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 1038496555 (990M) [application/octet-stream]\n", "Saving to: ‘train.h5’\n", "\n", "train.h5 100%[===================>] 990.39M 50.5MB/s in 20s \n", "\n", "2022-04-16 11:57:59 (50.8 MB/s) - ‘train.h5’ saved [1038496555/1038496555]\n", "\n" ] } ], "source": [ "!wget -O train.h5 https://zenodo.org/record/2603256/files/train.h5" ] }, { "cell_type": "code", "execution_count": 4, "id": "4a37ee28-fb23-4ed9-b0dd-c9bfdfcd516c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2022-04-16 11:58:03-- https://zenodo.org/record/2603256/files/val.h5\n", "Resolving zenodo.org (zenodo.org)... 137.138.76.77\n", "Connecting to zenodo.org (zenodo.org)|137.138.76.77|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 347378076 (331M) [application/octet-stream]\n", "Saving to: ‘validation.h5’\n", "\n", "validation.h5 100%[===================>] 331.29M 41.8MB/s in 9.5s \n", "\n", "2022-04-16 11:58:13 (34.7 MB/s) - ‘validation.h5’ saved [347378076/347378076]\n", "\n" ] } ], "source": [ "!wget -O validation.h5 https://zenodo.org/record/2603256/files/val.h5" ] }, { "cell_type": "code", "execution_count": 5, "id": "d7ddd1a1-b452-4504-a04b-b5f8a8bcf61d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2022-04-16 11:58:15-- https://zenodo.org/record/2603256/files/test.h5\n", "Resolving zenodo.org (zenodo.org)... 137.138.76.77\n", "Connecting to zenodo.org (zenodo.org)|137.138.76.77|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 347849376 (332M) [application/octet-stream]\n", "Saving to: ‘test.h5’\n", "\n", "test.h5 100%[===================>] 331.73M 14.9MB/s in 21s \n", "\n", "2022-04-16 11:58:37 (15.9 MB/s) - ‘test.h5’ saved [347849376/347849376]\n", "\n" ] } ], "source": [ "!wget -O test.h5 https://zenodo.org/record/2603256/files/test.h5" ] }, { "cell_type": "markdown", "id": "58c66318-07f9-442e-bc8a-3496fe20ab5a", "metadata": {}, "source": [ "## Convert to parquet" ] }, { "cell_type": "code", "execution_count": 8, "id": "1a06b45e-a7b8-4bd0-859a-46de3cf90081", "metadata": {}, "outputs": [], "source": [ "def convert_to_parquet(split):\n", " df = pd.read_hdf(f\"{split}.h5\", key=\"table\")\n", " df.to_parquet(f\"{split}.parquet\", index=False)" ] }, { "cell_type": "code", "execution_count": 9, "id": "3e1a0cdc-436f-495a-96e7-ae1eda7ceaae", "metadata": {}, "outputs": [], "source": [ "for split in [\"train\", \"validation\", \"test\"]:\n", " convert_to_parquet(split)" ] }, { "cell_type": "markdown", "id": "48696caa-7f47-43ef-8056-9ff45ec9c8d2", "metadata": { "tags": [] }, "source": [ "## Check loading script" ] }, { "cell_type": "code", "execution_count": 12, "id": "1e4e06f8-c5cf-49e1-b932-833e3dd85b03", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using custom data configuration dl4phys--top_quark_tagging-d8129c455ccac2e9\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Downloading and preparing dataset parquet/dl4phys--top_quark_tagging to /Users/lewtun/.cache/huggingface/datasets/parquet/dl4phys--top_quark_tagging-d8129c455ccac2e9/0.0.0/0b6d5799bb726b24ad7fc7be720c170d8e497f575d02d47537de9a5bac074901...\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6477d7e388124b728dc9b4702c2ca612", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading data files: 0%| | 0/3 [00:00