Skip to content
Usman Sattar edited this page Dec 13, 2019 · 2 revisions

Research

Purpose:

When Completed, the application should predict a number from 0-9 which the user draws with his or her mouse. It should take in the number which any user draws and print it back stating what that number was.

Definition of Machine Learning

Machine learning is a method of data analysis that automates analytical model building. It is a branch of artificial intelligence based on the idea that systems can learn from data, identify patterns and make decisions with minimal human intervention. Machine learning involves you a developer to train a model. For example, training a model to recognise digits.

Image description Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow. Keras supports both convolutional networks and recurrent networks, as well as combinations of the two. It is designed to enable fast experimentation with deep neural networks. Before installing Keras, I install one of its backend engines - In this project, I have used the TensorFlow backend, which is also recommened professionally.

Neurons in keras

import keras as kr
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['figure.figsize'] = (10, 10)

Linear

# Create a new neural network.
m = kr.models.Sequential()

# Add a single neuron in a single layer, initialised with weight 1 and bias 0.
m.add(kr.layers.Dense(1, input_dim=1, activation="linear", kernel_initializer='ones', bias_initializer='zeros'))

# Compile the model.
m.compile(loss="mean_squared_error", optimizer="sgd")


# Create some input values.
x = np.arange(0.0, 10.0, 1)

# Run each x value through the neural network.
y = m.predict(x)

x

OUTPUT: array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])

y

OUTPUT: array([[0.], [1.], [2.], [3.], [4.], [5.], [6.], [7.], [8.], [9.]], dtype=float32)

# Plot the values.
plt.plot(x, y, 'k.')

References to Keras

Image description TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML powered applications. https://www.tensorflow.org/

Uses of TensorFlow:

  1. Voice/Sound Recognition
  2. Text Based Applications
  3. Image Recognition
  4. Time Series
  5. Video Detection

Image Recognition

For our project we have to convert hand-written digits to images. Using TensorFlow we can then predict what number the user had drawn.

Image description

References to Keras

Image description

Flask is a lightweight WSGI web application framework. Flask provides you with tools and libraries that allow you to build a web application within python. I am using Flask to deploy my application. Flask is used for an user friendly front-end purpose to draw and predict user inputs.

Example of Flask

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, World!"
$ env FLASK_APP=hello.py flask run
 * Serving Flask app "hello"
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

References to flask

MNIST

The MNIST database is a large database of handwritten digits that is commonly used for training various image processing systems. The database is also widely used for training and testing in the field of machine learning. MNIST stands for: Modified National Institute of Standards and Technology database The black and white images from NIST were normalized to fit into a 28x28 pixel bounding box and anti-aliased, which introduced grayscale levels.

History

The MNIST dataset was constructed from two datasets of the US National Institute of Standards and Technology (NIST). The training set consists of handwritten digits from 250 different people, 50 percent high school students, and 50 percent employees from the Census Bureau. Note that the test set contains handwritten digits from different people following the same split.

References to MNIST