 Ciao, il mio nome è Matteo Maravita e sono responsabile di l'Asia Paca e l'Icompetenzia Center. Oggi vi introducirò alcuni concetti e tipi importanti che bisogna fare quando iniziare un nuovo design di un progetto machine learning. Questa è l'agenda dei topici che ci coveriamo. Per mantenere la videoconferenza in grado di durazione, lo spritiamo in una serie di due video. Per prima cosa, introduziamo alcuni concetti importanti di machine learning e iniziamo il nostro progetto di design con questa collezione, questa inspezione e questa pittura. Per prima cosa, facciamo più sul futuro, che è molto importante per qualsiasi tipo di progetto machine learning. Poi vediamo come evaluare la performance del modello che abbiamo creato. Finalmente, vedremo alcune informazioni addizionali che potrebbero essere utili per il futuro. Iniziamo con alcuni concetti di machine learning. Recentemente, i mass media stanno parlando di l'intelligenza artificiale, referendo a questa informazione come una delle tecnologie più recenti e avanzate. Attualmente, l'AI è un concetto che è stato concepito nel 50° di ultimo anno e ha un significato molto grande. Iniziamo con alcune tecniche che evitano un computer a imbibirci del comportamento umano. Poi puoi capire come questo concetto è molto generale e iniziamo con molte altre area di soluzioni e di ricerca. In questo video, facciamo un subseto dell'AI, che è il machine learning. Introduzionato nel 80° di ultimo anno. Iniziamo con un keyword che mostreremo in questo video, che è data. Infatti, il machine learning rifererebbe a alcun algoritmo e la metodologia che usano data e la ricerca da data per approfondire l'intero tempo. Iniziamo con questo concetto molto importante. Poi c'è un altro subseto di machine learning, che è il deep learning, che è l'algoritmo più complesso e avanzato. Perché? Perché non è solo la ricerca da data, ma anche come una struttura che mimica il neural network del brain umano. Quando riferiamo con i progetti di machine learning, prima di tutto, bisogna cambiare la nostra approccia per il soluzione di problemi. Infatti, con la tecnica di programmia standard, usiamo un approccio di priori. In il nostro brain, quando pensiamo di un problema, basically we already picture and consequently design the algorithm that we think that will solve the problem. Thus, we are already writing the solution from the real beginning. While in machine learning we use an empirical approach. We start from collecting data from observations of the system. Both input data and desired output data. And we derive the algorithm that will best fit the data and observations collected. Obviously, we don't start from a blank sheet, but we select a few machine learning models available. And we try to find the parameters that will give the best performance. In other words, we need a completely new mindset. Whenever we use machine learning or deep learning on embedded platforms, we need to follow five key steps in the design process. At first, we need to collect the data from our system and to save them in some data logs. The second step is to clean the data and eventually to make some preprocessing of them. We need also to add the labels to them in case of a supervisor model. Now we have the so-called dataset. In the third step we start from the dataset and we use it to train the machine learning model or we say also to fit it. In the fourth step it depends if we are running on a PC or on an embedded platform. On a PC we can run simply the Python libraries available for AI solutions. While on embedded platforms we need to convert from these libraries to C-codes for microcontrollers like the STM32 or to register settings for hardware solutions like the machine learning core present in the STMaps. The final step is to validate the machine learning model created on a real-time application. Talking about traditional machine learning solutions we have a wide variety of models that can be used each with some pros and cons. We will focus our attention from now on on one of them called Decision Tree for two main reasons. The first reason is that is very simple to understand and will help us to go through all the key steps of a machine learning model design. The second reason is that is the one used in the hardware engine present in our latest family of motion maps called the machine learning core. Let's jump into one example that is often used in the machine learning world, the real estate agency example. We need to define at first three key points. The problem, the features or the input to my system, to my algorithm and the desired output. The problem is to understand if the customer will buy or not buy an ounce. The features or inputs are a number of information that we think that are relevant to solve this problem like the cost of the house, the number of rooms, the distance from the station and so on. The desired output is to understand if the customer will buy or not buy. So in this case we are talking about a binary classification problem. You see on the right a decision tree model that I built for the sake of explanation for you in order to solve this issue. So let's go through it. At first you can see that one of the features the customer salary is checked with a certain pressure, $100k per year. If the condition is true or false we will move on the right side or left side of the decision tree. Then we move to another what we call a decision node where we are going to check another future and then again we will have another threshold and then we will proceed until we reach what we call a final leaf is where we take the decision buy or not buy. You can see in this example all the key elements of this decision tree that are the decision node, the futures, the thresholds and the final leaves. But you can tell me ok I'm solving this kind of problem the kind of if-then-else structure so it doesn't sound so much like an AI model. Where is the trick? Actually what is important is not the decision tree structure itself but is how I built it. Here as I said I built it for this example thinking a priori what can be a reasonable future and in which order I will check the different futures and with some thresholds that I think are reasonable. We will see later that actually all these things will be learned from the dataset. In fact I built a decision tree model starting from a dataset of real estate agency of houses for example in Tokyo where I live. And starting from this data learning from the data I decide which futures are more relevant to my problem in which decision node I will use them which are the thresholds that I will use in terms of the leaf nodes. If I change for example my dataset from Tokyo to the Japanese countryside or to other cities in the world like Milano, Paris, Sydney, whatever you can understand well that I may need to change all the futures and the thresholds and so on in order to best fit the reality of each location. So basically with machine learning I will try to fit my dataset and to find all the futures thresholds and so on that will give me the best performance. So we have seen the 5 key steps of a machine learning model design. I may need a dedicated tool for each of them. In case of ST MEMS MLC solution we have a dedicated tool called Unico GUI that is helping us to collect the data to level them to train the model and also to validate it. For the training phase is also possible to use external tools like MATLAB, WECA, Python libraries and so on. Let's start from the data collection. We need at first to select the right hardware platform or evaluation board with the right sensors for my use case. ST is providing a wide variety of evaluation boards and in this case we will focus on the ones that are mounting the motion MEMS with the machine learning core function. Also we need a software tool in order to log the data coming from the sensors. In case of ST we are offering a tool called Agobilder Suite in order to copy it. When collecting the logs for my data set I needed to decide at the very beginning a few key points. The first one is the definition of the classes for my problem since that we are talking about a classifier model. The classes are basically the desired output of my machine learning model. In this case I have a couple of examples of a motor vibration problem or a human activity recognition problem. The second point is the selection of the most appropriate sensor for my problem. I may decide to use only the accelerometer or I may need to use also a gyroscope or other sensors like a pressure sensor, magnetometer and so on. The third point to decide at the very beginning is the settings of this sensor. For example for motion maps I needed to decide the output data rate and the full scale. Infatti if I am going to change later one of these settings I need to restart all the process from the beginning and I want to avoid it. When collecting the data I need to take care also of other important factors. The first one is data consistency. For example if I am collecting the data log in my lab I need to make sure that the conditions and environment is similar to my application use case and eventually integrate the data later with other acquisitions taken in the real world application. The second point is to have a so called balanced dataset. Since we are talking about classifier I needed to make sure that each class has a similar amount of samples. Infatti if I have one class with less samples than others this class may be later not well recognized and the model may be polarized versus the other classes. The third point is the data log format. Sometimes it is easy to forget about it or when dealing with a large amount of data mix data with different formats. This is why for example in ST in all recent demos we are using a predefined data format called high speed data log. Once all data are collected we can now move to the machine learning model design. After applying some filtering or preprocessing to the raw data coming from the sensor we can calculate and select the features that represent the inputs to my machine learning model. This is where there is a major difference between the machine learning and the deep learning approach. Infatti while in machine learning the selection of the features is extremely important in deep learning we work usually with raw data and the features are automatically calculated and selected by the neural network itself. Here we can see some typical examples of features used for motion maps like peak to peak value, various mean and so on. We will come back later to this important aspect. Once the features are calculated the decision tree can be built. In a similar way to the example we have seen before with the real estate agency. Infatti we can see here that we are just changing the name of the features and the binary outputs with the ones used for motion maps. It's very important to remember that usually in machine learning we split the overall dataset in the so-called training dataset and the test dataset. Infatti we are using only a part of the overall dataset to train the model, usually 80% in case of smaller, medium size datasets. And we will use the remaining part the test dataset in order to evaluate the performance of the model built. This is done in order not to cheat. Infatti, if I am using to evaluate the performance, the same data that I used to train the model basically I cannot make sure that the model will perform well also with data slightly different. Basically I am checking if the machine learning model is able to generalize enough. A very important operation is the data inspection in order to identify any possible errors in the dataset, poor quality data or the so-called art layers. I may check at first in the time domain if I can see any pattern to recognize different classes o if any future, like the pick to pick the variance and so on seems to be more informative. Another option is to analyze the data in the frequency domain. Infatti, sometimes we can observe that some classes have a very peculiar frequency footprint. Like in this example where we can recognize easily the working class from the jogging or running class just looking at the FFT of the road data coming from the accelerometer. One operation that is often neglected or to which AI beginners don't pay so much attention is the process of data cleaning. Infatti, since we have said that the machine learning model is learning from the data, any kind of error or poor quality data will have a drastic impact on the performance of the model built. In machine learning world AI engineers usually refer to it with the famous sentence garbagin garbajaut. Per esempio, in this real use case where we wanted to detect the different operation of a power drill where there is tightening or untightening screw, you can see in the logs that are present also data of non drilling condition. We should put this data in a different dummy class like idle or other. Usually the labeling process cannot be done automatically very easily and we need to do it manually. The last point that needs to be decided is the selection of the most appropriate window source. Infatti, we need to make sure after data analysis and visualization that all the signal of interest is properly captured. Obviously there is a trade-off versus the response time needed in the application.