# Rule-Based DSL for Continuous Features and ML Models Selection in Multiple Sclerosis Research
## 3 Dsl Design
### Meta Model Design  
As we discussed, the design of our DSL's meta model is guided by key requirements ensuring its flexibility and applicability in MS research and treatment. It features a hierarchical structure for clear navigation, modularity for adaptability, and unique identifiers for precise element reference. The DSL supports task-specific models, flexible data loading, comprehensive evaluation metrics, and a rule-based training approach. It also includes mechanisms for feature selection, visualization, and handling of logical expressions, all facilitated by an auxiliary table for attribute values. These requirements ensure the DSL is robust, capable of addressing complex challenges, and user-friendly. The abstract syntax of our DSL in Listing 1 defines how each construct is interpreted and executed within the context of the ML model and feature selection. Here, we provide a precise description of the key language elements:  
* **RuleModel:** This is the root container for all the elements in a model definition. When executing a RuleModel, each contained element is interpreted and executed in sequence. * **Model:** Defines an ML task with a specific name and type (classification or regression). It encapsulates all the elements required for model training and evaluation. As shown in Listing 2, the model is defined with a regression task. It includes an AutoML model, feature selection from the loaded dataset, specified metrics, visualizations, and instructions for the ML model to start with. * **Load:** Specifies the data source. When executed, it loads the dataset from the specified path into memory, making it available for subsequent operations. * **MLModel:** Declares a ML model type with optional parameters. When invoked, it instantiates the specified model with the given parameters. * **Metric:** Defines the evaluation metrics for model performance. These metrics are calculated after model training and used in decision-making processes within rules. * **FeatureSelection:** Specifies the features to be used in model training. It can include filtering conditions and feature selections. When executed, it preprocesses the dataset to include only the specified features. Listing 2 provides a comprehensive example of feature selection. This example demonstrates the ability to select multiple features from different datasets while applying specific conditions. Furthermore, for each selected feature, operators can be added to filter feature values, offering fine-grained control over the data used in the model. * **Rule:** A rule is composed of two parts: the condition (expression) that checks the metrics of the ML models, and the specific action (typically selecting a model or feature set) to be taken. * **RuleSet:** Contains a collection of rules for model selection and feature engineering. Rules are evaluated sequentially, and their actions are executed when conditions are met. In Listing 3, the example ruleSet contains three rules, describing a workflow for model selection and training. Initially, if the SVM model does not meet the performance criteria, the system switches to training a RandomForest model. Should the RandomForest model perform well, it is further trained with a filtered set of features. However, if the RandomForest model also underperforms, the system initiates training of a DecisionTree model with a different feature selection. This rule-based approach allows for adaptive model selection and feature refinement based on performance metrics, enabling the system to dynamically adjust its strategy to achieve optimal results. * **Start:** Initiates the model training process with the specified model and feature set. It triggers the actual computation and evaluation of the ML pipeline. * **Show:** Outputs the results of the model training and evaluation process. It can display model performance metrics, feature importance, or other relevant information.