Skip to content

Commit af4f33b

Browse files
authored
Merge pull request #17 from kraina-ai/fix-mlinpl
Fix issues with MLinPL version of tutorial
2 parents 1cf26cc + 9879890 commit af4f33b

5 files changed

+17
-74
lines changed

answers/MLinPL/05_bikes_transfer_learning.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
"positive_samples[\"is_positive\"] = True\n",
256256
"\n",
257257
"# Mark remaining regions as negative\n",
258-
"negative_samples = regions_gdf.copy()[~regions_gdf.index.isin(positive_samples_new.index)]\n",
258+
"negative_samples = regions_gdf.copy()[~regions_gdf.index.isin(positive_samples.index)]\n",
259259
"negative_samples[\"is_positive\"] = False\n",
260260
"\n",
261261
"# Just to keep everything balanced - undersampling\n",
@@ -473,7 +473,7 @@
473473
"name": "python",
474474
"nbconvert_exporter": "python",
475475
"pygments_lexer": "ipython3",
476-
"version": "3.11.6"
476+
"version": "3.10.9"
477477
},
478478
"rise": {
479479
"controls": false,

answers/MLinPL/06_trip_flow_prediction.ipynb

+8-36
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"%pip install srai[torch]"
9+
"%pip install srai[torch] \"xgboost<3\" \"annoy<2\""
1010
]
1111
},
1212
{
@@ -33,7 +33,7 @@
3333
"with zipfile.ZipFile('../../data/trips_hexes.zip', \"r\") as zf:\n",
3434
" for member in tqdm(zf.infolist(), desc=\"\"):\n",
3535
" try:\n",
36-
" zf.extract(member, 'data')\n",
36+
" zf.extract(member, '../../data/')\n",
3737
" except zipfile.error:\n",
3838
" pass"
3939
]
@@ -238,7 +238,9 @@
238238
{
239239
"cell_type": "code",
240240
"execution_count": null,
241-
"metadata": {},
241+
"metadata": {
242+
"scrolled": false
243+
},
242244
"outputs": [],
243245
"source": [
244246
"buffered_regions = ring_buffer_h3_regions_gdf(regions_gdf=portugal_h3_regions, distance=neighbours_distance)\n",
@@ -354,7 +356,7 @@
354356
"cell_type": "code",
355357
"execution_count": null,
356358
"metadata": {
357-
"scrolled": false
359+
"scrolled": true
358360
},
359361
"outputs": [],
360362
"source": [
@@ -397,36 +399,6 @@
397399
")"
398400
]
399401
},
400-
{
401-
"cell_type": "code",
402-
"execution_count": null,
403-
"metadata": {},
404-
"outputs": [],
405-
"source": [
406-
"import matplotlib.pyplot as plt\n",
407-
"\n",
408-
"fig = plt.figure(figsize=(14,9))\n",
409-
"ax = fig.add_subplot(111, \n",
410-
" projection='3d')\n",
411-
" \n",
412-
"for idx in pca_embeddings.index:\n",
413-
" ax.scatter(pca_embeddings.loc[idx][0],\n",
414-
" pca_embeddings.loc[idx][1],\n",
415-
" pca_embeddings.loc[idx][2],\n",
416-
" s=60)\n",
417-
"\n",
418-
"ax.set_xlabel(\"PC1\", \n",
419-
" fontsize=12)\n",
420-
"ax.set_ylabel(\"PC2\", \n",
421-
" fontsize=12)\n",
422-
"ax.set_zlabel(\"PC3\", \n",
423-
" fontsize=12)\n",
424-
" \n",
425-
"ax.view_init(30, 125)\n",
426-
"plt.title(\"3D PCA plot\")\n",
427-
"plt.show()"
428-
]
429-
},
430402
{
431403
"cell_type": "code",
432404
"execution_count": null,
@@ -723,7 +695,7 @@
723695
"\n",
724696
"trainer_kwargs = {\n",
725697
" # \"max_epochs\": 50, # uncomment for a longer training\n",
726-
" \"max_epochs\": 25,\n",
698+
" \"max_epochs\": 5,\n",
727699
" # \"accelerator\": \"cpu\",\n",
728700
"}\n",
729701
"\n",
@@ -940,7 +912,7 @@
940912
"name": "python",
941913
"nbconvert_exporter": "python",
942914
"pygments_lexer": "ipython3",
943-
"version": "3.11.4"
915+
"version": "3.10.9"
944916
}
945917
},
946918
"nbformat": 4,

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ notebook>=6,<7 # RISE not compatible with version 7
55
pydeck==0.8.0
66
RISE==5.7.1
77
osmnx==1.7.0
8-
nbgrader==0.8.5
8+
nbgrader==0.8.5
9+
h3>=4.0.0b1,<4.0.0b3

tutorial/MLinPL/05_bikes_transfer_learning.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
"name": "python",
432432
"nbconvert_exporter": "python",
433433
"pygments_lexer": "ipython3",
434-
"version": "3.11.6"
434+
"version": "3.10.9"
435435
},
436436
"rise": {
437437
"controls": false,

tutorial/MLinPL/06_trip_flow_prediction.ipynb

+4-34
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"%pip install srai[torch]"
9+
"%pip install srai[torch] \"xgboost<3\" \"annoy<2\""
1010
]
1111
},
1212
{
@@ -33,7 +33,7 @@
3333
"with zipfile.ZipFile('../../data/trips_hexes.zip', \"r\") as zf:\n",
3434
" for member in tqdm(zf.infolist(), desc=\"\"):\n",
3535
" try:\n",
36-
" zf.extract(member, 'data')\n",
36+
" zf.extract(member, '../../data/')\n",
3737
" except zipfile.error:\n",
3838
" pass"
3939
]
@@ -395,36 +395,6 @@
395395
")"
396396
]
397397
},
398-
{
399-
"cell_type": "code",
400-
"execution_count": null,
401-
"metadata": {},
402-
"outputs": [],
403-
"source": [
404-
"import matplotlib.pyplot as plt\n",
405-
"\n",
406-
"fig = plt.figure(figsize=(14,9))\n",
407-
"ax = fig.add_subplot(111, \n",
408-
" projection='3d')\n",
409-
" \n",
410-
"for idx in pca_embeddings.index:\n",
411-
" ax.scatter(pca_embeddings.loc[idx][0],\n",
412-
" pca_embeddings.loc[idx][1],\n",
413-
" pca_embeddings.loc[idx][2],\n",
414-
" s=60)\n",
415-
"\n",
416-
"ax.set_xlabel(\"PC1\", \n",
417-
" fontsize=12)\n",
418-
"ax.set_ylabel(\"PC2\", \n",
419-
" fontsize=12)\n",
420-
"ax.set_zlabel(\"PC3\", \n",
421-
" fontsize=12)\n",
422-
" \n",
423-
"ax.view_init(30, 125)\n",
424-
"plt.title(\"3D PCA plot\")\n",
425-
"plt.show()"
426-
]
427-
},
428398
{
429399
"cell_type": "code",
430400
"execution_count": null,
@@ -719,7 +689,7 @@
719689
"\n",
720690
"trainer_kwargs = {\n",
721691
" # \"max_epochs\": 50, # uncomment for a longer training\n",
722-
" \"max_epochs\": 25,\n",
692+
" \"max_epochs\": 5,\n",
723693
" # \"accelerator\": \"cpu\",\n",
724694
"}\n",
725695
"\n",
@@ -936,7 +906,7 @@
936906
"name": "python",
937907
"nbconvert_exporter": "python",
938908
"pygments_lexer": "ipython3",
939-
"version": "3.11.4"
909+
"version": "3.10.9"
940910
}
941911
},
942912
"nbformat": 4,

0 commit comments

Comments
 (0)