t6 Blog Posts > Implementing Classification with t6 IoT and Machine Learning

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,

Implementing Classification with t6 IoT and Machine Learning

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

Step 2: Customization and Model Configuration

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 :

IIIIIIII8 input unitsAc. func. reluHH2 Dropout 0.2%HHHH4 hidden unitsAc. func. reluOPositive1 output unitsAc. func. softmax

Step 3: Training and Evaluation

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***]"
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 :

0204060801001201401601800.400.450.500.550.600.650.700.750.800.850.900.95Accuracy0.51.01.52.02.53.03.54.04.55.05.56.0LossAccuracyLoss

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,