Introduction to Artificial Intelligence

Artificial Intelligence have become one of the most important and interesting topics over the past few years , it gave computers the ability to “think” and to be “intelligent” . Unlike “old” programs and algorithms in which you should define and deal with every condition , AI algorithms can predict the action based on a training . What is AI ? What is Machine Learning ? What is Artificial Neural Network ? How could we train it ?

Before the AI era

In old programs , the output does not change over time and does not learn from training . Every thing should be written in the source code , every input should be included in the program . Whenever you have a new or a change in your input , you should update your program . This can be a huge problem when dealing with data and input that change frequently , specially if you could not predict them .

Let’s take the following example :

You have program that take the model and the speed of a car as an input and gives you fuel consumption as output . How could you develop this program ?

Let’s think for a minute …

We have to manage all the models , and for every model all the possible car’s speed ! This is very hard ! and unfeasible !

Artificial Intelligence will solve this problem ! Congrats !

What is Artificial Intelligence ?

An AI , is a program that given an input , it’ll predict the output , even if it doesn’t know any think about that specific input (It doesn’t know fuel consumption of this specific model at this specific speed) ! How it predict that ?

What is Machine Learning?

To build an Artificial Intelligence program , you have to train it using examples (many real car’s consumption) . This way , your program will learn from this data and try to understand how car’s consumption increase according to speed and car’s model . The more data you give to your program , the more accurate it’ll be : All this without any change in source code .So , how machine learning works ? How your program learn ?

Well ! It will do a Linear Regression to draw a line that cross the majority of points, like the following image :

 

Linear Regression
Linear Regression

For example :

  • X : represents car’s speed .
  • Y: represents fuel consumption.

What is Artificial Neural Network ?

Machine Learning is how to train our program to learn about our data .As we’ve seen earlier , Linear Regression is one of the methods to do that .

Artificial Neural Network is a new technique in machine learning that is inspired by human neurons. It is composed by “neurons” which has inputs and according to the input it calculates a value as an output .

Back the our example , to solve our issue we have to build an ANN that have 2 inputs :car model and car speed and 1 output : the fuel consumption . How to train it in order to predict the fuel consumption ?

How to train an Artificial Neural Network ?

There are two best tools to build and then train an ANN (Artificial Neural Network):

Scikit

TensorFlow : developed by Google for building advanced algorithms.

In our example , we should then build an ANN with 2 inputs , 1 output and we give it as many data as we can to train it . As we mentioned above , the neuron output depends on its input , so in each learning round (epochs) the output for the same input change to become more accurate .What !

I’ll explain . Let’s say in round 1 (the first epoch) , the output of the neuron is calculated according to the following equation :

0.4*input1+0.2*input2 = output

This will give an accuracy ,for example, of 70% of our ANN  .

In the second epoch , the ANN will try to improve the accuracy by changing the first equation , so it’ll be for example :

0.46*input1+0.199*input2 = output

Giving this equation , the ANN will have an accuracy of 75% , so our ANN improved itself by learning from each epoch and each input.

In each epoch , our ANN calculates the accuracy of the model and tries to improve it in the next epoch . (You could set the number of epoch as you want).

To conclude

AI is the evolution of computer algorithms that will surely help Humans make better decisions and to predict many things . Many big companies already started using AI in their products , like Google assistant , Alexa (Amazon) , Google search engine …

I am pretty sure that we will see AI in more products and programs in the near future , hoping that it will beneficial for the end user .