A simple explanation of Machine Learning and Neural Networks

A simple explanation of Machine Learning and Neural Networks and A New Perspective for ML Experts

This is an introduction to machine learning an neural networks in a simple and intuitive way. The concepts are explained in a way different from the traditional explanations for neural networks, with a new perspective.

Image by author (Moon above the Himalayas)

Deep learning, neural networks and machine learning have been the buzz words for the past few years. Surely, there is a lot that can be done using neural networks.

There has been immense research and innovation in the field of neural networks. Here are some amazing tasks that neural networks can do with extreme speed and good accuracy:

  • Image classification — For example, when given images of cats and dogs, the neural network can tell which image has a cat and which has a dog.
Cat-Dog Classification (Images from Pixabay: Cat by GidonPico, Dog by Chiemsee2016)
  • Object Detection — locating different objects in a given image.
Object Detection (Image from here)
  • Chatbots — Neural networks can chat with humans in conversations. Neural networks can do tasks for humans based on the human’s typed request or spoken request.
Chatbot (Image from pixy.org)
  • Language translation — Translating text from one language to another.
  • Image generation — Generating new images of a particular type. The people in the picture below do not exist! These faces have been generated by AI!!
These people do not exist! These faces have been generated by AI (Images from thispersondoesnotexist.com)
  • Predicting stock prices
  • Playing computer games
AI agents can learn how to play games like brick breaker (Image from Wikimedia Commons)

People use neural networks for numerous applications. Moreover, it is essential to note that generally, for each task a particular type of neural network that is used; that is, the neural network structure varies for different tasks.

This brings us to the question: What are neural networks?
Before we come to that, let us look at this question: What is machine learning?

What is machine learning?

Generally, when we want to predict house prices in a city like Bangalore, we have some data about different houses like

  • the carpet area (in sq. ft.)
  • walled area (in sq. ft.)
  • house type — independent house, flat in an apartment complex, villa
  • latitude and longitude (for the location of the house)
  • number of floors in the house
  • which floor the house is in (ground floor, 1st floor, etc.)
  • facilities available — swimming pool, gym, etc.
  • builder of the apartment/house

Typically, we would have a function that take the values of these features (characteristics) as input and estimate the price of the house. In other words, we already have a function that can be used to calculate the price of the houses based on these values.
Generally, we have some data and a function. We use this function to determine some quantity (house price) that we need.

However, in many cases, the data we get is new and we do not have any such function to estimate the price of the houses. We might need to take the help of experts to determine such a function. Even then, in many cases, this may not be possible to obtain easily.

Big Data Jobs

In such situations, machine learning turns out to be of great value!

The machine learning (ML) algorithm is used to find the function that is mentioned here. The machine learning algorithm will take in the values of the features (the different characteristics of each house) and also the output quantity (price of the corresponding houses). It will find a function which will calculate the prices of these houses. This function will be such that the overall error between the actual house price and, the prices calculated by the function based on the features of the corresponding houses is least.
Then, this function given out by the ML algorithm can be used to predict the prices of other houses as well!

Machine Learning vs Traditional Approaches (Image by author, created using diagrams.net)

The following are given as input to the machine learning algorithm to find the function:

  • the data/characteristics of many houses.
  • the prices of each of those houses.

The machine learning algorithm “learns” a function using this data.

When data of new houses is given, this learned function can predict the prices of the new houses.

Trending AI Articles:

1. Why Corporate AI projects fail?

2. How AI Will Power the Next Wave of Healthcare Innovation?

3. Machine Learning by Using Regression Model

4. Top Data Science Platforms in 2021 Other than Kaggle

Linear Regression

So, what functions can you think of? A very simple function is the straight line equation: y = f(x) = mx + c. Here, there is only one input value, x. Given this, we can find the output y by computing f(x).
Let us look at an example of this. There is a bicycle shop that rents bicycles with a base fare of ₹10 and an additional fare of ₹0.50 per minute. Let x be the number of minutes the bicycle is rented and y be the fare in rupees. Then, clearly, the function is y = f(x) = 0.5x + 10.
If we want to use machine learning to find this function, we have to get the fare values (y values) for many minutes (x values).

Using these values for x and y, the machine learning algorithm will return the function, that is, it will give m and c, so that we can use f(x) = mx + c.

The next few sections may have some Math which is complicated for some of you. Don’t worry about that now. Just assume that it such functions exists and all this works. It all boils down to this: a function F which takes n values as input and gives m values as output.

Extending the function to multiple inputs and outputs

We can extend this to taking in multiple inputs as follows:

The multiple inputs would correspond to each characteristic of the house that we mentioned earlier.

Linear Regression with multiple inputs (Image by author, created using diagrams.net)

Similarly, we can also have multiple outputs being given by the function f. For example, the price of a house as well as the rent of a house could be predicted.

Here, F takes 5 values as input and gives 2 values as output.

Linear Regression with 5 inputs and 2 outputs (Image by author, created using diagrams.net)

Once again, as I said, don’t worry too much about the Math above and the Math that is yet to come.

We have seen what linear regression is. How would it be if we have multiple steps in linear regression?

We saw that linear regression is basically a multiple-input function (and possibly multiple-output). Let us assume that there are ‘n’ input variables and ‘m’ output variables (‘m’ is 1 quite often). The ‘n’ variables are taken as input and transformed into the output ‘m’ variables through a function ‘f’ or a matrix multiplication (with a matrix, ‘W’). Here, we consider the function f and the matrix multiplication with ‘W’ as equivalent.

Instead of the above technique, let us say that the ‘n’ input variables are transformed into ‘n1’ intermediate variables by a function ‘f1’ (or a matrix ‘W1’). Then, let us say that these ‘n1’ intermediate variables are transformed into the output ‘m’ variables by a function ‘ f2’ (or a matrix ‘W2’). The final user will see only the input variables and the output variables and not the ‘n1’ intermediate variables because these are not of much importance to the final user. Thus, this set of ‘n1’ variables is called a hidden layer.

Series of linear regressions (Image by author, created using diagrams.net)

Similarly, instead of having one hidden layer we can have multiple hidden layers, say three hidden layers. Then, the following will be the process:

Series of linear regressions with 3 hidden layers — (Image by author, created using diagrams.net)

Input Layer: ‘n’ input variables

‘W1’ (or ‘f1’) transforms ‘n’ to ‘n1’

Hidden layer 1: ‘n1’ variables in this layer

‘W2’ (or ‘f2’) transforms ‘n1’ to ‘n2’

Hidden layer 2: ‘n2’ variables in this layer

‘W3’ (or ‘f3’) transforms ‘n2’ to ‘n3’

Hidden layer 3: ‘n3’ variables in this layer

‘W4’ (or ‘f4’) transforms ‘n3’ to ‘m’

Output layer: ‘m’ variables in this layer

Neural Network

In the above examples, we use matrix multiplication which is a linear operation. When we have multiple stages of linear operations, we can achieve a greater number of functions more easily.

However, not many functions can be obtained by performing linear operations. Thus, we introduce an element of non-linearity at each stage. This way, we will be able to achieve a greater number and variety of functions. Ultimately, this is what a basic neural network is.

Neural Network — (Image by author, created using diagrams.net)

Training the Neural Network or the Linear Regression Model

Let us say that we have created a neural network model or a linear regression model. How can we ensure that its predictions are accurate?

  1. The neural takes in the data (features/characteristics of each house) and the corresponding output values (house price).
  2. It predicts its own output value (predicts a house price for a house based on the features of the house).
  3. It compares the predicted value with the actual value.
  4. It minimizes the overall error between predicted value and the actual value for many houses (say 10,000 houses). [This step is actually a long process and requires a separate detailed explanation. For, further study, check out “Gradient Descent”.]
  5. The model is now ready to be used to predict the value (house price) of new data (new houses).

When we change the structure of the neural network that we saw above, we can make it suited for different kinds of tasks.This is what we call deep learning (because the network has some depth due to the series of layers). Deep learning and machine learning are finding their way into almost all fields in the industry. So, it is better if you go ahead and learn some basics and use it to your advantage.

Some other concepts that you may want to look up next to understand machine learning and deep learning are:

Very basic concepts — Accuracy, Mean Square Error, Classification, Regression, Confusion Matrix
Intermediate concepts — Decision Trees, Gradient Descent, Logistic Regression
More advanced concepts — Convolutional Neural Networks (CNNs), Support Vector Machines (SVM)

Note: I have written this article solely based on my knowledge and my understanding of machine learning. If you feel that there is anything lacking anywhere in this article, please feel free to get back to me so that I can improve it for others.
All equation images have been created by me using this website: https://latex2image.joeraut.com/
All other images used have either been created by me or are have a Creative Commons License.

Don’t forget to give us your ? !


A simple explanation of Machine Learning and Neural Networks was originally published in Becoming Human: Artificial Intelligence Magazine on Medium, where people are continuing the conversation by highlighting and responding to this story.

Via https://becominghuman.ai/machine-learning-and-neural-networks-af268f1278fe?source=rss—-5e5bef33608a—4

source https://365datascience.weebly.com/the-best-data-science-blog-2020/a-simple-explanation-of-machine-learning-and-neural-networks

Published by 365Data Science

365 Data Science is an online educational career website that offers the incredible opportunity to find your way into the data science world no matter your previous knowledge and experience. We have prepared numerous courses that suit the needs of aspiring BI analysts, Data analysts and Data scientists. We at 365 Data Science are committed educators who believe that curiosity should not be hindered by inability to access good learning resources. This is why we focus all our efforts on creating high-quality educational content which anyone can access online.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Design a site like this with WordPress.com
Get started