Back

IoT, Health

Machine Learning for IoT applications

iot.jpg

Why use artificial intelligence (AI) in your embedded systems?

The idea is gaining ground in all sectors, from aircraft to drones, cars, security equipment, robots, industrial sensors and biomedical monitors. In the latter systems involving human life, every millisecond counts. By processing the data close to the sensors that produce it, network latency times are avoided, in-responsiveness and safety rise up.

Problems to solve

How can embedded systems benefit from machine learning? 

How can IoT make predictions for their applications? For instance, how to predict remotely if a person is likely to have a risk of cardiovascular diseases?

Can machine learning help in this matter? How accurate predictive models can be used to detect such threats? How easily can these models be embedded in a system?

Benefits of TADA

Domain & data experts are not data scientists. They may not have the required skills in machine learning nor coding to build predictive models. Moreover, most data handled by these professionals are Small Data, meaning that their historical data often contains few hundreds or thousands of patients but rarely millions (aka Big Data). Traditional machine learning tools work well with Big Data but do not perform well with Small Data.

MyDataModels allows domain experts to automatically build predictive models from Small Data. They can use their raw data directly: no normalization, outliers handling nor feature engineering are required. Thanks to this limited data preparation, the results from this specific dataset were obtained with a few clicks in less than a minute on a standard laptop. 

Thanks to its light weight (2Ko), a TADA model can be embedded into devices microcontrollers. 

Therefore, in order to use a model, a device does not need to compute the data into the cloud but can do it locally in the edge environment.

Edge computing allows lower latency and reduced costs with a greater reliability, as opposed to a more traditional cloud computing approach using APIs.

By processing the data close to the sensors that produce it, network latency times are avoided, with important gains in responsiveness and safety.

No concern for data security either: in applications such as predictive maintenance & healthcare, manufacturers may be unwilling to put their production data in the cloud for analyze.

MyDataModels brings a self-service solution for those who have Small Data and no data scientists.

Conclusion

Now, the medical and healthcare world can combine the use of IoT and machine learning to detect health problems more accurately and faster than ever.

This symbiotic use makes it possible to train the model in the cloud or in a datacenter while using it in the embedded system.

The main benefit of this mode of operation is that you can take advantage of all the computing power of the cloud and advanced machine learning techniques to build models while being able to execute them remotely. Taking a decision, monitoring or raising an alert locally on an embedded device within seconds may avoid serious health complications or even save lives.

Case study

Solution

Automated Machine Learning solutions consist of predicting the future with historical data. To predict a future result, you must bring your descriptive data and the past result obtained.

TADA allows you to simply create a relevant predictive model from your data and apply it to future data.

In this case, the descriptive data are patient’s information.

The goal of the dataset is to predict if a patient has a cardiovascular problem or no: it’s a binary task (True/False).

To generate a model, the steps are the following:

  • Create your project and load your data as a CSV table (with data in rows and variables in columns).
  • Select the variable you want to predict, called Goal. 
    In this case, the Goal is the variable "Class Pathology" (a visualization of the variable is provided).
  • Select your data for the model generation. This step is called "Creating the Variable set" and allows you to manually select the descriptive variables you want to use. By default, they are all selected.
    TADA identifies the relevant descriptive variables by itself, which affects the calculation time required to create the model.
    The fewer variables selected, the faster the model creation
  • Create your model.
    At creation, default values ​​are proposed to you: Name of models, Population, Iteration. You only need to validate the default values ​​to start model generation.
    ‘Best practices’ are at your disposal to guide you in the choice of these parameters.

    Depending on the size of the file this step can take between a few seconds and ten minutes.
    Once the model is created, you can see the results of the model using metrics and charts so you can judge its relevance.

Note:

To apply a model that you think is relevant, you can:

  • Retrieve the associated mathematical formula and apply it (for instance on Excel)
  • Retrieve the source code of the formula and use it by yourself (Valid only on TADA paying offers). The source code is available in R, Java, C ++ and soon Python.
  • In order to use our "Predict" feature on the product, you will have to upload your file containing the data to be predicted. You will be returned a downloadable file containing the given data, with
    the calculated predictions.


Dataset information

The screenshot below shows an extract of the dataset.

Each row is an electrocardiogram signal (ECG) coming from a patient, and each column is a variable which can be used in the model.

dataset.jpg

  • Task type: Binary Classification
  • Number of columns: 25
  • Number of rows: 240
  • Target: class Pathology (T, F)
  • Weight: Positive class (T = True Pathology) 17%, Negative class (F = False Pathology) 83%

The  Variables are:

1) Item #, from 1 to 240

2) Pathology: target variable, F = False = no pathology detected, T = True = pathology detected

3) => 23) Alarms from electrocardiogram (ECG) signal, heart and breathing rates, temperature, walking speed, etc.

Given the unbalance in the target dataset, instead of evaluating the model using its accuracy, a better way to assess the performance of the model is to look at the sensitivity (True Positive Rate - TPR). 

Since the goal “Pathology” is the positive class, the sensitivity can be seen as the probability that the test is positive given that the patient is sick


Results

The results of the model are available following the generation of the model.

They present the performance of the predictive model.

The type of predictive model and the measurement indicators of the associated model are related to the Goal (Variable to be predicted) and the values ​​of this variable.

The type of model you make is shown on the model results display.

According to the type of the Goal (in our case, the Goal is "Target"), we can make three types of predictions:

  • Binary classification: Discrete value taking only two values (yes / no for instance)
  • Multiclass classification: Discrete value taking more than two values (for instance a status of state with values ​​like: On, Risk of breakdown, Down, etc.)
  • Regression: Continuous value that can take an infinite number of values (a temperature, a pressure, a turnover, the price of a house, etc.)

At the generation of the model and according to the practices and state of the art of Machine Learning, your dataset will be divided into three parts by TADA:

  • A training part which represents 40% of your dataset, it allows to train a certain number of formulas,
  • A validation part, which represents 30% of your dataset, which validates and selects the best formulas found in the previous step,
  • A test part which represents the last 30% of the model and which corresponds to the test of the formulas approved by the preceding stage. The performance measurement and the evaluation of your model should mainly be done on this partition (Standard and state of the art of Machine Learning) because the present data were not used in the learning and validation phase of the machine learning model and serve just to measure its performance.

metrics.jpg

ACC (Accuracy) represents the overall accuracy rate of the model, it is the percentage of classes that are well distributed (here we have 79.17% predictions that are correct)

TPR (True Positive Rate) represents the accuracy rate of the prediction of the positive class, i.e. of the "yes/T" class

TNR (True Negative Rate) represents the accuracy rate of the prediction of the positive class, i.e. of the "No/F" class

MCC (Matthew's Correlation Coefficient) represents the good prediction as a whole, that is, if we were able to divide the predictions between the two classes.

Confusion matrix 

confusion_matrix.jpg

Here, the confusion matrix represents a visual way to interpret the metrics.
In this case, TADA predicted 24 times that a patient has a pathology and was wrong 14 times (TADA predicted that 14 patients have a pathology, while they actually don’t).
In parallel, TADA predicted 48 times that a patient doesn’t have a pathology and was wrong 1 time (TADA missed only 1 pathology).

Ready to use TADA?

You don't have immediate data?

No problem, data are available to make your trial as relevant as possible!

Try it now!

Detailed informations

General

Artificial intelligence: Theories and techniques aiming to simulate intelligence (human, animal or other).

Binary Classification: It is the problem type when you are trying to predict one of two states, e.g. yes/no, true/ false, A/B, 0/1, red/green, etc. This kind of analysis requires that the Goal variable type is of type CLASS. Binary Classification analysis also requires that there be only 2 different values in the Goal column. Otherwise, it is not a binary problem (two choices and no more).

Convolutional Neural Network: This type of network is dedicated to object recognition. They are generally composed of several layers of convolutions + pooling followed by one or more FC layers. A convolutional layer can be seen as a filter. Thus, the first layer of a CNN make it possible to filter the corners, curves and segments and the following ones, more and more complex forms.

Data Mining: Field of data science aimed at extracting knowledge and / or information from a body of data.

Deep Learning: Deep Learning is a category of so-called "layered" machine learning algorithms. A deep learning algorithm is a neural network with a large number of layers. The main interest of these networks is their ability to learn models from raw data, thus reducing pre-processing (often important in the case of classical algorithms).

Fully Convolutional Networks: An FCN is a CNN with the last FC layers removed. This type of network is currently not used much but can be very useful if it is succeeded by an RNN network allowing integration of the time dimension in a visual recognition analysis.

GRU (Gated Recurrent Unit): A GRU network is a simplified LSTM invented recently (2014) and allowing better predictions and easier parameterization.

LSTM (Long Short-Term Memory): An LSTM is an RNN to which a system has been added to control access to memory cells. We speak of "Gated Activation Function". LSTMs perform better than conventional RNNs.

Machine learning : Subfield of Artificial Intelligence (AI), Machine Learning is the scientific study of algorithms and statistical models that provides systems the ability to learn and improve any specific tasks without explicit programming.

Multi Classification: Classification when there is more than two classes in the goal variable, e.g. A/B/C/D, red/orange/green, etc.

Multilayer perceptron: This is a classic neural network. Generally, all the neurons of a layer are connected to all the neurons of the next layer. We are talking about Fully Connected (FC) layers.

RCNN (Regional CNN): This type of network compensates for the shortcomings of a classic CNN and answers the question: what to do when an image contains several objects to recognize? An RCNN makes it possible to extract several labels (each associated with a bounding box) of an image.

Regression: Set of statistical processes to predict a specific number or value. Regression analysis requires the type of Goal variable to be numeric (INTEGER or DOUBLE).

Reinforcement learning: Reinforcement learning is about supervised learning. It involves using new predicted data to improve the learning model (calculated upstream).

RNN (Recurrent Neural Networks): Recurrent networks are a set of networks integrating the temporal dimension. Thus, from one prediction to another, information is shared. These networks are mainly used for the recognition of activities or actions via video or other sensors.

Semi supervised learning: Semi-supervised learning is a special case of supervised learning. Semi-supervised learning is when training data is incomplete. The interest is to learn a model with little labeled data.

Stratified sampling: It is a method of sampling such that the distribution of goal observations in each stratum of the sample is the same as the distribution of goal observations in the population. TADA uses this method to shuffle the data set from binary and multi classification projects.

Simple random sampling: It is a method of sampling in which each observation is equally likely to be chosen randomly. TADA uses this method to shuffle the data set from regression projects.

Supervised learning: Sub-domain of machine learning, supervised learning aims to generalize and extract rules from labeled data. All this in order to make predictions (to predict the label associated with a data without label).

Transfer learning: Brought up to date by deep learning, transfer learning consists of reusing pre-learned learning models in order not to reinvent the wheel at each learning.

Unsupervised learning: Sub-domain of machine learning, unsupervised learning aims to group data that are similar and divide/separate different data. We talk about minimizing intra-class variance and maximizing inter-class variance.


Metrics

Binary

ACC (Accuracy): Percentage of samples in the test set correctly classified by the model.

Actual Negative: Number of samples of negative case in the raw source data subset.

Actual Positive: Number of samples of positive case in the raw source data subset.

AUC: Area Under the Curve (AUC) of the Receiver Operating characteristic (ROC) curve. It is in the interval [0;1]. A perfect predictive model gives an AUC score of 1. A predictive model which makes random guesses has an AUC score of 0.5.

F1 score: Single value metric that gives an indication of a Binary Classification model's efficiency at predicting both True and False predictions. It is computed using the harmonic mean of PPV and TPR.

False Negative: Number of positive class samples in the source data subset that were incorrectly predicted as negative.

False Positive: Number of negative class samples in the source data subset that were incorrectly predicted as positive.

MCC (Matthews Correlation Coefficient): Single value metric that gives an indication of a Binary Classification model's efficacy at predicting both classes. This value ranges between -1 to +1 with +1 being a perfect classifier.

PPV (Positive Predictive Value/Precision): Number of a model's True Positive predictions divided by the number of (True Positives + False Positives) in the test set.

Predicted Positive: Number of samples in the source data subset predicted as the positive case by the model.

Predicted Negative: Number of samples in the source data subset predicted as the negative case by the model.

True Positive: Number of positive class samples in the source data subset accurately predicted by the model.

True Negative: Number of negative class samples in the source data subset accurately predicted by the model.

TPR (True Positive Rate/Sensitivity/Recall): Ratio of True Positive predictions to actual positives with respect to the test set. It is calculated by dividing the true positive count by the actual positive count.

TNR (True Negative Rate/Specificity): Ratio of True Negative predictions to actual negatives with respect to the test set. It is calculated by dividing the True Negative count by the actual negative count.

 

Multi classification

ACC (Accuracy): Ratio of the correctly classified samples over all the samples.

Actual Total: Total number of samples in the source data subset that were of the given class.

Cohen’s Kappa (K): Coefficient that measures inter-rater agreement for categorical items, it tells how much better a classifier is performing over the performance of a classifier that simply guesses at random according to the frequency of each class. It is in the interval [-1:1]. A coefficient of +1 represents a perfect prediction, 0 no better than random prediction and −1 indicates total disagreement.

False Negative: Number of positive class samples in the source data subset that were incorrectly predicted as negative.

False Positive: Number of negative class samples in the source data subset that were incorrectly predicted as positive.

Macro-PPV (Positive Predictive Value/Precision): The mean of the computed PPV within each class (independently of the other classes). Each PPV is the number of True Positive (TP) predictions divided by the total number of positive predictions (TP+FP, with FP for False Positive) within each class. PPV is in the interval [0;1]. The higher this value, the better the confidence that positive results are true.

Macro-TPR (True Positive Rate/Recall): The mean of the computed TPR within each class (independently of the other classes). Each TPR is the proportion of samples predicted Truly Positive (TP) out of all the samples that actually are positive (TP+FN, with FN for False Negative). TPR is in the interval [0;1]. The higher this value, the fewer actual samples of positive class are labeled as negative.

Macro F1 score: Harmonic mean of macro-average PPV and TPR. F1 Score is in the interval [0;1]. The F1 Score can be interpreted as a weighted average of the PPV and TPR values. It reaches its best value at 1 and worst value at 0.

MCC (Matthews Correlation Coefficient): Represents the multi class confusion matrix with a single value. Precision and recall for all the classes are computed and averaged into a single real number within the interval [-1;1]. However, in the multiclass case, its minimum value lies between -1 (total disagreement between prediction and truth) and 0 (no better than random) depending on the data distribution.

Predicted Total: Total number of samples in the source data subset that were predicted of the given class.

True Positive: Number of positive class samples in the source data subset accurately predicted by the model.

True Negative: Number of negative class samples in the source data subset accurately predicted by the model.

 

Regression

MAE (Mean Absolute Error): represents the average magnitude of the errors in a set of predictions, without considering their direction. It’s the average over the test sample of the absolute differences between prediction and actual observation where all individual differences have equal weight. MAE is in the intervall [0;+∞]. A coefficient of 0 represents a perfect prediction, the higher this value is the more error (relative error) the model have.

MAPE (Mean Absolute Percentage Error): MAPE is computed as the average of the absolute values of the deviations of the predicted versus actual values.

Max-Error: Maximum Error. The application considers here the magnitude (absolute error when identifying the maximum error. Thus -1.5 would be consider the maximum error over +1.3. The sign of the error however is still reported in this column in case it has domain significance for the user.

R2 (R Squared): also known as the Coefficient of Determination. The application computes the R2 statistic as 1 - (SSres / SStot) where SSres is the residual sum of squares and SStot is the total sum of squares.

RMSE: Root Mean Square Error against the Dataset partition selected. RMSE is computed as the square root of the mean of the squared deviations of the predicted from actual values.

SD-ERROR (Standard Deviation Error): Standard statistical measure used to quantify the amount of variation of a set of data values.