{
"cells": [
{
"cell_type": "markdown",
"id": "df15487e",
"metadata": {
"papermill": {
"duration": 0.003655,
"end_time": "2026-05-12T18:12:35.316317+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:35.312662+00:00",
"status": "completed"
},
"tags": []
},
"source": [
"# Digit Recognizer"
]
},
{
"cell_type": "markdown",
"id": "fe874a2f",
"metadata": {
"papermill": {
"duration": 0.002338,
"end_time": "2026-05-12T18:12:35.321466+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:35.319128+00:00",
"status": "completed"
},
"tags": []
},
"source": [
""
]
},
{
"cell_type": "markdown",
"id": "7ced5fba",
"metadata": {
"papermill": {
"duration": 0.002482,
"end_time": "2026-05-12T18:12:35.326178+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:35.323696+00:00",
"status": "completed"
},
"tags": []
},
"source": [
"## Dataset Description\n",
"\n",
"The data files train.csv and test.csv contain gray-scale images of hand-drawn digits, from zero through nine.\n",
"\n",
"Each image is 28 pixels in height and 28 pixels in width, for a total of 784 pixels in total. Each pixel has a single pixel-value associated with it, indicating the lightness or darkness of that pixel, with higher numbers meaning darker. This pixel-value is an integer between 0 and 255, inclusive.\n",
"\n",
"The training data set, (train.csv), has 785 columns. The first column, called \"label\", is the digit that was drawn by the user. The rest of the columns contain the pixel-values of the associated image.\n",
"\n",
"The test data set, (test.csv), is the same as the training set, except that it does not contain the \"label\" column.\n"
]
},
{
"cell_type": "markdown",
"id": "ec4b165d",
"metadata": {
"papermill": {
"duration": 0.002622,
"end_time": "2026-05-12T18:12:35.331393+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:35.328771+00:00",
"status": "completed"
},
"tags": []
},
"source": [
"## Aim & Target \n",
"\n",
"**Aim**\n",
"\n",
"The primary aim of this project is to develop a robust machine learning model capable of accurately identifying and classifying hand-drawn digits from the MNIST dataset. By leveraging a Convolutional Neural Network (CNN), the goal is to map high-dimensional pixel data into ten distinct numerical categories. \n",
"\n",
"**Target**\n",
"\n",
"The target is to achieve a categorization accuracy exceeding 98% on the 28,000 test images while maintaining a computationally efficient pipeline. Successfully meeting this benchmark will result in a submission file that correctly maps each ImageId to its predicted Label. This project serves as a foundational milestone in mastering image recognition and deep learning deployment workflows."
]
},
{
"cell_type": "markdown",
"id": "394fd234",
"metadata": {
"papermill": {
"duration": 0.003652,
"end_time": "2026-05-12T18:12:35.339320+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:35.335668+00:00",
"status": "completed"
},
"tags": []
},
"source": [
"## Importing Libraries"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "9f5737cf",
"metadata": {
"execution": {
"iopub.execute_input": "2026-05-12T18:12:35.349925Z",
"iopub.status.busy": "2026-05-12T18:12:35.349460Z",
"iopub.status.idle": "2026-05-12T18:12:38.936432Z",
"shell.execute_reply": "2026-05-12T18:12:38.935526Z"
},
"papermill": {
"duration": 3.595043,
"end_time": "2026-05-12T18:12:38.938258+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:35.343215+00:00",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"from sklearn.model_selection import train_test_split\n"
]
},
{
"cell_type": "markdown",
"id": "eab327cf",
"metadata": {
"papermill": {
"duration": 0.002335,
"end_time": "2026-05-12T18:12:38.943048+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:38.940713+00:00",
"status": "completed"
},
"tags": []
},
"source": [
"## Dataframe Generation"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f28ea190",
"metadata": {
"execution": {
"iopub.execute_input": "2026-05-12T18:12:38.949488Z",
"iopub.status.busy": "2026-05-12T18:12:38.948546Z",
"iopub.status.idle": "2026-05-12T18:12:42.619012Z",
"shell.execute_reply": "2026-05-12T18:12:42.618094Z"
},
"papermill": {
"duration": 3.675462,
"end_time": "2026-05-12T18:12:42.620795+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:38.945333+00:00",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"train = pd.read_csv(\"/kaggle/input/competitions/digit-recognizer/train.csv\") \n",
"\n",
"test = pd.read_csv(\"/kaggle/input/competitions/digit-recognizer/test.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "da8e3239",
"metadata": {
"execution": {
"iopub.execute_input": "2026-05-12T18:12:42.627192Z",
"iopub.status.busy": "2026-05-12T18:12:42.626825Z",
"iopub.status.idle": "2026-05-12T18:12:42.659630Z",
"shell.execute_reply": "2026-05-12T18:12:42.658951Z"
},
"papermill": {
"duration": 0.03771,
"end_time": "2026-05-12T18:12:42.661103+00:00",
"exception": false,
"start_time": "2026-05-12T18:12:42.623393+00:00",
"status": "completed"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"
| \n", " | label | \n", "pixel0 | \n", "pixel1 | \n", "pixel2 | \n", "pixel3 | \n", "pixel4 | \n", "pixel5 | \n", "pixel6 | \n", "pixel7 | \n", "pixel8 | \n", "... | \n", "pixel774 | \n", "pixel775 | \n", "pixel776 | \n", "pixel777 | \n", "pixel778 | \n", "pixel779 | \n", "pixel780 | \n", "pixel781 | \n", "pixel782 | \n", "pixel783 | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 2 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 3 | \n", "4 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 4 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
5 rows × 785 columns
\n", "RandomForestClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
RandomForestClassifier()