## 2 Methodology
### Data Preparation  
The third phase covers all the activities for the construction of the final dataset using raw data. Focusing on the study at hand, this phase was one of the longest and most tedious given the nature of the initial data available. More complex preparation was required to process fields expressed in natural language, as the rest were Boolean or categorical. During processing, keywords were identified in order to detect the meaning of the statement or to identify the basic concept expressed. For every natural language text, the doctor that helped in this project helped us define the key words we should look for inside the text. We built a script that transforms the free text field in several Boolean fields that will be true if we detect the keyword or false in case we did not find the word in the natural language field. For example, if considering an original field expressing the patient's family antecedents, a search would be carried out for keywords such as: ASD (autism spectrum disorders), ADHD (attention deficit hyperactivity disorder), speech problems, attention issues, mental issues, Asperger's and Down syndrome. To do so, the field of family antecedents is divided into eight Boolean fields, which are used at a later stage to train the unsupervised AI system. The same process is followed for the rest of fields with these characteristics such as complications at birth or type of birth. Furthermore, it is also necessary to prepare the data for some fields due to a lack of consistency in the units used. For instance, there are fields such as newborn baby weight, where values can be expressed both in grams and kilograms. The process for assigning a consistent unit was automated for the purposes of homogenization. It was also necessary to treat blank values. To do so, any fields exceeding 25% of the total record blanks were eliminated. In those cases where we have values in more that 75% of the total records but we find blank values, we replace the blank value with the mean for the numerical variable cases, and the median was used for categorical variables. Finally, it should be noted that atypical values, known as outliers, were ruled out as due to their nature, they were considered errors when inputting data. We consider an outlier a value greater than two times the medium. As a summary, Table 1 specifies the different fields used as well as the transformations and decomposition carried out. In order to explain this scheme, each individual column will be detailed paying attention, for instance, to the patient antecedents field. 1. _Medical Report field:_ ACOIDPEAMTFAMILIARES is the identifier of the field chosen as an example. 2. _Field description_: This value is an interpretation of the meaning of the field in question. 3. _Data type_: The possible values are: Categorical, Numerical, Free text (equivalent to natural language), or Not relevant. 4. _Completness_: Percentage of values completed in this field. 5. _Transformation_: Expresses where a transformation has been carried out. 6. _Final variable_: Contains the final variable type after transformation. 7. _Comment_: Specifies whether there are any additional aspects to be taken into consideration, i.e., No comment. 8. _S (selected)_: Value is 1 if this field was chosen as an explanatory variable to train the model. After completing these data preparation tasks, the final list of explanatory variables is 40, which shows the tasks used to train the system's unsupervised learning system.