Showing posts with label training. Show all posts
Showing posts with label training. Show all posts

MNIST Dataset Description

MNIST:

MNIST (Modified National Institute of Standards and Technology):

·       MNIST dataset,

·       which is a set of 70,000 small images of digits handwritten by

ü  high school students

ü  employees of the US Census Bureau.

Each image is labeled with the digit it represents.



Figure 1. Digits from the MNIST dataset

 

·       This set has been studied so much that it is often called the “hello world” of Machine Learning:

ü  whenever people come up with a new classification algorithm,

ü  they are curious to see how it will perform on MNIST, and

ü   anyone who learns Machine Learning tackles this dataset sooner or later.

 

ü  Scikit-Learn provides many helper functions to download popular datasets.

ü  MNIST is one of them.

        The following code fetches the MNIST dataset:

from sklearn.datasets import fetch_openml

MNIST = fetch_openml('MNIST_784', version=1)

MNIST.keys()

        dict_keys(['data', 'target', 'feature_names', 'DESCR', 'details', 'categories', 'url']) including the following:

ü  A DESCR key describing the dataset

ü  A data key containing an array with one row per instance and one column per feature

ü  A target key containing an array with the labels

 

        Let’s look at these arrays:

            X, y = MNIST["data"], MNIST["target"]

X.shape

            (70000, 784)

y.shape

            (70000,)

         There are

ü  70,000 images, and

ü  each image has 784 features.

·       This is because each image is 28 × 28 pixels, and

·       each feature simply represents one pixel’s intensity,

·       from 0 (white) to 255 (black).



 

·       Let’s take a peek at one digit from the dataset.

·       All you need to do is grab an instance’s feature vector, reshape it to a 28 × 28 array, and display it using Matplotlib’s imshow() function:

import matplotlib as mpl

import matplotlib.pyplot as plt

some_digit = X[0]

some_digit_image = some_digit.reshape(28, 28)

plt.imshow(some_digit_image, cmap="binary")

plt.axis("off")

plt.show()

·       This looks like a 5, and indeed that’s what the label tells us.

 

y[0]

'5'

·       Note that the label is a string.

·       Most ML algorithms expect numbers, so let’s cast y to integer:

y = y.astype(np.uint8)

·       To give you a feel for the complexity of the classification task,

·       Figure 1 shows a few more images from the MNIST dataset.

·       You should always

ü  create a test set and

ü  set it aside before inspecting the data closely.

·       The MNIST dataset is actually already split into

ü  a training set (the first 60,000 images)

ü  a test set (the last 10,000 images):

X_train, X_test, y_train, y_test = X[:60000], X[60000:],

                                                                                    y[:60000], y[60000:]

 

·       The training set is already shuffled for us,

ü  which is good because this guarantees that

·       all cross-validation folds will be similar.


·       Moreover, some learning algorithms are

ü  sensitive to the order of the training instances, and

ü  they perform poorly if they get many similar instances in a row.

·       Shuffling the dataset ensures that this won’t happen.

 

 Youtube Link: 


https://youtu.be/GaVUPdyOSyY


 

What is Machine Learning

 What is Machine Learning

        Machine Learning

        enables a Machine to Automatically learn from Data,

        improve performance from an Experience and

        predict things without explicitly programmed.”






        In Simple Words, when we fed the Training Data to Machine Learning Algorithm,

ü  this algorithm will produce a mathematical model and
ü  with the help of the mathematical model,
ü  the machine will make a prediction and

ü  take a decision without being explicitly programmed.


·      
Also, during training data,

o   the more machine will work with it

o   the more it will get experience and

o   the more efficient result is produced.

Example:  

In Driverless Car, the training data is fed to an Algorithm like  

ü  how to Drive a Car on Highway, Busy and Narrow Street with factors like

·       speed limit,

·       parking,

·       stop at signals etc.

After that, a Logical and Mathematical model is created on the basis of that and after that, the car will work according to the logical model.

Also, the more data, the data is fed the more efficient output is produced.


Definition: A computer program is said to

ü  learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.

 

To have a well-defined learning problem, three features needs to be identified:

  1. The class of tasks
  2. The measure of performance to be improved
  3. The source of experience

Simple learning process

        For any learning system, we must be knowing the three elements — 

ü  T (Task)

ü  P (Performance Measure),

ü  E (Training Experience).

        At a high level,

the process of learning system looks like below fig.




The learning process starts with

ü  task T,

ü  performance measure P and

ü  training experience E and

ü  objective are to find an unknown target function.

 

The target function is

ü  an exact knowledge to be learned from the training experience and

ü  its unknown.

 

For example, in a case of credit approval,

        the learning system will have

ü  customer application records as experience and

ü  task would be to classify whether the given customer application is eligible for a loan.

So in this case,

ü     the training examples can be represented as   


ü  where

        x represents customer application details and

        y represents the status of credit approval.


        With these details, what is that exact knowledge to be learned from the training experience?

        So the target function to be learned in the credit approval learning system is a mapping function f:x →y.

        This function represents the exact knowledge defining the relationship between input variable x and output variable y.

        The learning algorithms try to guess a “hypothesis’’ function h(X) that approximates the unknown f(.).

         A hypothesis is a function that best describes the target and Hypothesis set or space H(.) is the collection of all the possible legal hypothesis.

        This is the set from which the machine learning algorithm would determine the best possible (only one) which would best describe the target function or the outputs. 

        The goal of the learning process is to find the final hypothesis that best approximates the unknown target function.

Examples

i. Checkers game: A computer program that learns to play checkers might improve its performance as measured by its ability to win at the class of tasks involving playing checkers games, through experience obtained by playing games against itself.

            A checkers learning problem:

  • Task T: playing checkers
  • Performance measure P: percent of games won against opponents
  • Training experience E: playing practice games against itself

ii.  A handwriting recognition learning problem:

  • Task T: recognizing and classifying handwritten words within images
  • Performance measure P: percent of words correctly classified
  • Training   experience E: a database of handwritten      words with                  given classifications




iii.  A robot driving learning problem:

·       Task T: driving on public four-lane highways using vision sensors

·       Performance measure P: average distance travelled before an error (as judged by human overseer)

·       Training experience E: a sequence of images and steering commands recorded while observing a human driver



YouTube Link: https://www.youtube.com/watch?v=D9PrmxQPKS0&t=80s






Source: Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow by Aurélien Géron



About Machine Learning

Welcome! Your Hub for AI, Machine Learning, and Emerging Technologies In today’s rapidly evolving tech landscape, staying updated with the ...