├── .gitignore ├── LICENSE ├── README.md ├── mnist_digit_classification.ipynb └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control 110 | .pdm.toml 111 | .pdm-python 112 | .pdm-build/ 113 | 114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 115 | __pypackages__/ 116 | 117 | # Celery stuff 118 | celerybeat-schedule 119 | celerybeat.pid 120 | 121 | # SageMath parsed files 122 | *.sage.py 123 | 124 | # Environments 125 | .env 126 | .venv 127 | env/ 128 | venv/ 129 | ENV/ 130 | env.bak/ 131 | venv.bak/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | .dmypy.json 146 | dmypy.json 147 | 148 | # Pyre type checker 149 | .pyre/ 150 | 151 | # pytype static type analyzer 152 | .pytype/ 153 | 154 | # Cython debug symbols 155 | cython_debug/ 156 | 157 | # PyCharm 158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 160 | # and can be added to the global gitignore or merged into this file. For a more nuclear 161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 162 | #.idea/ 163 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Ata Turhan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MNIST Digit Classification with PyTorch 2 | 3 | A complete PyTorch-based solution for the MNIST handwritten digit classification challenge, including data exploration, model training, evaluation, and Kaggle submission generation. 4 | 5 | ## Overview 6 | 7 | The MNIST dataset is a collection of 70,000 grayscale images of handwritten digits (0–9). This project solves the multi-class classification problem of identifying the correct digit for each image. It serves as an excellent introduction to deep learning concepts, particularly neural networks. 8 | 9 | ## Features 10 | 11 | - **Data Preprocessing**: Includes normalization and custom PyTorch `Dataset` creation. 12 | - **Exploratory Data Analysis**: Visualizes sample images and provides statistical insights. 13 | - **Deep Learning Model**: Implements a fully connected neural network using PyTorch. 14 | - **Training and Evaluation**: Tracks loss and accuracy with a validation split. 15 | - **Kaggle Submission**: Generates predictions and prepares a CSV for Kaggle competition submission. 16 | 17 | ## Getting Started 18 | 19 | ### Prerequisites 20 | 21 | - Python 3.8+ 22 | - PyTorch 1.12+ 23 | - Jupyter Notebook or Kaggle environment 24 | 25 | ### Installation 26 | 27 | 1. Clone this repository: 28 | ```bash 29 | git clone https://github.com/ata-turhan/MNIST-Digit-Classification-PyTorch.git 30 | ``` 31 | 2. Navigate to the project directory: 32 | ```bash 33 | cd MNIST-Digit-Classification-PyTorch 34 | ``` 35 | 3. Install the required dependencies: 36 | ```bash 37 | pip install -r requirements.txt 38 | ``` 39 | 40 | ## Usage 41 | 42 | 1. **Run the Notebook**: 43 | Open `mnist_digit_classification.ipynb` in Jupyter Notebook or directly on Kaggle. 44 | 45 | 2. **Train the Model**: 46 | Execute the notebook cells to preprocess data, train the model, and evaluate it. 47 | 48 | 3. **Generate Kaggle Submission**: 49 | Run the prediction step to create `submission.csv`, ready for upload to Kaggle. 50 | 51 | ## Repository Structure 52 | 53 | ``` 54 | MNIST-Digit-Classification-PyTorch/ 55 | │ 56 | ├── README.md # Project overview 57 | ├── mnist_digit_classification.ipynb # Main notebook 58 | ├── requirements.txt # Python dependencies 59 | └── LICENSE # MIT License 60 | ``` 61 | 62 | ## Results 63 | 64 | The model achieves an accuracy of **96.95%** on the validation set and **96.89%** on Kaggle leaderboard submissions. 65 | 66 | ## Contributing 67 | 68 | Contributions are welcome! Please submit a pull request or raise an issue if you find a bug or have suggestions for improvement. 69 | 70 | ## License 71 | 72 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 73 | -------------------------------------------------------------------------------- /mnist_digit_classification.ipynb: -------------------------------------------------------------------------------- 1 | {"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":3004,"databundleVersionId":861823,"sourceType":"competition"}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Task 0: Introduction\n\nThe MNIST dataset is a benchmark dataset in machine learning and computer vision, consisting of 70,000 grayscale images of handwritten digits (0–9), each of size 28x28 pixels. The task is to classify each image into its corresponding digit, making it a multi-class classification problem. This challenge serves as an excellent introduction to deep learning, enabling the application of neural networks to solve real-world problems.\n\nIn this notebook, we will build a neural network using PyTorch to classify the MNIST digits. The solution involves loading and preprocessing the data, designing and training a deep learning model, evaluating its performance, and generating predictions for submission to Kaggle. This structured approach ensures reproducible results and facilitates understanding of fundamental deep learning concepts.","metadata":{}},{"cell_type":"markdown","source":"# Task 1: Importing Libraries","metadata":{}},{"cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n for filename in filenames:\n print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2024-11-19T02:47:00.602955Z","iopub.execute_input":"2024-11-19T02:47:00.603358Z","iopub.status.idle":"2024-11-19T02:47:01.770963Z","shell.execute_reply.started":"2024-11-19T02:47:00.603321Z","shell.execute_reply":"2024-11-19T02:47:01.769779Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Importing Necessary Libraries\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split\nimport torch\nfrom torch.utils.data import DataLoader, Dataset\nfrom torch import nn, optim","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:17:20.085246Z","iopub.execute_input":"2024-11-19T03:17:20.085596Z","iopub.status.idle":"2024-11-19T03:17:20.661446Z","shell.execute_reply.started":"2024-11-19T03:17:20.085567Z","shell.execute_reply":"2024-11-19T03:17:20.660325Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 2: Loading the Dataset","metadata":{}},{"cell_type":"code","source":"# Load the MNIST Dataset\ntrain_data_path = \"/kaggle/input/digit-recognizer/train.csv\"\ntest_data_path = \"/kaggle/input/digit-recognizer/test.csv\"\n\n# Load Training Data\ntrain_df = pd.read_csv(train_data_path)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:14:14.304113Z","iopub.execute_input":"2024-11-19T03:14:14.304476Z","iopub.status.idle":"2024-11-19T03:14:16.579234Z","shell.execute_reply.started":"2024-11-19T03:14:14.304446Z","shell.execute_reply":"2024-11-19T03:14:16.578215Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 3: Exploratory Data Analysis (EDA)","metadata":{}},{"cell_type":"code","source":"# Exploratory Data Analysis\n# Display some basic statistics\nprint(train_df.describe())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:14:33.643801Z","iopub.execute_input":"2024-11-19T03:14:33.644815Z","iopub.status.idle":"2024-11-19T03:14:35.674323Z","shell.execute_reply.started":"2024-11-19T03:14:33.644770Z","shell.execute_reply":"2024-11-19T03:14:35.673088Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Visualize a few samples from the dataset\ndef visualize_samples(dataframe, num_samples=6):\n \"\"\"Visualizes random samples from the dataset.\"\"\"\n samples = dataframe.sample(num_samples)\n fig, axes = plt.subplots(1, num_samples, figsize=(15, 4))\n for i, (idx, row) in enumerate(samples.iterrows()):\n label = row['label']\n image = row.drop('label').values.reshape(28, 28)\n axes[i].imshow(image, cmap='gray')\n axes[i].axis('off')\n axes[i].set_title(f\"Label: {label}\")\n plt.show()\n\nvisualize_samples(train_df)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:14:54.542198Z","iopub.execute_input":"2024-11-19T03:14:54.542588Z","iopub.status.idle":"2024-11-19T03:14:54.922228Z","shell.execute_reply.started":"2024-11-19T03:14:54.542554Z","shell.execute_reply":"2024-11-19T03:14:54.920965Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 4: Data Preprocessing","metadata":{}},{"cell_type":"code","source":"# Data Preprocessing with a Custom Dataset Class\nclass MNISTDataset(Dataset):\n def __init__(self, dataframe: pd.DataFrame):\n self.labels = dataframe['label'].values\n self.images = dataframe.drop(columns=['label']).values.astype(np.float32) / 255.0\n\n def __len__(self):\n return len(self.labels)\n\n def __getitem__(self, idx):\n image = self.images[idx].reshape(28, 28)\n label = self.labels[idx]\n return torch.tensor(image, dtype=torch.float32), torch.tensor(label, dtype=torch.long)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:16:51.898342Z","iopub.execute_input":"2024-11-19T03:16:51.898736Z","iopub.status.idle":"2024-11-19T03:16:51.906457Z","shell.execute_reply.started":"2024-11-19T03:16:51.898701Z","shell.execute_reply":"2024-11-19T03:16:51.905233Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 5: Splitting Data into Training and Validation Sets","metadata":{}},{"cell_type":"code","source":"# Train-Validation Split\ntrain_set, val_set = train_test_split(train_df, test_size=0.2, random_state=42)\ntrain_dataset = MNISTDataset(train_set)\nval_dataset = MNISTDataset(val_set)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:17:25.104662Z","iopub.execute_input":"2024-11-19T03:17:25.105291Z","iopub.status.idle":"2024-11-19T03:17:25.490378Z","shell.execute_reply.started":"2024-11-19T03:17:25.105224Z","shell.execute_reply":"2024-11-19T03:17:25.489276Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Create DataLoaders\ntrain_loader = DataLoader(train_dataset, batch_size=64, shuffle=True)\nval_loader = DataLoader(val_dataset, batch_size=64, shuffle=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:17:39.608942Z","iopub.execute_input":"2024-11-19T03:17:39.609879Z","iopub.status.idle":"2024-11-19T03:17:39.615159Z","shell.execute_reply.started":"2024-11-19T03:17:39.609839Z","shell.execute_reply":"2024-11-19T03:17:39.613960Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 6: Building the Neural Network Model","metadata":{}},{"cell_type":"code","source":"# Define the Neural Network Model\ninput_layer = 784\nhidden_layer1 = 128\nhidden_layer2 = 64\noutput_layer = 10\n\nmodel = nn.Sequential(\n nn.Linear(input_layer, hidden_layer1),\n nn.ReLU(),\n nn.Linear(hidden_layer1, hidden_layer2),\n nn.ReLU(),\n nn.Linear(hidden_layer2, output_layer)\n)\n\n# Loss Function and Optimizer\nloss_function = nn.CrossEntropyLoss()\noptimizer = optim.Adam(model.parameters(), lr=0.001)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:35:28.310441Z","iopub.execute_input":"2024-11-19T03:35:28.311719Z","iopub.status.idle":"2024-11-19T03:35:28.329877Z","shell.execute_reply.started":"2024-11-19T03:35:28.311677Z","shell.execute_reply":"2024-11-19T03:35:28.328694Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 7: Training the Model","metadata":{}},{"cell_type":"code","source":"# Training the Model\ndef train_model(model, train_loader, val_loader, epochs=10):\n \"\"\"Trains the neural network and evaluates it on validation data.\"\"\"\n for epoch in range(epochs):\n model.train()\n total_loss = 0\n for images, labels in train_loader:\n images = images.view(images.size(0), -1)\n optimizer.zero_grad()\n predictions = model(images)\n loss = loss_function(predictions, labels)\n loss.backward()\n optimizer.step()\n total_loss += loss.item()\n \n # Validation Step\n model.eval()\n val_loss = 0\n correct = 0\n with torch.no_grad():\n for images, labels in val_loader:\n images = images.view(images.size(0), -1)\n predictions = model(images)\n val_loss += loss_function(predictions, labels).item()\n correct += (predictions.argmax(1) == labels).sum().item()\n \n # Print Epoch Metrics\n print(f\"Epoch {epoch+1}/{epochs}\")\n print(f\"Train Loss: {total_loss/len(train_loader):.4f}\")\n print(f\"Validation Loss: {val_loss/len(val_loader):.4f}\")\n print(f\"Validation Accuracy: {100 * correct / len(val_dataset):.2f}%\")\n print(\"-\" * 30)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_model(model, train_loader, val_loader)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:18:29.960614Z","iopub.execute_input":"2024-11-19T03:18:29.961033Z","iopub.status.idle":"2024-11-19T03:18:54.800035Z","shell.execute_reply.started":"2024-11-19T03:18:29.960995Z","shell.execute_reply":"2024-11-19T03:18:54.798914Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 8: Preprocessing Test Data","metadata":{}},{"cell_type":"code","source":"# Evaluate on Test Data\ntest_df = pd.read_csv(test_data_path)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:23:21.160546Z","iopub.execute_input":"2024-11-19T03:23:21.160972Z","iopub.status.idle":"2024-11-19T03:23:22.960577Z","shell.execute_reply.started":"2024-11-19T03:23:21.160928Z","shell.execute_reply":"2024-11-19T03:23:22.959359Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prepare Test Dataset\nclass MNISTTestDataset(Dataset):\n def __init__(self, dataframe: pd.DataFrame):\n self.images = dataframe.values.astype(np.float32) / 255.0\n\n def __len__(self):\n return len(self.images)\n\n def __getitem__(self, idx):\n image = self.images[idx].reshape(28, 28)\n return torch.tensor(image, dtype=torch.float32)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:23:42.118964Z","iopub.execute_input":"2024-11-19T03:23:42.119384Z","iopub.status.idle":"2024-11-19T03:23:42.125757Z","shell.execute_reply.started":"2024-11-19T03:23:42.119347Z","shell.execute_reply":"2024-11-19T03:23:42.124643Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_dataset = MNISTTestDataset(test_df)\ntest_loader = DataLoader(test_dataset, batch_size=64, shuffle=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:23:44.603526Z","iopub.execute_input":"2024-11-19T03:23:44.603910Z","iopub.status.idle":"2024-11-19T03:23:44.669729Z","shell.execute_reply.started":"2024-11-19T03:23:44.603857Z","shell.execute_reply":"2024-11-19T03:23:44.668566Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 9: Making Predictions","metadata":{}},{"cell_type":"code","source":"# Make Predictions\ndef make_predictions(model, test_loader):\n \"\"\"Predicts labels for the test dataset.\"\"\"\n model.eval()\n predictions = []\n with torch.no_grad():\n for images in test_loader:\n images = images.view(images.size(0), -1)\n outputs = model(images)\n predicted_labels = outputs.argmax(1).tolist()\n predictions.extend(predicted_labels)\n return predictions","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:23:53.343889Z","iopub.execute_input":"2024-11-19T03:23:53.344832Z","iopub.status.idle":"2024-11-19T03:23:53.350517Z","shell.execute_reply.started":"2024-11-19T03:23:53.344791Z","shell.execute_reply":"2024-11-19T03:23:53.349342Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_predictions = make_predictions(model, test_loader)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:24:09.391604Z","iopub.execute_input":"2024-11-19T03:24:09.391991Z","iopub.status.idle":"2024-11-19T03:24:09.928371Z","shell.execute_reply.started":"2024-11-19T03:24:09.391954Z","shell.execute_reply":"2024-11-19T03:24:09.927217Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Task 10: Creating the Submission File","metadata":{}},{"cell_type":"code","source":"# Save Results to Submission File\nsubmission = pd.DataFrame({\n 'ImageId': range(1, len(test_predictions) + 1),\n 'Label': test_predictions\n})\nsubmission.to_csv(\"submission.csv\", index=False)\nprint(\"Submission file created: submission.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-19T03:24:12.090504Z","iopub.execute_input":"2024-11-19T03:24:12.090938Z","iopub.status.idle":"2024-11-19T03:24:12.125688Z","shell.execute_reply.started":"2024-11-19T03:24:12.090859Z","shell.execute_reply":"2024-11-19T03:24:12.124658Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]} -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | pandas 3 | matplotlib 4 | torch 5 | scikit-learn 6 | --------------------------------------------------------------------------------