Skip to content

Commit d6c02b0

Browse files
committed
style/rendering updates
1 parent cd038fb commit d6c02b0

15 files changed

+664
-367
lines changed

notebooks/00/intro.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ To reinforce learning and encourage active engagement, each chapter concludes wi
1919

2020
Whether you are new to time series analysis or looking to refine your expertise, this course offers a broad exploration of the field, with Python as your toolkit. I hope that you will find this material both educational and entertaining, brining you a step closer to mastering time series analysis.
2121

22-
```{note}
23-
The notebooks are presented in class as slides using RISE (see [here](https://github.com/FilippoMB/python-time-series-handbook?tab=readme-ov-file#-notebook-format-and-slides) for more details).
24-
For this reason, the text in the notebooks is organized with bullet points.
25-
```
26-
2722

2823
## 📖 Chapters
2924

@@ -32,6 +27,11 @@ The course is organized into the following chapters.
3227
```{tableofcontents}
3328
```
3429

30+
```{note}
31+
The notebooks are presented in class as slides using RISE (see [here](https://github.com/FilippoMB/python-time-series-handbook?tab=readme-ov-file#-notebook-format-and-slides) for more details).
32+
For this reason, the text in the notebooks is organized with bullet points.
33+
```
34+
3535
## 🎓 University courses
3636

3737
These notebooks are currently adopted in [STA-2003 Tidsrekker](https://sa.uit.no/utdanning/emner/emne?p_document_id=822793) at UiT the Arctic University of Tromsø.

notebooks/01/introduction_to_time_series.ipynb

Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
{
3232
"cell_type": "code",
33-
"execution_count": 27,
33+
"execution_count": 1,
3434
"metadata": {
3535
"slideshow": {
3636
"slide_type": "skip"
@@ -389,7 +389,10 @@
389389
"metadata": {
390390
"slideshow": {
391391
"slide_type": "subslide"
392-
}
392+
},
393+
"tags": [
394+
"hide-input"
395+
]
393396
},
394397
"outputs": [
395398
{
@@ -470,7 +473,10 @@
470473
"metadata": {
471474
"slideshow": {
472475
"slide_type": "subslide"
473-
}
476+
},
477+
"tags": [
478+
"hide-input"
479+
]
474480
},
475481
"outputs": [
476482
{
@@ -527,7 +533,10 @@
527533
"metadata": {
528534
"slideshow": {
529535
"slide_type": "fragment"
530-
}
536+
},
537+
"tags": [
538+
"hide-input"
539+
]
531540
},
532541
"outputs": [
533542
{
@@ -623,7 +632,10 @@
623632
"metadata": {
624633
"slideshow": {
625634
"slide_type": "fragment"
626-
}
635+
},
636+
"tags": [
637+
"hide-input"
638+
]
627639
},
628640
"outputs": [
629641
{
@@ -686,7 +698,10 @@
686698
"metadata": {
687699
"slideshow": {
688700
"slide_type": "fragment"
689-
}
701+
},
702+
"tags": [
703+
"hide-input"
704+
]
690705
},
691706
"outputs": [
692707
{
@@ -761,7 +776,10 @@
761776
"metadata": {
762777
"slideshow": {
763778
"slide_type": "fragment"
764-
}
779+
},
780+
"tags": [
781+
"hide-input"
782+
]
765783
},
766784
"outputs": [
767785
{
@@ -837,6 +855,21 @@
837855
"slide_type": "fragment"
838856
}
839857
},
858+
"outputs": [],
859+
"source": [
860+
"slope, intercept = np.polyfit(np.arange(len(additive)), additive, 1) # estimate line coefficient\n",
861+
"trend = np.arange(len(additive)) * slope + intercept # linear trend\n",
862+
"detrended = additive - trend # remove the trend"
863+
]
864+
},
865+
{
866+
"cell_type": "code",
867+
"execution_count": 15,
868+
"metadata": {
869+
"tags": [
870+
"hide-input"
871+
]
872+
},
840873
"outputs": [
841874
{
842875
"data": {
@@ -850,10 +883,6 @@
850883
}
851884
],
852885
"source": [
853-
"slope, intercept = np.polyfit(np.arange(len(additive)), additive, 1) # estimate line coefficient\n",
854-
"trend = np.arange(len(additive)) * slope + intercept # linear trend\n",
855-
"detrended = additive - trend # remove the trend\n",
856-
"\n",
857886
"plt.figure(figsize=(10, 3))\n",
858887
"plt.plot(additive, label='Original')\n",
859888
"plt.plot(trend, label='Trend')\n",
@@ -892,7 +921,7 @@
892921
},
893922
{
894923
"cell_type": "code",
895-
"execution_count": 15,
924+
"execution_count": 16,
896925
"metadata": {
897926
"slideshow": {
898927
"slide_type": "fragment"
@@ -904,27 +933,20 @@
904933
"additive_decomposition = seasonal_decompose(x=additive, model='additive', period=12)"
905934
]
906935
},
907-
{
908-
"cell_type": "markdown",
909-
"metadata": {
910-
"slideshow": {
911-
"slide_type": "subslide"
912-
}
913-
},
914-
"source": [
915-
"- We define a utility function to make the plots."
916-
]
917-
},
918936
{
919937
"cell_type": "code",
920-
"execution_count": 16,
938+
"execution_count": 17,
921939
"metadata": {
922940
"slideshow": {
923941
"slide_type": "-"
924-
}
942+
},
943+
"tags": [
944+
"hide-input"
945+
]
925946
},
926947
"outputs": [],
927948
"source": [
949+
"# Utility function to make the plots\n",
928950
"def seas_decomp_plots(original, decomposition):\n",
929951
" _, axes = plt.subplots(4, 1, sharex=True, sharey=False, figsize=(7, 5))\n",
930952
" axes[0].plot(original, label='Original')\n",
@@ -940,7 +962,7 @@
940962
},
941963
{
942964
"cell_type": "code",
943-
"execution_count": 17,
965+
"execution_count": 18,
944966
"metadata": {
945967
"slideshow": {
946968
"slide_type": "subslide"
@@ -1008,7 +1030,7 @@
10081030
},
10091031
{
10101032
"cell_type": "code",
1011-
"execution_count": 18,
1033+
"execution_count": 19,
10121034
"metadata": {
10131035
"slideshow": {
10141036
"slide_type": "subslide"
@@ -1054,13 +1076,13 @@
10541076
},
10551077
"source": [
10561078
"### Locally estimated scatterplot smoothing (LOESS)\n",
1057-
"- Next, we try a second method called `STL` (Seasonal and Trend decomposition using LOESS)\n",
1079+
"- Next, we try a second method called `STL` (Seasonal and Trend decomposition using LOESS).\n",
10581080
"- We start with the additive model."
10591081
]
10601082
},
10611083
{
10621084
"cell_type": "code",
1063-
"execution_count": 19,
1085+
"execution_count": 20,
10641086
"metadata": {
10651087
"slideshow": {
10661088
"slide_type": "subslide"
@@ -1097,7 +1119,7 @@
10971119
},
10981120
{
10991121
"cell_type": "code",
1100-
"execution_count": 20,
1122+
"execution_count": 21,
11011123
"metadata": {
11021124
"slideshow": {
11031125
"slide_type": "subslide"
@@ -1219,17 +1241,19 @@
12191241
" - Use the Fast Fourier Transform on a signal *without* trend.\n",
12201242
"\n",
12211243
"- We will look more into FFT later on.\n",
1222-
"- For now, you can use the following code to compute the dominant period in the data."
1244+
"- For now, you can use the following function to compute the dominant period in the data."
12231245
]
12241246
},
12251247
{
12261248
"cell_type": "code",
1227-
"execution_count": 21,
1249+
"execution_count": 22,
12281250
"metadata": {
12291251
"slideshow": {
12301252
"slide_type": "subslide"
12311253
},
1232-
"tags": []
1254+
"tags": [
1255+
"hide-input"
1256+
]
12331257
},
12341258
"outputs": [],
12351259
"source": [
@@ -1260,7 +1284,7 @@
12601284
},
12611285
{
12621286
"cell_type": "code",
1263-
"execution_count": 22,
1287+
"execution_count": 23,
12641288
"metadata": {
12651289
"slideshow": {
12661290
"slide_type": "subslide"
@@ -1282,12 +1306,14 @@
12821306
},
12831307
{
12841308
"cell_type": "code",
1285-
"execution_count": 23,
1309+
"execution_count": 24,
12861310
"metadata": {
12871311
"slideshow": {
12881312
"slide_type": "subslide"
12891313
},
1290-
"tags": []
1314+
"tags": [
1315+
"hide-input"
1316+
]
12911317
},
12921318
"outputs": [
12931319
{
@@ -1325,7 +1351,7 @@
13251351
},
13261352
{
13271353
"cell_type": "code",
1328-
"execution_count": 24,
1354+
"execution_count": 25,
13291355
"metadata": {
13301356
"slideshow": {
13311357
"slide_type": "-"
@@ -1338,7 +1364,7 @@
13381364
},
13391365
{
13401366
"cell_type": "code",
1341-
"execution_count": 25,
1367+
"execution_count": 26,
13421368
"metadata": {
13431369
"slideshow": {
13441370
"slide_type": "fragment"
@@ -1435,7 +1461,7 @@
14351461
},
14361462
{
14371463
"cell_type": "code",
1438-
"execution_count": 28,
1464+
"execution_count": 27,
14391465
"metadata": {
14401466
"slideshow": {
14411467
"slide_type": "-"

notebooks/02/stationarity.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,14 @@
234234
},
235235
"outputs": [],
236236
"source": [
237-
"def run_sequence_plot(x, y, title, xlabel=\"Time\", ylabel=\"Values\"):\n",
238-
" fig, ax = plt.subplots(1,1, figsize=(10,3.5))\n",
237+
"def run_sequence_plot(x, y, title, xlabel=\"Time\", ylabel=\"Values\", ax=None):\n",
238+
" if ax is None:\n",
239+
" _, ax = plt.subplots(1,1, figsize=(10, 3.5))\n",
239240
" ax.plot(x, y, 'k-')\n",
240241
" ax.set_title(title)\n",
241242
" ax.set_xlabel(xlabel)\n",
242243
" ax.set_ylabel(ylabel)\n",
243-
" plt.grid(alpha=0.3)\n",
244+
" ax.grid(alpha=0.3)\n",
244245
" return ax"
245246
]
246247
},

0 commit comments

Comments
 (0)