Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/farzeennimran/fashion-mnist-dataset-classification-using-neural-network

Implementation of a Multi-layer Perceptron classifier with hyperparameter tuning and k-fold cross-validation employing GridSearchCV for classifying images on the Fashion MNIST dataset 👗👚👖
https://github.com/farzeennimran/fashion-mnist-dataset-classification-using-neural-network

artificial-intelligence data-analysis data-mining data-science dataset deep-learning fashion-mnist-dataset gridsearchcv hyperparameter-tuning kfold-cross-validation machine-learning multilayer-perceptron-network neural-network numpy pandas python sklearn

Last synced: about 1 month ago
JSON representation

Implementation of a Multi-layer Perceptron classifier with hyperparameter tuning and k-fold cross-validation employing GridSearchCV for classifying images on the Fashion MNIST dataset 👗👚👖

Awesome Lists containing this project

README

        

# Fashion MNIST Dataset Classification using Neural Network

## Introduction
This repository contains the implementation of a Multi-layer Perceptron classifier with hyperparameter tuning and k-fold cross-validation employing GridSearchCV for classifying images on the Fashion MNIST dataset.

The Fashion MNIST dataset is a widely used dataset for benchmarking machine learning algorithms, consisting of 70,000 grayscale images of 28x28 pixels each, categorized into 10 different classes representing various fashion items.

## Neural Networks
Neural networks are a subset of machine learning models inspired by the human brain's structure and function. They consist of layers of interconnected nodes (neurons) where each connection has an associated weight. These networks are capable of learning complex patterns and representations from data through a process called training, where the network adjusts its weights based on the error of its predictions.

Neural networks are commonly used in image classification, natural language processing, and other domains requiring the extraction of high-level features from raw data.

## Code Explanation

### Data Loading and Preparation
The first part of the code involves importing necessary libraries and loading the Fashion MNIST dataset:

```python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from tensorflow.keras.datasets import fashion_mnist

(X_train, Y_train), (X_test, Y_test) = fashion_mnist.load_data()
```

After loading, the dataset shapes are printed to understand the structure:

```python
print('Fashion MNIST Dataset Shape:')
print('X_train: ' + str(X_train.shape))
print('Y_train: ' + str(Y_train.shape))
print('X_test: ' + str(X_test.shape))
print('Y_test: ' + str(Y_test.shape))
```

### Data Visualization
To get an initial understanding of the dataset, a segment of images along with their labels are visualized:

```python
num_row = 6
num_col = 6
num = num_row * num_col
images = X_train[:num]
labels = Y_train[:num]

fig, axes = plt.subplots(num_row, num_col, figsize=(1.5*num_col, 2*num_row))
for i in range(num_row * num_col):
ax = axes[i // num_col, i % num_col]
ax.imshow(images[i], cmap='gray')
ax.set_title('Label: {}'.format(labels[i]))
plt.tight_layout()
plt.show()
```

### Data Normalization
The pixel values of the images are normalized to the range [0, 1] to improve the training process:

```python
X_train = X_train / 255.0
X_test = X_test / 255.0
```

### Neural Network Model
The core part of the implementation involves creating and training a neural network model. The architecture and training process details are omitted in this snippet but typically involve defining a sequential model, adding layers, compiling the model with an optimizer and loss function, and fitting the model on the training data.

### Model Evaluation
After training, the model is evaluated on the test data to measure its performance. This typically includes calculating accuracy and possibly visualizing some predictions.

## Conclusion
This project demonstrates how to load, visualize, and preprocess the Fashion MNIST dataset, and highlights the basic workflow for training a neural network for image classification tasks. Neural networks are powerful tools for such tasks, capable of achieving high accuracy with appropriate architectures and training processes.