Six Jars of Machine Learning

Nitin Naidu
DataDrivenInvestor

--

With reference from session by Prof. Mitesh Khapra and Pratyush Kumar

In machine learning, you come across keywords like Classification, Regression, Gradient descent, Convolution neural networks. Some specialized keywords like Yolo for object detection, R-CNN for object detection and concepts like Eigen vectors among others.

In order to organize this jargon let us look at a uniquely designed concept by One Fourth Labs so that you know which part of Machine Learning you are dealing with. It will further give you the big picture to follow a flow towards developing the right machine learning model.

From jargons to jars:

Image credit: One Fourth Labs

Jar One: Data

We have data everywhere in the form of text, videos, images or tables. That again can be structured data or unstructured data.

To apply machine learning there is a need for a specific type of data. Let us take an example of cancer detection using images. Here you need data with input(x) and output(y) i.e images of the scan and labeled images that says whether it is a case of cancer.

With this data, you can train a model to classify a new image for the possibility of cancer. Data for an image is feeded to machine in the form of numbers according to pixels. This data is typically high dimensional.

Data can be curated in three ways-

  1. Free Public data sets such as Google AI, UCI
  2. Outsource though paid services like Amazon mechanical turk
  3. Simulate data through image processing tools like Photoshop

Jar Two: Tasks

Once the data has been identified the next step would be to define tasks that can be done with the data. Task can be as simple as prediction of the weather or finding the current temperature as a task to predict the ultimate task of predicting the temperature.

Among various posts in Facebook you might come across different images. Now if you want to tag the images. This can be a task for your machine learning model. All you need to do is have an input(x) as an image and an output(y) i.e a tagged image with coordinates and label of the image.

Getting the coordinates and the labels can be some of the task to achieve the main task of automated tagging. Task can be defining what your input and your output is in machine learning model.

Tasks can be supervised or unsupervised:

Supervised tasks-

Here there is requirement of both input and output. Classification is one of the common task based on the relationship between the input and the output. Regression is another one where one could be using it to find coordinates(width, height) of the text box in an image. Here output would be the coordinates of the particular box with text in an image.

Unsupervised tasks-

In unsupervised tasks one does not have the output with the labels. Work is done with only input for the machine learning model.

Clustering is one of the task towards creating clusters of the data among unlabeled data based on common factors such as shape, color. Here there is no output but rather clusters.

Generation is another task where there is generation of new input based on the input provided which may be dissimilar. Example of creating new tweets based on the past tweets by an individual.

Jar Three: Models

In machine learning there is a relationship between the input and the output. This relationship plays a key role towards achieving the objective of prediction.

So as we do not know the relationship, we can approximate a function which describes the relationship between the input(x) and the output(y).

The function could be as simple as y=mx+c

This function constitutes the machine learning model.

Finding the optimum parameters in the function which has the lowest error is of great importance. The function can be simple or complex based on the requirements for the data. Choosing the right function i.e the right model is important to achieve the objective.

Jar Four: Loss Function

While choosing the model(i.e the function and the parameters) for machine learning you might come across multiple models. Now to find the best function which has the lowest error we use the loss function.

The loss function plays a significant role in estimating how good or bad the model is based on the actual output. It plays a key role in finding the best parameters to achieving the optimum model.

Some of the loss functions include square error loss, cross entropy loss, KL divergence.

Jar Five: Learning Algorithm

Function — ax+bx+cx

In the above function one needs to select the optimum parameters(i.e a,b and c) to get the lowest error in machine learning model. In order to get these parameters one can use brute force i.e to try out all the parameters to find the right combination of parameters with minimum loss.The parameters further help to give appropriate weight to the features. However in practice this would be cumbersome with diversified data.

Here optimization solvers comes into play which helps to find the parameters with minimum loss. Some of the optimization solvers include Gradient Descent, Adagrad, RMSProp, Adam.

Jar Six: Evaluation

Among the different models implemented one need to find the best model. One of the ways to evaluate the model is by the prediction accuracy of the model.

Accuracy= Correct number of predictions/total number of predictions.

How is accuracy different from loss function which estimates the model with the minimum loss?

The answer is if you look at the loss function it is not clear to judge how good or bad a model is. So, accuracy gives a better idea about the best model among different models.

Precision and recall make up the accuracy.

Precision relates to the number of times the model gives the right output. While, recall relates to the number of times the model gives the wrong output. The evaluation is always done on test data instead of training data.

Some of the evaluation metrics include Top-k Accuracy, Precision, Recall, F1.

Image credit: One Fourth Labs

The six jars completes the pathway for machine learning to implement a robust model.

References:

Expert systems by One Fourth Labs

--

--