Implementing Classification with t6 IoT and Machine Learning
Learn how to leverage the machine learning capabilities of the t6 IoT platform to classify data into positive and negative classes, enabling you to make informed decisions and extract valuable insights from your IoT applications.
Tagged on #recipe, #flow, #preprocessor, #Machine-Learning, #Algo, #Supervised, #MadeWithTFJS, #TensorFlow, #Classification, #Labelling,
In this tutorial, we will explore how to utilize the machine-learning features of the t6 IoT platform to classify data into positive and negative classes. By harnessing the power of machine-learning algorithms, you can make accurate predictions and gain valuable insights from your IoT data.
Follow these steps to classify integers as “Positive” or “Negative” using the t6 IoT machine-learning process:
Step 1: Data Collection and Integration
- Ensure that your data Flows are properly configured and associated with
integer
datatype. - Make sure training data are correctly labeled for training, hence it will performs as supervised learning (SL).
Step 2: Customization and Model Configuration
- Define the list of categories and features for training: Categories are used as labels and features asre set as a “value” string inside
continuous_features
; the value will be taken from the Flow(s) integers values. In the case of our integer Classification, we will use 2 Categories: “Positive” and “Negative”. - Customize your machine-learning models in the t6 IoT platform with hyperparameters: validation_split
,
epochs,
layersand
compiler`. Customizing machine-learning models in the t6 IoT platform is easy and intuitive. You can create and configure models using the t6 IoT API.
Here’s a sample cURL request to create a new model, you will require to adjust {{YOUR_FLOW_UUID}}
accordingly :
curl --location --request POST "https://api.internetcollaboratif.info/v2.0.1/models" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer ey[***REDACTED***]" \
--data "{
\"name\": \"Machine Learning Model to classify integers relative to zero\",
\"datasets\": {
\"training\": {
\"start\": \"2024-04-04 20:00:00\",
\"end\": \"2024-04-11 20:00:00\"
},
\"testing\": {
\"start\": \"2024-04-04 20:00:00\",
\"end\": \"2024-04-11 20:00:00\"
}
},
\"window_time_frame\": \"1h\",
\"normalize\": false,
\"shuffle\": true,
\"flow_ids\": [
\"{{YOUR_FLOW_UUID}}\"
],
\"layers\": [
{
\"type\": \"input\",
\"mode\": \"dense\",
\"units\": 8,
\"activation\": \"relu\"
},
{
\"type\": \"hidden\",
\"mode\": \"dropout\",
\"rate\": 0.2,
\"units\": 2,
\"activation\": \"relu\"
},
{
\"type\": \"hidden\",
\"mode\": \"dense\",
\"units\": 4,
\"activation\": \"relu\"
},
{
\"type\": \"output\",
\"mode\": \"dense\",
\"activation\": \"softmax\"
}
],
\"compile\": {
\"optimizer\": \"adam\",
\"learningrate\": 0.0007,
\"loss\": \"categoricalCrossentropy\",
\"metrics\": [
\"accuracy\"
]
},
\"validation_split\": 0.15,
\"batch_size\": -1,
\"epochs\": 200,
\"continuous_features\": [
\"value\"
],
\"categorical_features\": [],
\"categorical_features_classes\": [],
\"labels\": [
\"Positive\",
\"Negative\"
],
\"retention\": \"retention1w\"
}"
Visualize the Model
Once the model is created, you can use the following sample cURL Code and visualize the model :
curl --location "https://api.internetcollaboratif.info/v2.0.1/models/{{YOUR_MODEL_UUID}}/explain/model?width=800&height=450&margin=50" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer ey[***REDACTED***]"
Sample result :
Step 3: Training and Evaluation
- Train and evaluating your machine-learning model using labeled data.
The evaluation performance will be using accuracy as metric - and it is defined in the model
compile.metrics
array.
curl --location --request POST "https://api.internetcollaboratif.info/v2.0.1/models/{{YOUR_MODEL_UUID}}/train" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer ey[***REDACTED***]"
- After training is completed, you will be able to retrieve and visualize Training Curves
curl --location "https://api.internetcollaboratif.info/v2.0.1/models/{{YOUR_MODEL_UUID}}/explain/training?width=800&height=580&margin=50" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer ey[***REDACTED***]"
Sample result :
Step 4: Predict Class using the model
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer ey[***REDACTED***]"
--data "[
{
\"time\": \"2025-12-30 20:00:00\",
\"value\": -3773,
\"flow_id\": \"{{YOUR_FLOW_UUID}}\",
\"meta\": {
\"categories\": []
}
}
]"
As a result, the Api will return a predicted value using the trained model :
{
"code": 200,
"value": -3773,
"labels": [
"Positive",
"Negative"
],
"predictions": [
{
"label": "Positive",
"prediction": 0
},
{
"label": "Negative",
"prediction": 1
}
],
"bestMatchIndex": 1,
"bestMatchPrediction": 1,
"bestMatchLabel": "Negative"
}
By following these implementation steps, you can harness the machine learning capabilities of the t6 IoT platform to classify data into positive and negative classes effectively. Whether it’s sentiment analysis, anomaly detection, or predictive maintenance, t6 provides a powerful framework for extracting valuable insights from your IoT applications. Experiment with different use cases, iterate on model training, and unlock the full potential of machine-learning with t6 IoT.
We hope this tutorial has provided you with valuable insights into leveraging machine learning for positive and negative class classification with the t6 IoT platform. Explore the possibilities, customize your models, and embark on a journey of discovery with t6 IoT.
For further information and support, refer to our Technical documentation and reach out to our dedicated support team.
Tagged on #recipe, #flow, #preprocessor, #Machine-Learning, #Algo, #Supervised, #MadeWithTFJS, #TensorFlow, #Classification, #Labelling,