Skip to content

Commit c782f4d

Browse files
authored
Updates to tutorial (#846)
1 parent 0ae9c48 commit c782f4d

File tree

1 file changed

+28
-61
lines changed

1 file changed

+28
-61
lines changed

documentation/tutorials.md

Lines changed: 28 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ These tutorials illustrate how to use a sequence of Kaggle CLI commands to accom
66

77
Before starting these tutorials, please make sure you have:
88

9-
1. Installed the Kaggle CLI.
10-
2. Downloaded your `kaggle.json` API token from your Kaggle account page (e.g., `https://www.kaggle.com/settings`) and placed it in the `~/.kaggle/` directory (or `C:\Users\<Windows-username>\.kaggle\` on Windows).
11-
3. Logged in to your kaggle.com account in a web browser. This will allow you to easily verify the results of the CLI commands in the "Your Work" section of your Kaggle profile.
9+
1. Installed the Kaggle CLI, following the instructions [here](https://github.com/Kaggle/kaggle-api/blob/main/documentation/intro.md#installation).
10+
2. Set up your API credentials, following the instructions [here](https://github.com/Kaggle/kaggle-api/blob/main/documentation/intro.md#api-credentials)
11+
3. Logged in to Kaggle in a web browser. This will allow you to verify the results of the CLI commands in the [`Your Work`](https://www.kaggle.com/work) section of your Kaggle profile.
1212

1313
## Tutorial: Create a Dataset
1414

@@ -41,24 +41,18 @@ This tutorial walks you through creating a new dataset on Kaggle.
4141
* Replace `"INSERT_SLUG_HERE"` with a URL-friendly version of your title, e.g., `"my-sample-dataset"`. The URL-friendly version is made by converting the title to lower-case and changing spaces to dashes.
4242
* You can also add licenses, descriptions, and other relevant information.
4343

44-
*Example using `sed` (for Linux/macOS):*
45-
```bash
46-
sed -i 's/INSERT_TITLE_HERE/My Sample Dataset/' dataset-metadata.json
47-
sed -i 's/INSERT_SLUG_HERE/my-sample-dataset/' dataset-metadata.json
48-
```
49-
5044
5. **Create the dataset.** This command uploads your `sample_data.csv` and `dataset-metadata.json` to Kaggle.
5145

5246
```bash
5347
kaggle datasets create -p .
5448
```
5549
You can add `--public` to make it public immediately.
5650

57-
6. **Verify on Kaggle.com.** Go to your Kaggle profile and check the "Datasets" tab in the "Your Work" section. You should see "My Sample Dataset".
51+
6. **Verify on Kaggle.com.** Refresh the [`Datasets` tab in `Your Work`](https://www.kaggle.com/work/datasets). You should see "My Sample Dataset".
5852

59-
## Tutorial: Download a Dataset and Prepare for Analysis
53+
## Tutorial: Find and Download a Dataset
6054

61-
This tutorial explains how to find, download, and prepare a Kaggle dataset for local analysis using the CLI.
55+
This tutorial explains how to find and download using the CLI.
6256

6357
1. **Search for a Dataset (Optional).**
6458
* If you know the dataset you want, you can skip this step. Otherwise, you can search for datasets. For example, to search for datasets related to "iris":
@@ -91,30 +85,19 @@ This tutorial explains how to find, download, and prepare a Kaggle dataset for l
9185
# For uciml/iris, it's iris.zip
9286
unzip iris.zip
9387
```
94-
* After unzipping, you should see the data files (e.g., `Iris.csv`, `database.sqlite`).
88+
9589

96-
5. **Prepare for Analysis.**
97-
* The dataset is now downloaded and extracted. The primary data file for the Iris dataset is `Iris.csv`.
98-
* You can now use your preferred tools (e.g., Python with libraries like Pandas and Scikit-learn, R, etc.) to load and analyze the data.
99-
* For example, in a Python script within the `iris-dataset-analysis` directory, you might load the data using Pandas:
100-
```python
101-
import pandas as pd
102-
df = pd.read_csv('Iris.csv')
103-
print(df.head())
104-
print(df.info())
105-
```
90+
5. **Verify the results.**
91+
* After unzipping, you should see the data files (e.g., `Iris.csv`, `database.sqlite`).
10692

107-
This completes the process of downloading a dataset and preparing it for analysis using the Kaggle CLI.
108-
You can adapt these steps for any dataset on Kaggle.
10993

11094
## Tutorial: Update a Kernel (Notebook)
11195

11296
This tutorial shows how to download an existing kernel, modify it, and push the changes back to Kaggle.
11397

11498
1. **Create or identify a kernel on Kaggle.com.**
11599
* Log in to kaggle.com.
116-
* Find an existing notebook (or create one). For this tutorial, let's assume its title is "My CLI Test Kernel".
117-
* If the notebook has not been saved before, make a small change and **save a version** of the notebook on Kaggle.com (e.g., click "Save Version" and choose "Save & Run All (Commit)"). You cannot pull or push a kernel that is only in draft form.
100+
* Find an existing notebook you own (or create one). For this tutorial, let's assume its title is "My CLI Test Kernel".
118101
* Note the kernel slug from the browser's address bar. It will be something like `YOUR_USERNAME/my-cli-test-kernel`.
119102

120103
2. **Create a new local directory for your kernel.**
@@ -135,15 +118,15 @@ This tutorial shows how to download an existing kernel, modify it, and push the
135118
4. **Edit the kernel or metadata.**
136119
* Open the downloaded notebook file (e.g., `my-cli-test-kernel.ipynb`) and make some changes to the code or content.
137120
* Open `kernel-metadata.json`. Let's add "benchmark" to the keywords. Find the `"keywords": []` line and change it to `"keywords": ["benchmark"]`.
138-
* *Note: While you can edit keywords here, it's often best to manage them on kaggle.com, as there might be a restricted list of allowed keywords.*
121+
* *Note: While you can edit keywords here, it's often best to manage them on kaggle.com, as there is a restricted list of allowed keywords.*
139122

140123
5. **Push the kernel.** This uploads your changes and the updated metadata, then runs the kernel on Kaggle.
141124

142125
```bash
143126
kaggle kernels push -p .
144127
```
145128

146-
6. **Verify on Kaggle.com.** Refresh the notebook page on kaggle.com. You should see your code changes and the "benchmark" tag added to the kernel settings.
129+
6. **Verify on Kaggle.com.** Refresh the [`Code` tab in `Your Work`](https://www.kaggle.com/work/code). You should see your code changes and the "benchmark" tag added to the kernel settings.
147130

148131
## Tutorial: Create a Model
149132

@@ -170,21 +153,13 @@ This tutorial guides you through creating a new model on Kaggle.
170153
* Replace `"INSERT_SLUG_HERE"` with a URL-friendly version of the title (e.g., `"my-awesome-ai-model"`).
171154
* Fill out the `"description"` field and other relevant sections like `"licenses"`.
172155

173-
*Example using `sed` (for Linux/macOS):*
174-
```bash
175-
# Replace YOUR_USERNAME with your actual Kaggle username
176-
sed -i 's/INSERT_OWNER_SLUG_HERE/YOUR_USERNAME/' model-metadata.json
177-
sed -i 's/INSERT_TITLE_HERE/My Awesome AI Model/' model-metadata.json
178-
sed -i 's/INSERT_SLUG_HERE/my-awesome-ai-model/' model-metadata.json
179-
```
180-
181156
5. **Create the model.**
182157

183158
```bash
184159
kaggle models create -p .
185160
```
186161

187-
6. **Verify on Kaggle.com.** Go to your Kaggle profile and check the "Models" tab in the "Your Work" section. You should see "My Awesome AI Model".
162+
6. **Verify on Kaggle.com.** Refresh the [`Models` tab in `Your Work`](https://www.kaggle.com/work/models). You should see "My Awesome AI Model".
188163

189164
## Tutorial: Create a Model Instance
190165

@@ -213,22 +188,13 @@ This tutorial shows how to create an instance under an existing model. A model i
213188
* Replace `"INSERT_FRAMEWORK_HERE"` with the model framework (e.g., `"jax"`, `"tensorflow"`, `"pytorch"`, `"sklearn"`).
214189
* Update the `"instance_size_bytes"` if known, and add a `"description"`.
215190
216-
*Example using `sed` (for Linux/macOS):*
217-
```bash
218-
# Replace YOUR_USERNAME and my-awesome-ai-model accordingly
219-
sed -i 's/INSERT_OWNER_SLUG_HERE/YOUR_USERNAME/' model-instance-metadata.json
220-
sed -i 's/INSERT_EXISTING_MODEL_SLUG_HERE/my-awesome-ai-model/' model-instance-metadata.json
221-
sed -i 's/INSERT_INSTANCE_SLUG_HERE/jax-implementation/' model-instance-metadata.json
222-
sed -i 's/INSERT_FRAMEWORK_HERE/jax/' model-instance-metadata.json
223-
```
224-
225191
5. **Create the model instance.** This uploads the files in the current directory (e.g., `flax_model.params`) along with the instance metadata.
226192
227193
```bash
228194
kaggle models instances create -p .
229195
```
230196
231-
6. **Verify on Kaggle.com.** Go to your model's page on Kaggle. You should see a new "jax-implementation" instance listed, and it will have one version containing `flax_model.params`.
197+
6. **Verify on Kaggle.com.** Go to your model's page on Kaggle by clicking on the model under in the [`Models` tab on `Your Work`](https://www.kaggle.com/work/models). You should see a new "jax-implementation" instance listed, and it will have one version containing `flax_model.params`.
232198

233199
## Tutorial: Create a Model Instance Version
234200

@@ -252,16 +218,16 @@ This tutorial explains how to add a new version to an existing model instance, f
252218
```
253219
*Note: The `-p .` means all files in the current directory will be uploaded as part of this new version. If you only want to upload `flax_model_v2.params`, ensure only it (and any other V2 files) are in a directory and point `-p` to that directory, or manage your files carefully.*
254220
255-
4. **Verify on Kaggle.com.** Go to your model instance page on Kaggle (e.g., `YOUR_USERNAME/my-awesome-ai-model/jax/jax-implementation`). You should see a new version (e.g., version 2) listed with your notes and the new files.
221+
4. **Verify on Kaggle.com.** Go to your model instance page on Kaggle (e.g., `YOUR_USERNAME/my-awesome-ai-model/jax/jax-implementation`) by clicking on the [`Models` tab on `Your Work`](https://www.kaggle.com/work/models). You should see a new version (e.g., version 2) listed with your notes and the new files.
256222
257223
## Tutorial: How to Submit to a Competition
258224
259225
This tutorial walks you through the process of making a submission to a Kaggle competition using the CLI.
260226
261227
1. **Find a Competition and Accept Rules.**
262228
* First, you need to find a competition. You can list active competitions using `kaggle competitions list`.
263-
* For this tutorial, we'll use the "titanic" competition, which is a common starting point. You can find it at `https://www.kaggle.com/c/titanic`.
264-
* **Important**: Before you can download data or submit, you *must* accept the competition's rules on the Kaggle website. Navigate to the competition page (e.g., `https://www.kaggle.com/c/titanic/rules`) and accept the terms.
229+
* For this tutorial, we'll use the "titanic" competition, which is a common starting point. You can find it at [`https://www.kaggle.com/c/titanic`](https://www.kaggle.com/c/titanic).
230+
* **Important**: Before you can download data or submit, you *must* join the competition and accept the competition's rules on the Kaggle website. Navigate to the competition on kaggle.com to do this.
265231
266232
2. **Create a Directory and Download Competition Files.**
267233
* Create a new directory for your competition files and navigate into it.
@@ -307,22 +273,21 @@ This tutorial walks you through the process of making a submission to a Kaggle c
307273

308274
5. **Check Your Submission Status.**
309275
* After submitting, you'll get a message indicating success or failure.
310-
* You can check your submission's score and status on the "My Submissions" tab of the competition page on Kaggle.com (e.g., `https://www.kaggle.com/c/titanic/submissions`).
276+
* You can check your submission's score and status on the "My Submissions" tab of the competition page on Kaggle.com (e.g., [`https://www.kaggle.com/c/titanic/submissions`](https://www.kaggle.com/c/titanic/submissions)).
311277
* You can also list your recent submissions and their scores via the CLI:
312278
```bash
313279
kaggle competitions submissions -c titanic
314280
```
315281
* This command will show your submission, its status (e.g., `complete`, `error`), and your public/private scores if available.
316282

317-
This completes the process of submitting to a Kaggle competition using the CLI!
318283

319284
## Tutorial: How to Submit to a Code Competition
320285

321286
This tutorial walks you through the process of submitting to a code competition on Kaggle.
322287

323288
1. **Find a Code Competition.**
324289

325-
* First, you need to find a code competition to participate in. You can browse the available competitions on the [Kaggle competitions page](https://www.kaggle.com/competitions).
290+
* First, you need to find a code competition to participate in. You can browse the available competitions on the [Kaggle competitions page](https://www.kaggle.com/competitions). Many Featured Competitions are code competitions.
326291

327292
2. **Download the Dataset.**
328293

@@ -332,24 +297,26 @@ This tutorial walks you through the process of submitting to a code competition
332297
```
333298
* Replace `<competition-name>` with the name of the competition you want to participate in.
334299

335-
3. **Create a Kernel.**
300+
3. **Create a Notebook.**
336301

337-
* Next, you need to create a kernel to work on your submission. A kernel is a computational environment that you can use to write and run your code. You can create a new kernel on the Kaggle website or by using the `kaggle kernels init` command.
302+
* Next, you need to create a Kaggle Notebook to work on your submission. A Kaggle Notebook contains the code and environment settings for Kaggle to run and evaluate your submission. Follow the tutorial on [Creating / Updating Notebooks](https://github.com/Kaggle/kaggle-api/blob/main/documentation/tutorials.md#tutorial-update-a-kernel-notebook) if you're not sure how to do this.
338303
339304
4. **Write Your Code.**
340305
341-
* Now it's time to write your code! You can use any programming language or framework that you are comfortable with. The goal is to create a model that can make predictions on the test set.
306+
* Now it's time to write your code! You can use any programming language or framework that is supported by Kaggle. The goal is to create a model that can make predictions on the test set.
342307

343308
5. **Submit Your Prediction.**
344309

345310
* Once you are happy with your model, you can submit your prediction to the competition. You can do this using the `kaggle competitions submit` command:
346311
```bash
347-
kaggle competitions submit -c <competition-name> -f <submission-file> -m <message>
312+
kaggle competitions submit -c <competition-name> -k <username>/<notebook-slug> -m <message>
348313
```
349-
* Replace `<competition-name>` with the name of the competition, `<submission-file>` with the path to your submission file, and `<message>` with a brief description of your submission.
314+
* Replace `<competition-name>` with the name of the competition, `<username>/<notebook-slug>` with the identifier of your notebook, and `<message>` with a brief description of your submission.
350315

351316
6. **Check Your Score.**
352317

353-
* After you have submitted your prediction, you can check your score on the competition leaderboard. The leaderboard shows the scores of all the participants in the competition.
318+
* After you have submitted your prediction, you can check your score on the competition leaderboard. The leaderboard shows the scores of all the participants in the competition. You can download the leaderboard using the `kaggle competitions leaderboard` command:
319+
```bash
320+
kaggle competitions leaderboard <competition-name>
321+
```
354322

355-
That's it! You have now successfully submitted to a code competition on Kaggle.

0 commit comments

Comments
 (0)