70,000 MNIST Hand Writing Recognition - Logistic Regression
from sklearn.datasets import fetch_openml
mnist = fetch_openml('mnist_784')
x,y = mnist['data'],mnist['target']
x,y = mnist['data'], mnist['target']
import matplotlib.pyplot as plt
some_digit = x_test[2813]
some_digit_image = some_digit.reshape(28,28)
plt.imshow(some_digit_image)
x_train, x_test = x[:60000], x[60000:]
y_train, y_test = y[:60000], y[60000:]
import numpy as np
shuffle_index = np.random.permutation(60000)
x_train, y_train = x_train[shuffle_index], y_train[shuffle_index]
from sklearn.linear_model import LogisticRegression
clf = LogisticRegression()
clf.fit(x_train, y_train)
some1 = x_test[2813]
some1.reshape(28,28)
clf.predict([some1])
Colab Notebook Link:
Comments