Abstract
In this paper, we illustrate how to enhance an existing state-of-the-art modeling language and tool for the Internet of Things (IoT), called ThingML, to support machine learning on the modeling level. To this aim, we extend the Domain-Specific Language (DSL) of ThingML, as well as its code generation framework. Our DSL allows one to define things, which are in charge of carrying out data analytics. Further, our code generators can automatically produce the complete implementation in Java and Python. The generated Python code is responsible for data analytics and employs APIs of machine learning libraries, such as Keras, Tensorflow and Scikit Learn. Our prototype is available as open source software on Github.
Introduction
The development of Internet of Things (IoT) services utilizing Big Data is currently a fragmented process. Developers typically rely on Computer-Aided Software Engineering (CASE) tools like ThingML for modeling device behavior and communication, but these tools often lack native support for data analytics. Conversely, Computer-Aided Data Engineering and Analytics (CADEA) frameworks like KNIME excel at data science but operate outside the broader software development lifecycle.
This "gap" necessitates manual, complex integration code to connect IoT devices to machine learning (ML) models. ThingML2 addresses this by bringing ML into the Model-Driven Software Engineering (MDSE) paradigm, specifically tailored for IoT and Cyber-Physical Systems (CPS).
Methodology: Extending ThingML
ThingML2 evolves the original language through two primary enhancements: a DSL extension and an updated code generation framework.
DSL Extension
The authors modified the ThingML meta-model to incorporate "Data Analytics" (DA) blocks. This allows a "Thing" within the model to be explicitly tasked with analytics operations. New modeling elements include specific actions for preprocessing data, training models, making predictions, and saving results.
Enhanced Code Generation
The framework's code generators produce full implementations in Java and Python. While Java manages general system logic, the generated Python code serves as the analytics engine. It automatically utilizes industry-standard libraries such as Keras, TensorFlow, and Scikit-Learn, abstracting away the implementation details of these ML libraries from the high-level model.
Key Insights
- ML as a First-Class Citizen: Data analytics is treated as a core component of a "Thing's" behavior, defined alongside its ports, messages, and state machines.
- Automated Glue Code: ThingML2 automates the "plumbing" required to move data from sensors into ML-ready formats and return predictions to the system logic.
- Smart State Machines: Traditional state machines become "smart" by transitioning based on ML-driven events, such as moving to an
Ignorestate when a DDoS attack is predicted.
Results and Case Study
The authors demonstrated the framework using a "Smart PingPong" use case for DDoS detection. In this scenario, a server uses an ML-enabled "Data Analytics Thing" to identify and mitigate attacks.
The prototype, named ML-Quadrat, is available as open-source software on GitHub, providing a tangible tool for the MDSE community to integrate ML into IoT workflows.
Limitations and Future Work
While ThingML2 supports major Python ML libraries, the current scope for handling highly complex or custom model architectures within the DSL requires further detail. Additionally, the challenge of running these models on resource-constrained "edge" devices versus powerful servers remains an area for exploration. Future research will focus on quantitative evaluations of performance overhead and developer productivity gains.
Summary updated