Skip to content

Commit 1fa9e37

Browse files
authored
Merge pull request #159 from gperdrizet/dev
Added requirements file for Kaggle
2 parents 0010231 + eeea690 commit 1fa9e37

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

notebooks/unit3/lesson_20/Lesson_20_activity.ipynb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,19 @@
4848
" - Your notebook must output test set predictions to `submission.csv` in the correct format\n",
4949
" - Go to 'Submit to competition' tab in the right sidebar and click 'Submit'\n",
5050
"\n",
51-
"**Note:** This notebook uses a `KAGGLE` flag (under 'Run configuration') to switch between Kaggle and local file paths. Set it to `True` when running on Kaggle, or `False` when running locally with data in a `../data/` directory.\n",
51+
"You may see warnings when running on Kaggle due to inconsistencies in installed package versions between your environment and Kaggle. If you are using a virtual environment already, install this [kaggle_requirements.txt](https://github.com/gperdrizet/FSA_devops/blob/main/notebooks/unit3/lesson_20/kaggle_requirements.txt.ipynb):\n",
52+
"\n",
53+
"```\n",
54+
"pip install --force-reinstall kaggle_requirements.txt\n",
55+
"```\n",
56+
"\n",
57+
"This is working for me with Python 3.12. It contains a slightly newer version of scikit-learn than is found on Kaggle. Update in the Kaggle environment by going to 'Add-ons' -> 'Install Dependencies' and adding:\n",
58+
"\n",
59+
"```\n",
60+
"pip install scikit-learn==1.5.2\n",
61+
"```\n",
62+
"\n",
63+
">**Note:** This notebook uses a `KAGGLE` flag (under 'Run >configuration') to switch between Kaggle and local file paths. Set it >to `True` when running on Kaggle, or `False` when running locally.\n",
5264
"\n",
5365
"## Notebook set-up\n",
5466
"\n",
@@ -122,7 +134,7 @@
122134
},
123135
{
124136
"cell_type": "code",
125-
"execution_count": 3,
137+
"execution_count": null,
126138
"id": "d1a2421c",
127139
"metadata": {
128140
"execution": {
@@ -358,11 +370,13 @@
358370
"source": [
359371
"# Set file paths based on environment\n",
360372
"if KAGGLE:\n",
373+
"\n",
361374
" # Kaggle paths - data is in /kaggle/input/\n",
362375
" train_df_path = '/kaggle/input/playground-series-s5e12/train.csv'\n",
363376
" test_df_path = '/kaggle/input/playground-series-s5e12/test.csv'\n",
364377
"\n",
365378
"else:\n",
379+
"\n",
366380
" # Otherwise, load data from course GitHub repository\n",
367381
" train_df_path = 'https://gperdrizet.github.io/FSA_devops/assets/data/unit3/diabetes_prediction_train.csv'\n",
368382
" test_df_path = 'https://gperdrizet.github.io/FSA_devops/assets/data/unit3/diabetes_prediction_test.csv'\n",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ipykernel
2+
matplotlib==3.7.2
3+
numpy==1.26.4
4+
pandas==2.2.3
5+
scipy==1.15.3
6+
scikit-learn==1.2.2
7+
seaborn==0.12.2
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
layout: post
3+
title: "Kaggle requirements"
4+
date: 2025-12-08
5+
categories: resources
6+
---
7+
8+
Added a `requirements.txt` file for Kaggle notebooks.
9+
10+
You may see warnings when running on Kaggle due to inconsistencies in installed package versions between your environment and Kaggle. If you are using a virtual environment already, install this [kaggle_requirements.txt](https://github.com/gperdrizet/FSA_devops/blob/main/notebooks/unit3/lesson_20/kaggle_requirements.txt):
11+
12+
```
13+
pip install --force-reinstall kaggle_requirements.txt
14+
```
15+
16+
This is working for me with Python 3.12. It contains a slightly newer version of scikit-learn than is found on Kaggle. Update in the Kaggle environment by going to 'Add-ons' -> 'Install Dependencies' and adding:
17+
18+
```
19+
pip install scikit-learn==1.5.2
20+
```

0 commit comments

Comments
 (0)