{ "cells": [ { "cell_type": "markdown", "id": "dd59fccd", "metadata": { "papermill": { "duration": 0.003701, "end_time": "2025-12-04T16:45:56.340937", "exception": false, "start_time": "2025-12-04T16:45:56.337236", "status": "completed" }, "tags": [] }, "source": [ "# Kaggle student health risk challenge: submission template\n", "\n", "Our lesson 20 classification activity uses an active Kaggle playground competition. Playground competitions run every month and are designed for fast iteration and skill practice.\n", "\n", "This month's competition is: [Playground Series - Season 6, Episode 7: Predicting student health risk](https://www.kaggle.com/competitions/playground-series-s6e7)\n", "\n", "This notebook template is structured for local development first. It is pre-filled with data-loading code and a random baseline submission in section 5.\n", "\n", "## How to submit to Kaggle\n", "\n", "You can choose one of these three workflows to participate in the competition.\n", "\n", "### Option 1: use the course submission repo fork (recommended)\n", "\n", "Use a fork of this repository:\n", "\n", "- [gperdrizet/student-health-risk](https://github.com/gperdrizet/student-health-risk)\n", "\n", "This repo includes a GitHub workflow that submits automatically when a pull request is merged to `main`.\n", "\n", "Typical flow:\n", "\n", "1. Fork the repo and clone your fork.\n", "2. Build your model and generate `submission.csv` using the required Kaggle format.\n", "3. Commit and push your changes to a branch.\n", "4. Open and merge a pull request into `main`.\n", "5. The workflow submits your file automatically.\n", "\n", "### Option 2: work locally and upload manually\n", "\n", "1. Run this notebook locally and create `submission.csv`.\n", "2. Go to the competition page and click `Submit Predictions`.\n", "3. Upload your `submission.csv` file manually.\n", "\n", "### Option 3: work in a Kaggle notebook\n", "\n", "1. Upload or create a notebook on Kaggle (`Code` -> `Create` -> `Import notebook`).\n", "2. Add the competition dataset as a notebook source:\n", " - Open the `Input` tab in the right sidebar.\n", " - Click `+ Add Input` and filter by `Competition Datasets`.\n", " - Select `Playground Series - Season 6, Episode 7`.\n", "3. Update the data-loading cell paths to Kaggle paths:\n", " - `train_df_path = '/kaggle/input/playground-series-s6e7/train.csv'`\n", " - `test_df_path = '/kaggle/input/playground-series-s6e7/test.csv'`\n", "4. Run the notebook and submit from the Kaggle notebook sidebar.\n", "\n", "\n", "## Notebook set-up\n", "\n", "### Imports" ] }, { "cell_type": "code", "execution_count": null, "id": "04d85a3b", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:45:56.348530Z", "iopub.status.busy": "2025-12-04T16:45:56.348220Z", "iopub.status.idle": "2025-12-04T16:45:58.407545Z", "shell.execute_reply": "2025-12-04T16:45:58.406198Z" }, "papermill": { "duration": 2.065596, "end_time": "2025-12-04T16:45:58.409770", "exception": false, "start_time": "2025-12-04T16:45:56.344174", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Standard library imports\n", "from pathlib import Path\n", "\n", "# Third party imports\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "2ae53a2b", "metadata": { "papermill": { "duration": 0.002851, "end_time": "2025-12-04T16:45:58.415832", "exception": false, "start_time": "2025-12-04T16:45:58.412981", "status": "completed" }, "tags": [] }, "source": [ "### Data loading" ] }, { "cell_type": "code", "execution_count": null, "id": "d1a2421c", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:45:58.423485Z", "iopub.status.busy": "2025-12-04T16:45:58.423107Z", "iopub.status.idle": "2025-12-04T16:46:02.306776Z", "shell.execute_reply": "2025-12-04T16:46:02.305525Z" }, "papermill": { "duration": 3.889301, "end_time": "2025-12-04T16:46:02.308493", "exception": false, "start_time": "2025-12-04T16:45:58.419192", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Download competition data directly from GitHub raw URLs\n", "train_df_url = 'https://raw.githubusercontent.com/gperdrizet/student-health-risk/main/data/raw/student-health-risk-train.csv'\n", "test_df_url = 'https://raw.githubusercontent.com/gperdrizet/student-health-risk/main/data/raw/student-health-risk-test.csv'\n", "\n", "# Load the training and testing datasets\n", "train_df = pd.read_csv(train_df_url)\n", "test_df = pd.read_csv(test_df_url)\n", "\n", "# Display first few rows of training data\n", "train_df.head()" ] }, { "cell_type": "code", "execution_count": null, "id": "c9edb967", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:46:02.316341Z", "iopub.status.busy": "2025-12-04T16:46:02.316028Z", "iopub.status.idle": "2025-12-04T16:46:02.579217Z", "shell.execute_reply": "2025-12-04T16:46:02.577176Z" }, "papermill": { "duration": 0.26922, "end_time": "2025-12-04T16:46:02.581019", "exception": false, "start_time": "2025-12-04T16:46:02.311799", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Display dataset information (columns, dtypes, non-null counts)\n", "train_df.info()" ] }, { "cell_type": "markdown", "id": "c2f83f1b", "metadata": { "papermill": { "duration": 0.003317, "end_time": "2025-12-04T16:46:02.588198", "exception": false, "start_time": "2025-12-04T16:46:02.584881", "status": "completed" }, "tags": [] }, "source": [ "## 1. EDA" ] }, { "cell_type": "code", "execution_count": null, "id": "1b49dac8", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:46:02.597068Z", "iopub.status.busy": "2025-12-04T16:46:02.596748Z", "iopub.status.idle": "2025-12-04T16:46:02.601201Z", "shell.execute_reply": "2025-12-04T16:46:02.600004Z" }, "papermill": { "duration": 0.011581, "end_time": "2025-12-04T16:46:02.603066", "exception": false, "start_time": "2025-12-04T16:46:02.591485", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Your code here..." ] }, { "cell_type": "markdown", "id": "15d1a762", "metadata": { "papermill": { "duration": 0.003202, "end_time": "2025-12-04T16:46:02.609520", "exception": false, "start_time": "2025-12-04T16:46:02.606318", "status": "completed" }, "tags": [] }, "source": [ "## 2. Feature engineering" ] }, { "cell_type": "code", "execution_count": null, "id": "715276e5", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:46:02.617258Z", "iopub.status.busy": "2025-12-04T16:46:02.616925Z", "iopub.status.idle": "2025-12-04T16:46:02.621182Z", "shell.execute_reply": "2025-12-04T16:46:02.620037Z" }, "papermill": { "duration": 0.010201, "end_time": "2025-12-04T16:46:02.622943", "exception": false, "start_time": "2025-12-04T16:46:02.612742", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Your code here..." ] }, { "cell_type": "markdown", "id": "0a0e0c1b", "metadata": { "papermill": { "duration": 0.002954, "end_time": "2025-12-04T16:46:02.629151", "exception": false, "start_time": "2025-12-04T16:46:02.626197", "status": "completed" }, "tags": [] }, "source": [ "## 3. Model building" ] }, { "cell_type": "code", "execution_count": null, "id": "abdb3c80", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:46:02.636717Z", "iopub.status.busy": "2025-12-04T16:46:02.636400Z", "iopub.status.idle": "2025-12-04T16:46:02.641384Z", "shell.execute_reply": "2025-12-04T16:46:02.640372Z" }, "papermill": { "duration": 0.010911, "end_time": "2025-12-04T16:46:02.643109", "exception": false, "start_time": "2025-12-04T16:46:02.632198", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Your code here..." ] }, { "cell_type": "markdown", "id": "530931ae", "metadata": { "papermill": { "duration": 0.002984, "end_time": "2025-12-04T16:46:02.649294", "exception": false, "start_time": "2025-12-04T16:46:02.646310", "status": "completed" }, "tags": [] }, "source": [ "## 4. Model evaluation" ] }, { "cell_type": "code", "execution_count": null, "id": "fddaa21e", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:46:02.656583Z", "iopub.status.busy": "2025-12-04T16:46:02.656295Z", "iopub.status.idle": "2025-12-04T16:46:02.661034Z", "shell.execute_reply": "2025-12-04T16:46:02.660017Z" }, "papermill": { "duration": 0.010313, "end_time": "2025-12-04T16:46:02.662563", "exception": false, "start_time": "2025-12-04T16:46:02.652250", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Your code here..." ] }, { "cell_type": "markdown", "id": "4a4303c1", "metadata": { "papermill": { "duration": 0.003006, "end_time": "2025-12-04T16:46:02.668933", "exception": false, "start_time": "2025-12-04T16:46:02.665927", "status": "completed" }, "tags": [] }, "source": [ "## 5. Submission" ] }, { "cell_type": "code", "execution_count": null, "id": "edf67e48", "metadata": { "execution": { "iopub.execute_input": "2025-12-04T16:46:02.676497Z", "iopub.status.busy": "2025-12-04T16:46:02.676229Z", "iopub.status.idle": "2025-12-04T16:46:02.971039Z", "shell.execute_reply": "2025-12-04T16:46:02.970066Z" }, "papermill": { "duration": 0.300682, "end_time": "2025-12-04T16:46:02.972781", "exception": false, "start_time": "2025-12-04T16:46:02.672099", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Make random predictions for submission by sampling from the training labels\n", "# Note: Replace this with your model's predictions.\n", "predictions = train_df['health_condition'].sample(n=test_df.shape[0], random_state=42)\n", "prediction_ids = test_df['id'].astype(int)\n", "\n", "# Create submission DataFrame with required format: id, health_condition\n", "submission_df = pd.DataFrame({\n", " 'id': prediction_ids.values,\n", " 'health_condition': predictions.values\n", "})\n", "\n", "# Save submission file and display preview\n", "submission_file = 'submission.csv'\n", "submission_df.to_csv(submission_file, index=False)\n", "submission_df.head()" ] } ], "metadata": { "kaggle": { "accelerator": "none", "dataSources": [ { "databundleVersionId": 14272474, "sourceId": 91723, "sourceType": "competition" } ], "dockerImageVersionId": 31192, "isGpuEnabled": false, "isInternetEnabled": true, "language": "python", "sourceType": "notebook" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.12" }, "papermill": { "default_parameters": {}, "duration": 12.320018, "end_time": "2025-12-04T16:46:03.599457", "environment_variables": {}, "exception": null, "input_path": "__notebook__.ipynb", "output_path": "__notebook__.ipynb", "parameters": {}, "start_time": "2025-12-04T16:45:51.279439", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }