Professional Documents
Culture Documents
Roll Number: K20SW002, K20SW016, K20SW017 Subject: Data Science & Analytics(Pr)
Task:
Step 1: Load and explore the MNIST dataset
from sklearn.datasets import fetch_openml
import matplotlib.pyplot as plt
import pandas as pd
plt.show()
Output:
Step 4: Build a logistic regression model
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
Output:
import numpy as np
# Visualize a few test images with their predicted and actual labels
fig, axes = plt.subplots(1, 4, figsize=(10, 3))
for i in range(4):
axes[i].imshow(X_test[i].reshape(28, 28), cmap='gray')
axes[i].set_title(f"Actual: {y_test[i]}, Predicted: {y_pred[i]}")
axes[i].axis('off')
plt.show()
Output:
Output:
THE END