Skip to content

Commit e88efbd

Browse files
committed
draft of getting_started notebook.
1 parent 1933314 commit e88efbd

3 files changed

Lines changed: 130 additions & 0 deletions

File tree

.binder/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This Dockerfile is used to build sktime when launching binder.
2+
# Find out more at: https://mybinder.readthedocs.io/en/latest/index.html
3+
4+
FROM jupyter/scipy-notebook:python-3.11.6
5+
# Set up user to avoid running as root
6+
ARG NB_USER
7+
ARG NB_UID
8+
ENV USER ${NB_USER}
9+
ENV HOME /home/${NB_USER}
10+
11+
# Binder will automatically clone the repo, but we need to make sure the
12+
# contents of our repo are in the ${HOME} directory
13+
COPY . ${HOME}
14+
USER root
15+
RUN chown -R ${NB_UID} ${HOME}
16+
17+
# Switch user and directory
18+
USER ${USER}
19+
WORKDIR ${HOME}
20+
21+
# Install extra requirements and sktime based on master branch
22+
RUN pip install --upgrade pip --no-cache-dir && pip install .[binder]

examples/getting_started.ipynb

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Welcome to tsbootstrap\n",
8+
"\n",
9+
"`tsbootstrap` is a `sklearn` and `sktime` compatible library of bootstrapping algorithm for time series.\n",
10+
"This notebook explains how you can start with tsbootstrap. \n",
11+
"\n"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"metadata": {},
17+
"source": [
18+
"## Getting started\n",
19+
"`tsbootsrap` is following the [`sklearn` design principle](https://scikit-learn.org/stable/developers/develop.html). This means that there are mainly three steps of interaction of a bootstrapper:\n",
20+
"1. Initiate the bootrapper\n",
21+
"2. Fitting the bootstrapper\n",
22+
"3. Transforming the data using the fitted bootstrapper"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"metadata": {},
28+
"source": [
29+
"In this example, we use the moving block bootstrapper. Therefore, we instantiate the class. "
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"from tsbootstrap import MovingBlockBootstrap, MovingBlockBootstrapConfig\n",
39+
"\n",
40+
"bootstrapper = MovingBlockBootstrap(block_length=10)"
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {},
46+
"source": [
47+
"After the instantiation, we can fit the bootsrapper. Therefore, we load the airline passenger dataset using the dataset loading functionalities of sktime"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"from sktime.datasets import load_airline\n",
57+
"\n",
58+
"y = load_airline()\n",
59+
"\n",
60+
"bootstrapper.fit(y)"
61+
]
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"metadata": {},
66+
"source": [
67+
"After fitting the bootstrapper, we can use the bootstrapper to transform the data"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": null,
73+
"metadata": {},
74+
"outputs": [],
75+
"source": [
76+
"bootstrapper.transform(y)"
77+
]
78+
},
79+
{
80+
"cell_type": "markdown",
81+
"metadata": {},
82+
"source": [
83+
"Instead of calling first `fit` and `transform` afterwards, we can also use the shortcut: `fit_transform`"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {},
90+
"outputs": [],
91+
"source": [
92+
"bootstrapper.fit_transform(y)"
93+
]
94+
}
95+
],
96+
"metadata": {
97+
"language_info": {
98+
"name": "python"
99+
}
100+
},
101+
"nbformat": 4,
102+
"nbformat_minor": 2
103+
}

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,8 @@ docs = [
226226
"sphinx-version-warning",
227227
"tabulate",
228228
]
229+
230+
binder = [
231+
"jupyter",
232+
"sktime",
233+
]

0 commit comments

Comments
 (0)