Windows Step-by-Step ML Report Guide

Windows Step-by-Step Guide (with Report Format)

THE APP CAN BE FOUND - https://dcomltp.streamlit.app/
THE REPO WITH INSTRUCTIONS TO RUN THE APP ON A LOCAL DEVICE CAN BE FOUND - GitHub Repo

---OR YOU CAN USE THE INSTRUCTIONS MARKED AS STEPS TO GET REPORTS AS DONE IN THE ORIGINAL METHOD USING JUPYTER NOTEBOOKS

1. Install prerequisites

  1. Install Python 3.10 (from python.org) and check:
    python --version
  2. Install VS Code and add the Python + Jupyter extensions.
  3. Install Git (optional, but useful).

2. Create project folder and virtual environment

Open PowerShell:

mkdir ml_report_project
cd ml_report_project
python -m venv .venv
.venv\Scripts\activate

3. Install required packages

Create a file requirements.txt:

numpy
pandas
matplotlib
seaborn
scikit-learn
tensorflow==2.12.0
jupyterlab
notebook

Install:

pip install -r requirements.txt

4. Start Jupyter Notebook in VS Code

5. Notebook cells (copy–paste in order)

Cell 0 — Title

# Assignment: Can You Teach a Machine to Read?

Datasets: Fashion-MNIST (CSV) and CIFAR-10 (CSV subset).  
Outputs: dataset exploration, MLP & CNN training, evaluation, confusion matrices, and comparisons.

Cell 1 — Imports

import numpy as np, pandas as pd, matplotlib.pyplot as plt, seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
from tensorflow.keras import layers, models

Cell 2 — Load Fashion-MNIST CSV

df_fashion = pd.read_csv("fashion_mnist.csv")
y_fashion = df_fashion['label'].values
Xf = df_fashion.drop('label', axis=1).values.reshape(-1,28,28)/255.0

class_names_fashion = ['T-shirt/top','Trouser','Pullover','Dress','Coat',
                       'Sandal','Shirt','Sneaker','Bag','Ankle boot']
print("Fashion-MNIST:", Xf.shape, y_fashion.shape)

Cell 3 — Visualize

plt.figure(figsize=(8,8))
for i in range(25):
    plt.subplot(5,5,i+1)
    plt.imshow(Xf[i], cmap='gray')
    plt.title(class_names_fashion[y_fashion[i]], fontsize=8)
    plt.axis("off")
plt.show()

Cell 4 — Build Models

def build_mlp(input_shape=(28,28), num_classes=10):
    m = models.Sequential([
        layers.Flatten(input_shape=input_shape),
        layers.Dense(128, activation='relu'),
        layers.Dropout(0.2),
        layers.Dense(num_classes, activation='softmax')
    ])
    m.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
    return m

def build_cnn(input_shape=(28,28,1), num_classes=10):
    m = models.Sequential([
        layers.Conv2D(32,(3,3),activation='relu',input_shape=input_shape),
        layers.MaxPooling2D(2,2),
        layers.Conv2D(64,(3,3),activation='relu'),
        layers.MaxPooling2D(2,2),
        layers.Flatten(),
        layers.Dense(128,activation='relu'),
        layers.Dropout(0.3),
        layers.Dense(num_classes,activation='softmax')
    ])
    m.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
    return m

Cell 5 — Train Fashion CNN

X_train,X_test,y_train,y_test = train_test_split(Xf,y_fashion,test_size=0.2,random_state=42)

cnn = build_cnn((28,28,1))
history_cnn = cnn.fit(X_train.reshape(-1,28,28,1), y_train,
                      validation_split=0.1, epochs=10, batch_size=64)

Cell 6 — Evaluate Fashion CNN

test_loss,test_acc = cnn.evaluate(X_test.reshape(-1,28,28,1), y_test)
print("Fashion CNN Test Accuracy:", test_acc)

plt.plot(history_cnn.history['accuracy'], label="Train Acc")
plt.plot(history_cnn.history['val_accuracy'], label="Val Acc")
plt.xlabel("Epoch"); plt.ylabel("Accuracy"); plt.legend(); plt.show()

y_pred = np.argmax(cnn.predict(X_test.reshape(-1,28,28,1)),axis=1)
cm = confusion_matrix(y_test,y_pred)
ConfusionMatrixDisplay(cm, display_labels=class_names_fashion).plot(xticks_rotation=45)

Cell 7 — Load CIFAR-10 Subset CSV

df_cifar = pd.read_csv("cifar10_small.csv")  # created with keras.datasets earlier
yc = df_cifar['label'].values
Xc = df_cifar.drop('label', axis=1).values.reshape(-1,32,32,3)/255.0
print("CIFAR-10:", Xc.shape, yc.shape)

Cell 8 — Train CIFAR CNN

Xc_train,Xc_test,yc_train,yc_test = train_test_split(Xc,yc,test_size=0.2,random_state=42)

cnn_cifar = build_cnn((32,32,3))
history_cifar = cnn_cifar.fit(Xc_train,yc_train, validation_split=0.1, epochs=10, batch_size=64)

loss_c,acc_c = cnn_cifar.evaluate(Xc_test,yc_test)
print("CIFAR-10 CNN Test Accuracy:", acc_c)

Cell 9 — Compare Fashion vs CIFAR

plt.plot(history_cnn.history['val_accuracy'], label="Fashion-MNIST")
plt.plot(history_cifar.history['val_accuracy'], label="CIFAR-10")
plt.xlabel("Epoch"); plt.ylabel("Validation Accuracy"); plt.legend(); plt.show()

6. Export to Report (Notebook → PDF/HTML)

On Windows in VS Code:

Or from PowerShell:

jupyter nbconvert --to html assignment.ipynb

📑 Editable Report Format (Auto-generated from Notebook)

✅ That’s it: With this guide, you can: