<jupyter_start><jupyter_text>![alt text](https://4.bp.blogspot.com/-gbL5nZDkpFQ/XScFYwoTEII/AAAAAAAAAGY/CcVb_HDLwvs2Brv5T4vSsUcz7O4r2Q79ACK4BGAYYCw/s1600/kk3-header00-beta.png)[<NAME>](http://www.linkedin.com/in/prithwis) https://blog.hyperiondev.com/index.php/2019/02/18/machine-learning/ Data<jupyter_code>#get the data
!wget http://ufldl.stanford.edu/housenumbers/train_32x32.mat
#Feature Processing
import sklearn
import scipy.io
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# load our dataset
train_data = scipy.io.loadmat('train_32x32.mat')
# extract the images and labels from the dictionary object
X = train_data['X']
y = train_data['y']
from sklearn.utils import shuffle
X = X.reshape(X.shape[0]*X.shape[1]*X.shape[2],X.shape[3]).T
y = y.reshape(y.shape[0],)
X, y = shuffle(X, y, random_state=42)
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<jupyter_output><empty_output><jupyter_text>Retrieve<jupyter_code>#instead we download from https://drive.google.com/file/d/16l-3moLo4S-f87C6Nw9JxPPuCuXvJrso/view?usp=sharing
!gdown https://drive.google.com/uc?id=16l-3moLo4S-f87C6Nw9JxPPuCuXvJrso
import joblib
clf_03 = joblib.load('imClass-model-100221.pkl')<jupyter_output><empty_output><jupyter_text>ML Test<jupyter_code>from sklearn.metrics import accuracy_score
preds = clf_03.predict(X_test)
print("Accuracy:", accuracy_score(y_test,preds))<jupyter_output>Accuracy: 0.7080262080262081<jupyter_text>Test Individual Files https://github.com/elliebirbeck/model-deployment-flask/tree/master/test-imgs<jupyter_code>import numpy as np
#from scipy import misc
import imageio
!wget https://github.com/elliebirbeck/model-deployment-flask/raw/master/test-imgs/test-5.png
!wget https://github.com/elliebirbeck/model-deployment-flask/raw/master/test-imgs/test-7.png

img0 = imageio.imread("test-7.png")
img1 = img0[:,:,:3]
img2 = img1.reshape(1, -1)
img2
#plt.imshow(X[:,:,:,img_index])
plt.imshow(img0)
prediction = loadedModel.predict(img2)
label = str(np.squeeze(prediction))
label
print(str(np.squeeze(loadedModel.predict(img2))))
#now to make it completely unreadable
print(str(np.squeeze(loadedModel.predict(img0[:,:,:3].reshape(1, -1)))))
print(str(np.squeeze(loadedModel.predict(imageio.imread("test-7.png")[:,:,:3].reshape(1, -1)))))
print(str(np.squeeze(loadedModel.predict(imageio.imread("test-5.png")[:,:,:3].reshape(1, -1)))))<jupyter_output>5
{'fraction_non_alphanumeric': 0.15891629599676507, 'fraction_numerical': 0.046906591184795794, 'mean_word_length': 7.386440677966101, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 7, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '275730', 'license': 'MIT', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1039, 'n_words': 130, 'path': 'Image_Classification_Load,_Test,_Predict.ipynb', 'repo_name': 'ShahrukhGouhar/WebApp-Using-Flask', 'size': '2484'}