Skip to content

Commit

Permalink
changes to class names, and tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
UnravelSports [JB] committed Jul 19, 2024
1 parent 6b5f08d commit 9ea1105
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 210 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ dev.py
bug.py
scratch.py
TODO.md
BUILD.md
build.py

/.data
/pickle_files
Expand Down
133 changes: 133 additions & 0 deletions examples/0_getting_started.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 🌀 It's all starting to unravel!\n",
"\n",
"First run `pip install unravelsports` if you haven't already!\n",
"\n",
"\n",
"-----\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install unravelsports --quiet"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1. Quick Start"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Processing frames: 100%|██████████| 500/500 [00:02<00:00, 221.19it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading 477 graphs into CustomSpektralDataset...\n",
"Loading 477 graphs into CustomSpektralDataset...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"from unravel.soccer import GraphConverter, CustomSpektralDataset\n",
"\n",
"from kloppy import skillcorner\n",
"\n",
"from unravel.utils import dummy_labels, dummy_graph_ids\n",
"\n",
"# Load Kloppy dataset\n",
"kloppy_dataset = skillcorner.load_open_data(\n",
" include_empty_frames=False,\n",
" limit=500, # limit to 500 frames in this example\n",
")\n",
"\n",
"# Initialize the Graph Converter, with dataset, labels and settings\n",
"converter = GraphConverter(\n",
" dataset=kloppy_dataset,\n",
" labels=dummy_labels(kloppy_dataset)\n",
")\n",
"\n",
"# Compute the graphs and add them to the CustomSpektralDataset\n",
"dataset = CustomSpektralDataset(\n",
" data=converter.to_spektral_graphs()\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from spektral.data import DisjointLoader\n",
"\n",
"N, F, S, n_out, n = dataset.dimensions()\n",
"\n",
"train, test = dataset.split_test_train(\n",
" split_train=4, split_test=1, random_seed=42\n",
")\n",
"\n",
"loader_tr = DisjointLoader(train, batch_size=16, epochs=150)\n",
"loader_te = DisjointLoader(test, batch_size=16, epochs=1, shuffle=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 2. Build GNN Model\n",
"\n",
"For a functional implementation of a Graph Neural Network see the [Full Graph Converter Tutorial](1_tutorial_graph_converter.ipynb)."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 9ea1105

Please sign in to comment.