How to create our Artificial Intelligence

28/03/22

We have often talked about Artificial Intelligence, but we have not done it yet from the point of view of those who want to approach the subject and try to build their own AI.

Today, however, we are approaching the younger ones trying to explain what it takes to create an AI, what tools are useful and how to proceed step by step towards your goal. In this article we take some knowledge for granted, in particular we do not explain what an AI is. If, as you continue reading, you realize that you need to refresh some concepts, I suggest you read the article "The new digital revolution, Deep Learning"by Andrea Piras, where you can find the definitions and explanations of AI, Machine Learning e Deep Learning.

Identify the problem

It may seem strange but if you want to build an AI you have to identify the problem you want to solve well. 

We immediately specify that a problem that appears simple from a human point of view could be difficult or complex for an AI and vice versa. AI is usually very effective at carrying out repetitive tasks that could possibly be alienating for a person. For example, suppose you need to collect photos and drawings of some types of fruit (pears and apples). We could hire a person capable of drawing and send him around in search of subjects to draw. Leonardo da Vinci probably would have toured the city markets and the countryside, making the drawings himself. Or we could hire a photographer, asking him to take some shots that we will then use for our needs. We could also hire someone to search the internet for images and then save them in two different folders depending on the subject. We could, in the latter case, use an AI created for the purpose. As you can see, the task is relatively simple, but the methodology and technology used are different. 

Similarly, it is possible that the same problem can be solved using different types of Artificial Intelligence. It is therefore necessary to try to define the problem well and choose the best methodology to achieve the goal. Finally, depending on the problem, it could also happen that using an AI turns out to be useless and expensive, but we will not deal with the latter case.

About the data ...

Once the problem has been defined, it might be tempting to move on to writing the program (code) that will help us solve it (we always talk about collecting images, photos or drawings of pears and apples and classifying them). But this is not the case, first of all we need to think about the data. We need to try to understand what kind of data we are dealing with (structured or unstructured) and how we should catalog them: do we have to divide the apples and pears or do we need to do something more complex, perhaps distinguishing between fruits of different colors? Data analysis is very important and will be useful in different phases of our project, especially in the training phase of our AI, in practice when it is taught to perform the task for which it was created.

As I said before, data can be divided into two macro categories: structured or unstructured.

Structured data conforms to a model, has a well-defined structure, is ordered and can be easily accessed for use (either by a person or by a program). They are usually stored in databases. If we consider the example of apples and pears previously introduced, we can associate the two fruits with their own characteristics (color, size, shape ...) which will serve to distinguish them and will be used to train the algorithm. 

Unstructured data, on the other hand, is video, photos, audio ... much more difficult to process.

The algorithm

After reflecting on the type of data we will be dealing with, we can start thinking about the most suitable algorithm for solving the problem, an algorithm that will become the heart of our AI. 

We can divide algorithms into two categories called "supervised learning" and "unsupervised learning". 

The first category (supervised learning) includes algorithms that require human intervention, mainly to manually classify the data that will then be used to train the algorithm. If our problem consisted in checking incoming emails and selecting spam ones, to be sent to a specific folder, we will probably use an algorithm of this category using as examples a very large number of messages that users have classified as legitimate or spam. Among these techniques we can include neural networks, naive Bayes, linear regression, logistic regression, support vector machine (SVM), k-nearest neighbor, random forest.

The second category (unsupervised learning) includes algorithms that do not require human intervention to classify the data and there are three sub-categories: clustering, association and dimensionality reduction. Also by way of example, if our problem consists in identifying potentially malicious activities in a corporate network, we will probably use a clustering algorithm to identify the set of activities that appear very different from the usual ones. 

Train AI

The next step is to train the algorithm to do the task. To return to the simple initial example of the division of images of pears and apples, it will be necessary to train our algorithm to recognize the two fruits with a certain accuracy. Accuracy is up to us, it's something we have to decide based on our business goals. We may decide that we care about 80% accuracy, which means that our algorithm will need to be able to recognize a pear or an apple from fruit images 80 times out of a hundred. this means that we can manage the algorithm error through another methodology (for example by putting a person to check the selected images) or that the error does not cause damage to our business or that the damage caused is less than the expense that we should support to improve the selection process.

However, if in the training phase the required accuracy is not achieved, it may be necessary to take a step back and choose a different type of algorithm. But before changing algorithm it is better to check its configuration (through the configuration parameters) and if the dataset selected to perform the training is correct. To return to the usual example of selecting apples and pears, if among the images used for training we have mistakenly used only images of pears and apples in red color, it could be that the AI ​​does not recognize pears and apples of other colors, failing therefore to achieve the required accuracy. In this case it will be sufficient to modify the dataset to include fruits of various colors, until the required accuracy is reached.

Programming language and platform

The next step is to choose the programming language to use. The choice depends on our programming knowledge.

The languages ​​that can be used are many but the most common are Python and R as they already have many ready-to-use libraries that simplify writing the code. Finally, it is necessary to choose the platform that will allow us to build our AI. There are various platforms that help in the realization of our project, among these for example TensorFlow is an open source platform that allows you to do tests without spending anything, or Numpy, Keras, Pandas, scikit-learn, Matplotlib, Seaborn and so on, the panorama is really wide.

All that remains is to try ...

By the way, I forgot to mention that our AI continually feeds on the data it receives. It tracks and uses them. In this way it is possible to teach them to make predictions, perhaps on the quality and type of apples that we will find on the market in the coming months. But that's another problem!

Alessandro Rugolo

(I thank all the friends of SICYNT who advised me and helped me to improve the article)

To learn more:

The new digital revolution, deep learning - Online Defense

Step-by-Step Methods To Build Your Own AI System Today | upGrad blog

What is Structured Data? - GeeksforGeeks

What is Supervised Learning? | IBM

Types of Artificial Intelligence Algorithms You Should Know [A Complete Guide] | upGrad blog

Unsupervised Learning for Cyber ​​(hmgstrategy.com)

rheinmetal defense