MACHINE LEARNING
Tags: Keras, Machine Learning, TensorFlow, Deep Learning

MACHINE LEARNING

Introduction to Machine Learning

Machine learning is a subfield of Artificial Intelligence(AI) . Machine learning algorithms instead allow for computers to train on data inputs and use statistical analysis in order to output values that fall within a specific range.

PREDICTION OF HAND-WRITTEN DIGITS:-

In this tutorial,you will discover how to predict,recognize hand-written digits.

After completeing this tutorial,you will know:

How to use python for the prediction of hand written digits. How to install sufficient libraries needed to predict. How to predict the hand-written digits with minimality of error.

Let’s get started.

TUTORIAL OVERVIEW:-

The tutorial is divided into parts,they are:

Classification and Regression Software Requirements Steps for installing Notebook Importing libraries Training the Model Prediction of Accuracy

1.CLASSIFICATION AND REGRESSION:-

Discrete value prediction refers to Classification.It divides the datasets into various classes.There are two types of classification,They are,

I) Single Class Classification:-

Classification occurs between two classes referred as Single Class Classification.

Example:-

Prediction of the given image is a cat or dog.

II) Multiple Class Classification:-

Classification occurs between more than two classess referred to as Multiple Class Classification.

Example:-

Prediction of the given image is a cat or dog or cow or somewhat else.

Regression:-

Regression differs from Classification as it predicts the continuous values.

2. SOFTWARE REQUIREMENTS:-

Anaconda Navigator :-

ANACONDA is a software which is free and open source for programming langauges such as python.It is widely used software for python users for machine learning concepts.

You can able to install different packages using this software.

KERAS:-

Keras is a open source library for Nueral network. It also acts as a interface of tensorflow. It follows best procedure for reducing coagnitive load.

TENSORFLOW:-

Tensoflow is an end-to-end open source for machine learning for everyone.It has flexible system of tools and libraries with specific functions.

3. STEPS FOR INSTALLING NOTEBOOK:-

Step 1: Download and install ANACONDA NAVIGATOR.

Step 2: Open Anaconda prompt.

Follow the steps given below:-

Enter conda create — name python36 python=3.6.8

The aove step will install python of version 3.6.8.

Enter activate python36

Enter pip install virtualenv

Virtual Environment(virtualenv):virtualenv is a tool to create isolated Python environments.

Enter virtualenv

Enter cd keras

Enter Scripts/activate

Enter pip install keras

Enter pip install tensorflow

Enter pip install jupyter

Jupyter notebook: The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.

Enter jupyter notebook

The above step opens jupyter notebook in your default browser.

3. IMPORTING LIBRARIES:-

Step 1:-

Its done for python compatiblity.

Step 2:-

for Experiment reproduciblity

Numpy:It is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.

Step 3:-

Sequential model: It is used to build a nueral network, a network which has many layers.

Dense layer:Dense layer refers to more number of layers in which every node is connected to different other nodes.Dataset is the barrier which decides the dense layer.

Stochastic gradient descent(SGD):is an iterative method for optimizing an objective function with suitable smoothness properties.

Modified National Institute of Standards and Technology(MNIST):It is a large database of handwritten digits that is commonly used for training various image processing systems.

Step 4:-

num_classes: It differs from 0–9. They are the classes used for prediction.

batch_size:It is a subset of training dataset.

Epoch:It refers to the cycle of training full dataset.

5. TRAINING THE MODEL:-

Shuffling the data:-

Data is shuffled and split between the train and test datasets.

Normalizing the data:-

The Resolution of the image is 28x28. Hence it is converted into full size as 784.After that the data is converted into float32 . Then the data is normalized by dividing the values with 255.

Conversion of Data:-

Vector class is converted into binary class matrices.

One-hot Vector:It is a method to quantify categorical data.

Creating Layers:-

In this model we added three dense layers in which the value 512 represents number of nodes. Sigmoid is the activation algorithm we’ve used.

Softmax : It is used in multinomial logistic regression and is often used as the last activation function of a neural network to normalize the output of a network to a probability distribution over predicted output classes.

Compiling and Learning of the model:-

The above code refers to the compilation and learning process. Testing datasets of x and y were used.

verbose = 1, which includes both progress bar and one line per epoch.

Output for training samples

Here I have given the value of epoch=2, so it has performed the full datasets for 2 times.

6.EVALUATION OF ACCURACY:-

Lets evaluate the accuracy of our model by using test datasets of x and y.

If we want to see the accuracy of datasets,then type

score[0]

output for score[0]

Here is the finalized output for training the model with minimal error.

That’s all for this project. Hope you guys have a clear idea about hand wriiten digis prediction using keras and tensorflow. Post your thoughts in the comment section.

ARTICLES:-

Keras

Tensorflow

Numpy

Virtual_Environment

Jupyter_notebook