Anastasios Alexiadis

Alexandros Nizamis
email: alnizami@iti.gr

Ioannis Koskinas

Dimosthenis Ioannidis

Konstantinos Votis
email: kvotis@iti.gr

Dimitrios Tzovaras
email: dimitrios.tzovaras@iti.gr

Applying an Intelligent Personal Agent on a Smart Home using a Novel Dialogue Generator

Keywords: Intelligent Agents, Natural Language Understanding, Multiple Intents, Smart Home

Nowadays, Intelligent Personal Agents include Natural Language Understanding (NLU) modules, that utilize Machine Learning (ML), which can be included in different kind of applications in order to enable the translation of users' input into different kinds of actions, as well as ML modules that handle dialogue. This translation is attained by the matching of a user's sentence with an intent contained in an Agent. This paper introduces the first generation of the CERTH Intelligent Personal Agent (CIPA) which is based on the RASA 1 framework and utilizes two machine learning models for NLU and dialogue flow classification. Besides the architecture of CIPA-Generation A, a novel dialogue-story generator that is based on the idea of adjacency pairs is introduced. By utilizing on this novel-generator, the agent is able to create all the possible dialog trees in order to handle conversations without training on existing data in contrast with the majority of the current alternative solutions. CIPA supports multiple intents and it is capable of classifying complex sentences consisting of two user's intents into two automatic operations from the part of the agent. The introduced CIPA-Generation A has been deployed and tested in a real-world scenario at Centre's of Research & Technology Hellas (CERTH) nZEB Smart Home 2 in two different domains, energy and health domain.

Introduction

Fast growth in natural language understanding capabilities of intelligent virtual agents enables its wide use on different types of consumers devices. This type of personal agents have been the focus of research for a long time with plenty of significant results. ELIZA [START_REF] Weizenbaum | ELIZA a Computer Program for the Study of Natural Language Communication Between Man and Machine[END_REF] and IBM Shoebox [START_REF] Dersch | Shoebox -A voice responsive machine[END_REF] are considered as two of the most representative research's first outcomes. Nowadays, there is a wide variety of Intelligent Personal Assistants (IPAs) such as Google Assistant,Amazon Alexa and Apple Siri that attempt to assist humans either by providing them with information or by performing specific tasks for them as a results of their communication with humans using natural language. These systems aim to solve two different but related problems: (a) the natural language understanding and (b) the management of the flow of the conversation (dialogue). Based on these two aforementioned problems, different frameworks have been designed. These frameworks provide to researchers and developers systems that are capable of handling the above problems in order to enable them to develop Virtual Assistants and chat-bots for specific domains. These IPAs frameworks include Google Dialogflow,Amazon Lex,Facebook WIT.AI and RASA. Most of these frameworks are accessed through web Application Programming Interfaces (APIs) and the developers do not have access neither to their source code or to the machine learning models that power them. Leveraging on the above described research results and frameworks, the first version of CERTH Intelligent Personal Agent is designed and introduced in this work. The main key innovative aspect of the proposed agent is the adoption of a novel dialogue-story generator that is based on the idea of adjacency pairs and is able to cover all the possible states in the communication between the humans and the agent. Furthermore, CIPA Generation A is able to support applications of different domains and it is available in a multi-intent model.

The paper is structured as follows. Following the Introduction, a brief literature review is presented. The proposed CIPA-gen A's architecture is analyzed in section 3. In the same section, the dialogue-story generator that is based on the idea of adjacency pairs is presented as well. Section 4 consists the evaluation section and provides a brief description of the use cases of both domains, energy and health. Finally, the conclusions and future work are drawn in section 5.

Related Works

Modern conversational agents relies on natural language processing, supported by AI and ML techniques and execute tasks based on verbal interaction with end-users. As the proposed work is driven by results of research and development in the fields of task-based agents, conversational agents, and dialogue generation, a brief analysis of related works in these fields is documented in this section.

The proposed work is strongly related with dialogue generation in general. Modeling the future direction of a dialogue is crucial to generate coherent dialogues and execute tasks. To this aim, data-driven conversation modeling mostly build upon recurrent neural networks (RNNs) [START_REF] Vinyals | A persona-based neural conversation model[END_REF] that enable an agent to learn how to map rules between input messages and responses from a massive amount of training data. StarSpace [START_REF] Wu | StarSpace: Embed All The Things![END_REF] is a general-purpose neural embedding model that can solve a wide variety of problems including text classification. The StarSpace model consists of learning entities that are described by a set of discrete features. Its main contributions are (a) the generalization across diverse problems and (b) the comparison between embeddings of different types. Industry leaders such as Google Assistant, Amazon Alexa and Apple Siri are based on ML models for dialogue generation . Recently, Google introduces Meena3 , an end-to-end, neural conversational model that learns to respond sensibly to a given conversational context. Meena has a single evolved transformer encoder block for processing the conversation context block and 13 evolved transformer decoder blocks to formulate an actual response. The Encoder-Decoder Model for dialogue generation is a popular technique that is adopted from research community as well. Serban et al. [START_REF] Serban | A hierarchical latent variable encoder-decoder model for generating dialogues[END_REF] introduces an encoder-decoder model for generating dialogues. It is based in a neural network-based architecture, with hierarchical latent variables that capture dependencies over an extended conversation history. To the same direction, a variational hierarchical conversation RNNs model is introduced in [START_REF] Park | A Hierarchical Latent Structure for Variational Conversation Modeling[END_REF]. Other recent approaches are based on Reinforcement Learning techniques. Li at all [14] train two models, a generative model to produce response sequences, and a discriminator to distinguish between the human-generated dialogues and the machine-generated ones. The generative model receives the output of the discriminator as a reward in order to push the complete system to generate dialogues that mostly resemble human dialogues. In [START_REF] Li | Deep reinforcement learning for dialogue generation[END_REF] deep reinforcement learning for dialogue generation method was lately proposed. The method optimizes long-term rewards and uses a encoder-decoder architecture. It simulates the conversation between two virtual agents to discover possible actions while learns to maximize expected reward. Furthermore, plenty approaches related to task-oriented RL methods have been proposed [START_REF] Schatzmann | A survey of statistical user simulation techniques for reinforcement-learning of dialogue management strategies[END_REF].

Besides the general works related to dialogue generation, smart home automation applications that were led by task oriented dialogue systems have been introduced. Recently, Park et al [START_REF] Park | An Efficient Framework for Development of Task-Oriented Dialog Systems in a Smart Home Environment[END_REF], introduced a framework for development of task-oriented dialogue systems in a Smart Home environment. Domain knowledge is required for the proposed task-oriented dialogue system. The framework ontologically expresses the required knowledge and is able to build a dialogue system by editing the dialogue knowledge. In addition to this, a more intelligent conversation is enabled by providing a hierarchical argument structure to manage the various argument representations that are included in natural language sentences. The dialogue management system of the introduced framework is based on a rule-based systems. Rule-based dialogue management systems are defining the possible states of a dialogue and the behavior of the system for the given state. Both finite-state [START_REF] Goddeau | A Form-based Dialogue Manager for Spoken Language Applications[END_REF] and information-state [START_REF] Traum | Current and New Directions in Discourse and Dialogue[END_REF] based systems are used. Especially, the finite-state methodology is highly-correlated to the adjacency pairs methodology, that is introduced from the presented work, as a concept for dialogue generation. However both finite-state and information-state techniques are vulnerable to errors in NLU, because they are entirely dependent on the result of the NLU to recognize the intent of the user. A smart home automation system, named Cassandra, has been introduced in [START_REF] Dumitrescu | Cassandra smart-home system description[END_REF]. A voice assisting system based on automatic speech recognition and NLU is proposed in order to enable user to control smart home appliances. Opposite to the presented work in this paper, Cassandra uses a knowledge base of predefined scenarios to handle the dialog with the user. After analysis and parameters' extraction based on user's voice command, a predifined scenario is selected. Furthermore, the end-user is able to alter Cassandra's configuration by creating scenarios or editing existing ones.

In contrast with the above described related works, that are based on dialogue generation for existing knowledge and data, the proposed CIPA Gen-A introduces a novel dialogue generator that does not require the availability of historical data. It is based on adjacency pairs and enables the generation of all the possible dialogue trees. Adjacency pairs were first introduced by Schegloff and Sacks [START_REF] Schegloff | Opening up closings[END_REF] as the basic foundation of conversational structure can be used for the evaluation of dialogue stories. Midgley et al [START_REF] Midgley | Empirical verification of adja-cency pairs using dialogue segmentation[END_REF] proposed a new method of dialogue segmentation in order to leverage the gathered information from more than one previous utterances identifying adjacency pair labels that occur with high frequency.

CIPA Gen-A Architecture

In this section the design approaches of CERTH Intelligent Personal Agent Gen-A architecture are presented. CIPA-gen A is designed in order to support multiple task domains. This capability is enabled by auto-generated Python scripts that sub-class RASA Core's Action classes, one class for each action included in a CIPA domain, and by providing a call-back function that handles the actions for that domain. Moreover, CIPA-gen A offers an API that supports exchange of messages in JSON format. Furthermore, it includes an SQL database for the storage of user's messages and an action history. CIPA-gen A is provided with a multiple intent model. The novel dialogue generator from CIPA-gen A and the supported multi intent model are explained in details in the following subsections. The technical descriptions come alongside with examples related to the supported domains by the Agent and their datasets in order to describe better the application of the proposed agent and be easier for the reader to understand and follow the concepts in this document.

Supported Domains and Datasets

CIPA-gen A has been deployed in CERTH nZEB Smart Home in two different domains, energy and health. The CERTH nZEB Smart Home is a rapid prototyping and a novel technologies demonstration infrastructure resembling a real domestic building where occupants can experience actual living scenarios while exploring various innovating smart IoT-based technologies with provided Energy, Health, Big Data, Robotics and Artificial Intelligence (AI) services.

CERTH nZEB Smart Home -Energy Domain: Smart Home is equipped with energy domain related IoT devices that monitor the energy consumption and production, and the conditions of the entire building while various algorithms can support automation and energy efficiency scenarios. A dataset has been created from the testers' (Smart Home occupants) inputs, thereafter referred to as the gold set of the energy domain. This set is continuously extended for nZEB Smart Home's energy domain. Due to its size (1608 samples) it is solely used as a test set. A common pattern that has been found in the data was the omission of information crucial for an operation to be performed. For example a user could utter "Turn on the lights" without providing the room where he/she wanted the action to be performed. Moreover, there were observations such as "Turn the lights" which did not contain the fully specified action information, such as if the user wanted the lights on or off. As the user could request a change for the state of the lights of another room this is crucial information.

CERTH nZEB Smart Home -Health Domain: Health related IoT devices monitors a variety of physiological attributes, and enabling the extraction of valuable data through intelligent processing towards preventing situations that could lead to harmful outcomes. A dataset, based on the testers' inputs, has been created. Thereafter, it is referred as the gold set of the health domain. This set is continuously extended and updated for nZEB Smart Home's health domain. Due to its size (1972 samples) it is solely used as a test set.

Novel Dialogue Generator

A novel dialogue-story generator that is based on the idea of adjacency pairs has been designed and developed for CIPA-gen A. The proposed story generator models dialogues that consist of a subset of adjacency pairs based on the following two assumptions: (a) the user may omit information required by an action and thus the Agent have to ask for that information by interacting with the user in a dialogue and (b) the user may not cooperate by following up the conversation. For example, instead of replying to a question posed by the Agent, the user may request another action.

For every action requested, the story generator produces conversation flows with various pieces of the missing but required information and defines the conversation flows that interact with the user to obtain this missing information. This produces all valid conversation flows for each action. For example, consider the "Turn on hvac" action from the nZEB Smart Home energy domain. The introduced generator will produce the following valid stories for this action:

-The user gives the room and the on/off switch.

-The user gives only the room and the agent asks for the on/off operation.

-The user gives only the on/off operation and the agent asks for the room.

-The user doesn't give the required information and the agent first asks for the room and after getting a correct reply asks for the on/off option.

In addition, the generator produces dialogues for handling valid multi-intents by the user. For example in the turn-hvac+change-hvac-mode multi intent, the generator will produce all valid adjacency pair flows for the union of their slots. At the end of each story it will call each action sequentially. If a slot is common to both intents and the user has not provided it, the CIPA-gen A will ask it once. write ' -' intent to act map[intent] 25: else if repeat = -1 or runRepeatedAct = T rue then 26:

for each intent inte of multi intent intent do 27:

write ' -' intent to act map[inte ] 28:

end for 29: end if 30: write ' -action restarted' Moreover, it produces invalid conversation flows in which the user does not cooperate by following up the conversation with the supported intents but he/she follows up the conversation with a different intent. The invalid conversation flows restart the conversation after the agent tells the user that it did not understand his/her intentions.

The proposed algorithm that generates stories (Algorithm 1 to 3), takes as inputs an intent to action mapping, a function that maps intents to a set of slots (that are needed for the intent), a slot example relation that maps slots to random slot instances, a slot to action mapping (that specifies which action requests each slot) and a mapping of valid multi intents. The algorithm automatically generates the story file (in the RASA format) for training the dialogue models. It operates by including a tree-expansion phase to produce all possible story combinations that have slot information missing in the original user message, as well as all invalid variations of them in which the user's reply is classified to a different intent from the expected one.

Algorithm 2 Generate all stories of an intent 0: procedure Gen Intent(intentT oP rocess, rc, mappings) 1: if multIntent(intentT oP rocess) then 2:

Split intentT oP rocess to individual intents 3:

slots ← union of slots of the individual intents 4: else 5:

slots ← slots of intentT oP rocess 6: end if 7: c = 1 8: slotsComb = SlotsCombinations(slots) 9: for include, exluded in slotsComb do 10:

W riteStory(intentT oP rocess, intentT oP rocess, included, excluded, runRepeated = F alse, mappings, c, -1) 11:

c ← c + 1 12:

for excludedItem[i] in excluded do 13:

for intent in intent to act map do 14:

if intent = intentT oP rocess then 15:

W riteStory(intentT oP rocess, intent, included, excluded, runRepeatedAct = F alse, mappings, rc, i) 16: else 17:

W riteStory(intenT oP rocess, intent, included, excluded, runRepeatedAct = T rue, mappings, rc, i) 18:

end if 19:

rc ← rc + 1 20:

end for 21:

end for 22: end for 23: return rc

Single and Multi Intent Models

Both single and multi intent models are supported by the CIPA-gen A. In the single intent model the Chatito,a third-party open-source natural language generator is used in order to create a training set for the NLU module. For the NLU model we did not select Rasa NLU's default model that uses the SpaCy Natural Language Processing system but opted to use a RASA NLU Model based on StarSpace for intent classification. Afterwards, we defined in Chatito's DSL (Domain Specific Language) examples of intents for the nZEB Smart Home domain. These do not correspond to an exact one to one mapping, as we defined some extra intents. The two most important of them are the inform and nounderstand intents. The first should match all user messages that inform the agent about a slot (a parameter) of an action, such as the location of an action, in the case it was not included in the original message. The second one, the nounderstand intent, should match all user messages that resemble messages that correspond to other intents but that do not make sense. For example consider the user message "turn on the lights" and the message "turn on the door", the first message should be classified to the turn the lights intent, whereas the second should be classified to the nounderstand intent. By specifying these intents and text patterns in the Chatito DSL, we used the generator to generate our training set for the NLU Model.

For the dialogue Model, we used the default Rasa Core's LSTM and memorization models. Furthermore, we added a fallback policy for both the intent classification and dialogue classification models. Therefore, the Agent will be able to reply that he does not understand anything in the cases of low classification confidence.

Algorithm 3 Story Gen -Main function of the algorithm 0: procedure Story Gen(domain mappings) 1: Write a story of no understand classified to utter default 2: rc ← 1 3: for intent in intent to action map do 4:

rc ← GenIntent(intent, rc, domain mappings) 5: end for 6: for (inte1 → intents) in multi intent map do 7:

for inte2 in intents do 8:

rc ← GenIntent(inte1 + inte2, rc, domain mappings) 9:

end for 10: end for 11: for slot in slots to act map do 12:

Write a story consisting of a single inform and a slot classified to no-understand 13: end for 14: Write a story consisting of a single inform classified to no-understand

For the multi intent model we developed an algorithm that takes as input a Chatito DSL file alongside with a mapping of valid multi intents and then, it produces an extended Chatito DSL file that includes patterns of these multi intents by combining the patterns of their single intents counterparts. Moreover, it uses a random variable to consider omitted duplicated words when combining messages from two intents. For example, in the case of combining "please turn on the hvac in the kitchen" with "turn the hvac mode on", the second "hvac" word will probably be omitted in the training example for the multi-itent.

Thereafter, we used the output of this algorithm to generate our NLU training examples using Chatito. The output of this algorithm produced a multitude of multi intent data that surpassed the single-intent ones in the data. To balance the classes we post-processed this output by tripling to quadrupling the singleintent observations in the data. Furthermore, we extended RASA NLU's adaption of the StarSpace method, by adding more hidden layers to the NLU model and training an NLU Model for multi-intent classification. We used a 512x384x256x128 configuration for network A and a 384x128 configuration for network B.

Evaluation

In this section the evaluation results for the multi intent models and for both domains, energy and health, are presented. Prior to introducing the results of the evaluation, an assumption for miss-classification should be taken into consideration. Most of the miss-classification were of the type no-understand to inform. This miss-classification type is not a problem as it is handled by the dialogue model. We can classify orphan informs (that is informs that do not occur in the middle of the dialogue) as no-understands, whereas incorrect informs in the middle of a dialogue that do no match any of the valid dialogue flows generated by the generator presented in this paper are handled by the produced stories for invalid scenarios. So, if we consider this type of miss-classifications as correct our accuracy is increased (column Accuracy2 in Table 1). 1 presents the results of the multi-intent NLU model on the gold sets of the two domains. We have included various text patterns for these intents in the Chatito DSL and generated our training data for the NLU Models as we did not have access to enough real world user messages for these domains. Training our NLU Models on real-world data should provide a stronger model for these domains. To evaluate the dialogue generator we present examples of valid use cases. A user can phrase a command for the agent in various ways. Moreover, the agent can converse with the user if it recognizes an intent that information is missing. For example if the user commands the agent to "turn the lights", the agent will reply with either "where?" or "in which room?". If the user replies with a valid room (i.e., "In the kitchen") the agent will reply "Do you want them on or off?". If the user replies with either "on" or "off" the agent will execute the turn-lights action. A representative example of the generative process of the algorithm through the conversational flow between the agent and a user, as far as set temperature-single intent command are concerned:

-Active node = stands on an active state that has not fulfilled all requirements and is able to generate new scenarios -Final node = stands on a final state and cannot generate new scenarios A case example was used as part of the evaluation process. The example aims to demonstrate that the Novel Dialogue Generator of CIPA-gen A is able to produce all the possible use case scenarios in its conversation with a user by adopting the concept of adjacency pairs. In particular, in the presented example the agent requires information about the value of the temperature and the place (room). There are 4 initial cases: (a) the user defines the intent accompanied by the value or (b) the place or (c) both of them or (d) the case that the user inputs only the intent. In the next step of this discourse, the user can either provide valid information that fulfills a slot or provide an invalid input that is categorized in one of the 14 invalid operations in the sector of energy (lights, hvac, etc) including no-understand operation in the case of no relevant input. Every single invalid input in the Figure 1 diagram is translated to multiple alternative rejected scenarios. The node that contains value and place is a final node. On the contrary, the rest of the nodes need at least one more slot to be fulfilled in order to end up in a final state. In the same logic, every active node generates more complex scenarios until a final node is born. In this example, the set temperature intent generates 64 unique scenarios that cover all possible contingencies and they are illustrated from the colourful nodes in the Figure 1. Each node represents the given input from the user. Calculation of all possible generated scenarios in a multi intent command is a process identical to the single intent, differentiating only in the number of slots. Multi intents commands have as slots the union of the slots of two intents. So, for example in the set temperature lights intent that is responsible to set the temperature in a room and turn the lights, the available slots comprise the union of (value, place) from set temperature and lights on of f from light. The total number of generated scenarios are 281.

The evaluation of CIPA story generator was an experimental process that conducted through a comparison between the enumeration of all possible scenarios that can be generated from a dialogue among an agent and a user as illustrated in the Figure 1 and the actual scenarios that are generated from CIPA (Parsed data from the generated file and calculated the sum of generated scenarios for every intent). CIPA is evaluated as a competent agent that behaves properly covering all contingencies.

Conclusions & Future Work

In conclusion, this paper introduces a general purpose task-based agent, equipped with a novel dialogue generator, and it was applied to two domains of the CERTH nZEB Smart Home, energy and health domain. The developed CIPA-gen A is based on the RASA framework and supports multi-intent for the aforementioned domains capable of recognizing up to two intents per user command. Towards to a domain agnostic agent, the code-base was engineered so as to be easily applied to different domains. CIPA-gen A uses an embedding method for its NLU model that is not based on pre-trained word vectors of a specific language so as it can be generalized to any natural language. The training data should have to be generated for that language, using the tools selected and the algorithms developed, while omitting a dependency on SpaCy for slot extraction. This consists the only limitation on training a model for a different language. In addition, messages from real-world users should be collected in order to build a real usage data set that can be used for both training the model to achieve greater accuracy and for evaluation purposes. Furthermore, a novel dialogue generator, based on the idea of adjacency pairs, has been implemented in order to enable the proposed agent to generate all the possible scenarios in a conversation between the agent and a user.

Future research and development related to CIPA agent will be focused on the extension of the agent's capabilities. A first enhancement would be the replacement of the LSTM of the dialogue model with a differential neural computer (DNC) [START_REF] Graves | Hybrid computing using a neural network with dynamic external memory[END_REF]. Next releases of the agent will support complex objectives in its action model, i.e., the agent will be able to form a complex plan of action based on its conversation with the user and execute it and by utilizing AI Planning research [START_REF] Nau | Automated Planning: Theory & Practice[END_REF]. The new system will be the CERTH Advanced Multi-Domain Reasoning and Planning System (CAMDRaPS). This idea has been considered before by MIT researchers [START_REF] Yu | Towards personal assistants that can help users plan[END_REF] but it has not been developed yet. In general, it is planned to add an open-source classical planner, more advanced conversion model from intents/entities to planning actions/variables, machine learning techniques to improve classification of the domain, Probabilistic Planning and Probabilistic Reasoning over Time.

Fig. 1 .

 1 Fig. 1. Finite Automata of Story Generator Example

Table 1 .

 1 Evaluation Metrics

	Evaluation	Accuracy Accuracy2 Lowest Conf
	M-Intent (Energy) 98.39% 99%	0.53
	M-Intent (Health) 99.14% 99.75%	0.47
	Table

https://rasa.com/

https://smarthome.iti.gr/

https://ai.googleblog.com/2020/01/towards-conversational-agent-that-can.html

Acknowledgements

This project has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No 643607 (myAirCoach) & No 732679 (ACTIVAGE)


António João Silva
email: antonio.silva@ccg.pt

Paulo Cortez
email: pcortez@dsi.uminho.pt

A Two-stage Machine Learning System for Predicting the Arrival of Samples

Keywords: Automated Machine Learning, Industry 4.0, Regression

This paper presents a two-stage Machine Learning (ML) model to predict the arrival time of In-Process Control (IPC) samples at the quality testing laboratories of a chemical company. The model was developed using three iterations of the CRoss-Industry Standard Process for Data Mining (CRISP-DM) methodology, each focusing on a different regression approach. To reduce the ML analyst effort, an Automated Machine Learning (AutoML) was adopted during the modeling stage of CRISP-DM. The AutoML was set to select the best among six distinct state-of-the-art regression algorithms. Using recent real-world data, the three main regression approaches were compared, showing that the proposed two-stage ML model is competitive and provides interesting predictions to support the laboratory management decisions (e.g., preparation of testing instruments). In particular, the proposed method can accurately predict 70% of the examples under a tolerance of 4 time units.

Introduction

The Industry 4.0 concept assumes a high usage of Artificial Intelligence (AI), where industrial physical processes generate data that can be analyzed by Business Analytics, namely Data Mining (DM) and Machine Learning (ML) techniques, aiming to improve the factory efficiency (e.g., reduce costs, enhance production levels) [START_REF] Shrouf | Smart factories in industry 4.0: A review of the concept and of energy management approached in production based on the internet of things paradigm[END_REF]. This concept is transforming the Chemical industry, which has a large impact in the world economy (e.g., petrochemicals, pharmaceuticals).

In this work, we address a relevant Business Analytics need of a chemical company, which is adopting a Industry 4.0 transformation. To ensure the quality of the products being manufactured, samples taken from the company production processes need to be tested in laboratories. The tests assure that the products are compliant with quality standards, allowing their usage by the company clients. Under this context, predicting the arrival of production samples at the laboratory is a key issue, since it helps in the allocation of equipment and human resources. Aiming to solve this task, this paper presents a novel twostage ML prediction system, which was developed during the implementation of a CRoss-Industry Standard Process for DM (CRISP-DM) [START_REF] Wirth | Crisp-dm: Towards a standard process model for data mining[END_REF] project that included three iterations, each focusing on a distinct regression strategy. During the modeling stage of the three CRISP-DM iterations, an Automated ML (AutoML) [START_REF] Feurer | Efficient and robust automated machine learning[END_REF] procedure was adopted, allowing to compare and configure six state-of-the-art ML algorithms.

The paper is structured as follows. Section 2 describes the related work. The business task, data and proposed approach are presented in Section 3. The obtained results are shown in Section 4. Finally, Section 5 concludes the paper.

Related Work

In recent years, there has been an increased interest in the field of AI, due to the rise of data, computational power and sophisticated learning algorithms (e.g., Deep Learning) [START_REF] Darwiche | Human-level intelligence or animal-like abilities?[END_REF]. Following the Industry 4.0 revolution [START_REF] Shrouf | Smart factories in industry 4.0: A review of the concept and of energy management approached in production based on the internet of things paradigm[END_REF], many factories now are generating data that can be analyzed by DM and ML techniques in order to support managerial decision-making. Yet, several real-world DM projects tend to fail due to a misalignment between business needs and ML analyses [START_REF] Deal | The ten most common data mining business mistakes[END_REF]. The CRISP-DM is an open standard and robust methodology that was specifically developed to reduce this misalignment and increase the success of DM projects [START_REF] Wirth | Crisp-dm: Towards a standard process model for data mining[END_REF]. CRISP-DM includes six stages that are executed through several iterations and that involve both business and ML experts: business understanding, data understanding, data preparation, modeling, evaluation and deployment. CRISP-DM is a popular methodology. For instance, it has been applied to the Banking [START_REF] Moro | Using data mining for bank direct marketing: An application of the crisp-dm methodology[END_REF] and Health Care [START_REF] Caetano | Using data mining for prediction of hospital length of stay: An application of the CRISP-DM methodology[END_REF] domains.

Regarding the analyzed chemical industry, the quality testing laboratories are mostly managed manually, with the usage of Information Technology (IT) being more focused on storing the test values rather than the process [START_REF] Skobelev | Laboratory information management systems in the work of the analytic laboratory[END_REF][START_REF] Kammergruber | The future of the laboratory information system-what are the requirements for a powerful system for a laboratory data management[END_REF]. Moreover, the data is typically spread through different databases what work as information silos (e.g., production, laboratory testing), thus it is difficult to have an easy access to all data under a single version of the truth. By adopting the Industry 4.0 concept, which assumes a better usage of IT, there is a potential gain to optimize the management of the chemical laboratories. In this work, we describe one aspect of the Industry 4.0 transformation that is being conducted by a chemical company. It corresponds to the result of implementing a CRISP-DM project that uses both production and laboratory testing databases.

In terms of Predictive Analytics applied to the industry, most studies target predictive maintenance via several ML algorithms, such as Random Forest (RF) [4], Neural Networks (NN) [START_REF] Spendla | Concept of predictive maintenance of production systems in accordance with industry 4[END_REF] and Gradient Boosting Machines (GBM) [START_REF] Liulys | Machine learning application in predictive maintenance[END_REF]. There are also studies about non maintenance prediction applications, such as: the classification of quality products produced by injection molding processes via Boosting, RF and NN models [START_REF] Charest | Integration of artificial intelligence in an injection molding process for on-line process parameter adjustment[END_REF]; and estimation of endpoint temperature and chemical concentration of a furnace when producing low-carbon steel using RF and ridge regression algorithms [START_REF] Sala | Multivariate time series for data-driven endpoint prediction in the basic oxygen furnace[END_REF]. All these studies require the selection and configuration of the right ML algorithm, which often depends on the ML expert knowledge and that involves the usage of heuristics or trial-and-error experiments [START_REF] Gibert | Which method to use? an assessment of data mining methods in environmental data science[END_REF]. In order to avoid this time-consuming procedure (in terms of the ML expert effort), we adopt an AutoML [START_REF] Feurer | Efficient and robust automated machine learning[END_REF] during the modeling stage of the CRISP-DM. This systematization and automation the ML model selection provides two main advantages. First, it alleviates the effort of the ML analyst, allowing to focus on other ML aspects in order to provide a better business value. In particular, in this paper, it allowed to implement more iterations of the CRISP-DM methodology, which was helpful to design the proposed two-stage ML model. Second, it reduces the ML maintenance effort, since the ML can be retrained automatically, as new data arrives, which is advantageous for the analyzed company.

Materials and Methods

Business Task

The analyzed chemical company produces several products, in batches. During the production-batch execution process, a sequence of samples, called In-Process Control (IPC), are selected for quality laboratory inspection, in order to ensure that the production process is running as expected. In terms of the chemical laboratories, the IPC samples have the highest priority, because the production process can not continue without their approval. A fixed amount of IPC samples are selected from each production-batch (s ∈ {1, ..., IP C max }). The production information system registers several attributes related to the IPC sample production, including its initial production time, denoted here as IPC production time P T s . One by one, the IPC samples arrive at the laboratory at time LT s , under irregular intervals that are difficult to be estimated in advance.

The business goal is thus the non-trivial task of predicting of arrival time for each IPC sample at the chemical laboratories. Solving this task efficiently allows a better management of the laboratory equipment and human resources. For instance, some IPC quality tests require a setup time, in which the analysts need to prepare in advance the laboratory testing instruments. The business goal was addressed as a regression task, under two main target goals. In the first CRISP-DM iteration, we only used laboratory temporal data and the target goal was defined as predict y 1 = LT s+1 -LT s, which corresponds to the time lag between the next IPC sample arrival (LT s+1 ) and the current (already known) laboratory sample arrival (LT s ). In the second and third CRISP-DM iterations, we explored production temporal data, predicting y 2 = LT s -P T s , where the laboratory arrival time can be immediately estimated once the IPC sample starts its production.

Data Understanding and Preparation

We used an Extract, Transform, load (ETL) procedure to merge the relevant data from two main databases related with the production and laboratory testing information systems, populating an integrated and business oriented data warehouse system. The ETL resulted in a raw file with 226,929 rows and 33 columns regarding all laboratory samples that were analyzed during a threeyear time period. The data warehouse was further filtered in order to contain rows related with IPC samples and with complete values in terms of the input and output attributes (Table 1), leading to a dataset with 26,611 instances. The input variables were manually selected and defined from the filtered raw file using expert domain knowledge, obtained by interacting with the chemistry experts. Due the complexity of the chemical factory processes and information system integration issues, it was not possible to have access to a more richer set of data features (e.g., which components and machines were used to produce the samples). Thus, the resulting set of 8 inputs is rather small, which makes more challenging the prediction task. Both output targets were computed using a particular time unit, which is not disclosed here due to business privacy issues.

Machine Learning Models

In terms of computational environment, we adopted the R tool and its rminer package [START_REF] Cortez | Modern optimization with R[END_REF] for data manipulation and ML result evaluation, while the AutoML adopts the H2O implementation [START_REF] Cook | Practical machine learning with H2O: powerful, scalable techniques for deep learning and AI[END_REF]. The AutoML procedure was configured to select the regression model and its hyperparameters based on the best Root Mean Squared Error (RMSE) computed using a validation set that is obtained by applying an internal 10-fold cross-validation method over the training data. All computational experiments were executed on the same personal computer and each individual ML model was trained up to a maximum running time of 3,600 seconds. Once a ML model is selected, the model was retrained with all training data. As in [START_REF] Ferreira | An Automated and Distributed Machine Learning Framework for Telecommunications Risk Management[END_REF], the AutoML was configured to include a total of 6 distinct regression algorithms: RF, Extremely Randomized Trees (XRT), Generalized Linear Model (GLM), GBM, XGBoost (XG) and a Stacked Ensemble (SE). The RF is a popular ensemble method that combines a large number of decision trees based on bagging and random selection of input features [START_REF] Hastie | The elements of statistical learning: data mining, inference, and prediction[END_REF]. The XRT algorithm extends the RF approach by randomly selecting the decision thresholds of the tree nodes [START_REF] Geurts | Extremely randomized trees[END_REF]. GLM estimates regression models for exponential distributions (e.g., Gaussian, Poisson, gamma) [START_REF] Hastie | The elements of statistical learning: data mining, inference, and prediction[END_REF]. The GBM algorithm is a based on a generalization of tree boosting, sequentially building regression trees for all data features [START_REF] Hastie | The elements of statistical learning: data mining, inference, and prediction[END_REF]. XG is another ensemble tree method that uses boosting to enhance the prediction results [START_REF] Chen | Xgboost: A scalable tree boosting system[END_REF]. The SE method, also known as stacked regression [START_REF] Breiman | Stacked regressions[END_REF], combines the predictions of different base learners by using a second-level ML algorithm. The H2O implementation [START_REF] Cook | Practical machine learning with H2O: powerful, scalable techniques for deep learning and AI[END_REF] uses the following AutoML setup: RF and XRT -set with the default hyperparameters; GLM -grid search used to set one hyperparameter (alpha, a regularization parameter); GBM and XGgrid search used to tune nine and ten hyperparameters (e.g., number of trees, maximum depth, minimum rows); SE -all five algorithms (RF, XRT, GLM, GBM, XG) are used as base learners and the individual predictions are weighted by using a second-level GLM learner. For the ML algorithms that require numeric inputs (e.g., GLM), the nominal inputs (e.g., product, grade) are previously transformed by using the standard one-hot encoding, which assigns one boolean input per categorical level. For instance, a categorical feature with three levels ({a,b,c}) is encoded as: a =(1,0,0), b =(0,1,0) and c =(0,0,1).

A total of three CRISP-DM iterations were executed, aiming to improve the regression results and the potential value of the ML models. The first CRISP-DM iteration targeted the y 1 output, while the second and third CRISP-DM iterations approached y 2 , under two variants. The y 1 target is assumes that at least one IPC sample from the production-batch as arrived at the laboratory. The trained ML model can be used each time new sample arrives, allowing to estimate when the next sample will be delivered ( y 1 ). A different perspective is adopted by the y 2 target, since the fitted ML model can be applied to predict the laboratory sample arrival once an IPC sample production has started. The model employed in the second CRISP-DM iteration uses a simple regression with a single ML model ( y 2 ). During the evaluation stage of the second CRISP-DM iteration, we identified that there were some high prediction errors, in particular when predicting the arrival times for the first sample of the production-batch (s = 1). In order to check if we could improve these results, a third CRISP-DM iteration was executed, in which we specialize two distinct ML models (α and β). The first ML model (α) is trained using only the first product-batch sample examples (s = 1) and thus the fitted model includes only seven input attributes ({day, month, product, version, grade, stage,batch}). The second model (β) is only activated when producing the other product-batch IPC samples (s > 1). Similarly to the second CRISP-DM iteration model, this ML model is trained with all eight inputs (including s, the sample sequence number). The proposed two-stage model ( y 2αβ ) is shown in Fig. 1.

Evaluation

The collected data was divided into three main sets, by using a chronological order. The last 20 weeks of data (total of 5,110 examples) was kept out of the initial ML experiments. The goal is apply this additional unseen data in a more realistic evaluation, provided by a Rolling Window (RW) validation [START_REF] Tashman | Out-of-sample tests of forecasting accuracy: an analysis and review[END_REF] that is executed for the best ML regression approach. The remaining and oldest 21,501 examples (not used as test set by the RW) were further divided into training and test sets (holdout split) [START_REF] Schorfheide | On the use of holdout samples for model selection[END_REF]. The time ordered Holdout Split (HS) was used to compare the three distinct main regression approaches (from the CRISP-DM iterations). The training data included the oldest 15,050 examples (around 70%). As for the HS test set, it included 6,451 instances.

Regarding the RW, it was set using a fixed training window with six months of data and a weekly testing of the ML models, in a total of 20 iterations. In the first iteration, at the first Sunday, the ML was trained with the last six months of historical data. Then, the model was used to perform sample arrival predictions for the incoming week (fixed test size of seven days). In the second iteration, executed at the second Sunday, the training window was updated by discarding one week of the oldest data and adding the previous week examples, allowing to update (retrain) the ML model, which then predicted the next week sample arrival times, and so on.

In this work, we adopt two popular regression error measures: RMSE and Mean Absolute Error (MAE). We also use the Acc@T metric, which is more easily understood by the business analysts, since it measures the percentage of examples accurately predicted when assuming an absolute error tolerance of T . A quality regression model should provide low RMSE and MAE values and also a high accuracy for a small T value. The Acc@T concept allows to compare the predictive performance of different regression modes in a single graph, as proposed in [START_REF] Bi | Regression error characteristic curves[END_REF] with the Regression Error Characteristic (REC) curves, which plot in the y-axis the Acc@T for different T values (x-axis). The overall quality (for distinct T values) can be measured by computing the Area of REC (AREC) curve when assuming a maximum tolerance of T max (in %).

Results

Table 2 presents the test data errors, in terms of the RMSE error measure, for the HS evaluation and when comparing the two y 2 prediction strategies: y 2 , executed during the second CRISP-DM iteration; and y 2αβ , explored in the third CRISP-DM iteration. The RMSE values confirm that for both prediction strategies, it is more difficult to predict the arrival of the first IPC sample (s = 1) than the arrival of the remaining samples (s > 1). It is interesting to notice that by specializing a learning model for each of these IPC sample types, as executed in the third CRISP-DM iteration ( y 2αβ ), a substantial error reduction is achieved for both sample types (s = 1 and s > 1). The full comparison of the aggregated HS results, assuming all IPC samples, is shown in Table 3, which contains: the evaluation method used (Eval.); the best model selected using the AutoML procedure (Model); and several predictive performance measures. The AREC was computed by using a maximum tolerance of T max=16 time units. All performance measures confirm that the best predictive model was achieved by y 2αβ , while y 1 obtained better results than y 2 . When compared with y 1 , y 2αβ achieved a substantial predictive improvement: RMSEreduction of 46.8 points; MAE -difference of 14.1 points; and AREC -increase of 10 percentage points. As for the ML algorithms, the AutoML selected GBM and SE as the best performing models when using the 10-fold internal crossvalidation (applied over training data). The y 2αβ uses GBM for predicting the arrival times of the s = 1 samples and SE for the other ones. Fig. 2 complements the HS results by showing the respective REC curves for the three main regression approaches. The plot confirms that for most of the low tolerance range (x-axis), y 2αβ provides a higher classification accuracy, resulting in an overall higher AREC. Indeed, the proposed two-stage ML model can predict correctly 37%, 59% and 70% of the samples for low tolerance values of T = 1, T = 2 and T = 4, a value that increases to 85% when the tolerance is increased to T = 16 time units. To estimate how the selected model ( y 2αβ ) would behave in a real environment setting, we tested it under a RW evaluation. The results for all 20 week iterations are shown in terms of the last row of Table 3 and show consistency when compared with the HS evaluation. In effect, the same AREC value is achieved (71%), while the RMSE and MAE values are slightly lower (RMSE of 37.5 and MAE of 11.4). This is an interesting result, since the RW evaluation used more recent test data, not seen when comparing the HS results. The obtained results were presented to the business domain experts, which considered them very positive, encouraging the incorporation of the two-stage prediction model into a friendly dashboard that included several business indicators to support the laboratory management decisions. To facilitate the visualization, the dashboard was designed to provide different granularity levels (hourly, daily or monthly) for the sample arrival prediction. For demonstrative purposes, Fig. 3 plots the real and predicted values when assuming a daily aggregation of the IPC sample arrival for a particular chemical laboratory and for the entire RW testing time period. Due to business privacy issues, the scale of the y-axis is omitted from the graph. Fig. 3 shows that the predictions are very close to the real values, denoting a high quality fit of the prediction model.

Conclusions

This paper addresses the non-trivial task of predicting the arrival of In-Process Control (IPC) samples at chemical laboratories for quality testing. To solve this task, we implemented the CRoss-Industry Standard Process for Data Mining (CRISP-DM) methodology, under three iterations, each focusing on a different regression approach. During the data understanding and preparation CRISP-DM stages, we collected recent data from a chemical company, resulting in 26,611 sample arrival examples related with a three-year time period. As for the modeling stage of CRISP-DM, we employed an Automated Machine Learning (Au-toML) procedure, to automatically select and configure the best model when exploring six state-of-the-art ML algorithms. Several experiments were held. Using a time ordered Holdout Split (HS), we compared the three main regression approaches: y 1 -predict the time lag between the arrival of two consecutive samples (y 1 ), executed in the first CRISP-DM iteration; y 2 -predict the time lag between starting the production of the sample and its arrival to the laboratory (y 2 ), explored in the second CRISP-DM iteration; and y 2αβ -a two-stage ML model to predict y 2 , developed in the third CRISP-DM iteration. For all predictive performance measures, the best results were achieved at the two-stage ML model, which obtained interesting results (e.g., it can accurately predict 70% of the examples under a tolerance of T = 4 time units). The selected two-stage ML model ( y 2αβ ) was further evaluated using a realistic Rolling Window (RW) procedure, which considered 20 weeks of unseen data. A similar predictive performance was achieved, when compared with the HS results, showing that the proposed two-stage ML model is robust for the analyzed chemical company. In effect, the ML model was incorporated into a friendly dashboard prototype, obtaining a valuable feedback from the chemical laboratory managers.

In future work, we intend to apply the two-stage model to predict the arrival of other types of samples (e.g., raw material). Moreover, we intend to further explore the deployment stage of CRISP-DM, by better integrating the proposed model in a decision support system tool. For instance, by using the predictions to directly optimize the laboratory human resources and instruments.

Fig. 1 .

 1 Fig. 1. Schematic of the proposed two-stage ML prediction model ( y 2αβ ).

Fig. 2 .

 2 Fig. 2. Holdout REC curves for the three regression approaches.

Fig. 3 .

 3 Fig. 3. Daily sample arrival values and ŷ2αβ predictions for the rolling window test data.

Table 1 .

 1 Summary of the data attributes.

		Input Attributes:
	Name Description	Range
	day	day of the week when the production-batch started	{1,...,7}
	month month when the production-batch started	{1,...,12}
	product product type (nominal code)	155 levels
	version version of the product (numeric)	{1,...,108}
	grade product grade (nominal, related with the lab tests)	15 levels
	stage	product stage (nominal, related with the lab tests) 1,272 levels
	batch batch identification of the product (nominal)	925 levels
	s	sequence number of the sample (s ∈ {1, ..., IP Cmax}) {1,...,169}
		Output Targets:
	Name Description	Range
	y1	time lag arrival of two consecutive samples	[0.2,5315.3]
	y2	time lag between P Ts and LTs	[0.0,3270.0]

Table 2 .

 2 Test data holdout results for s = 1 and s > 1 IPC sample arrival (best values in bold).

		RMSE
	Approach s = 1 s > 1
	y2	209.9 188.9
	y 2αβ	124.8 41.3

Table 3 .

 3 Test data results (best HO values in bold).

	Acc@T

Acknowledgments

This work has been supported by FCT -Fundação para a Ciência e Tecnologia within the R&D Units Project Scope: UIDB/00319/2020. The authors also wish to thank the chemical company staff involved with this project for providing the data and also the valuable domain feedback.


Daniel Stamate

Richard Smith

Ruslan Tsygancov

Rostislav Vorobev

John Langham

Daniel Stahl

David Reeves

Applying Deep Learning to Predicting Dementia and Mild Cognitive Impairment

Keywords: Dementia prediction, Artificial Neural Networks, Deep Learning, Multi-Layer Perceptron, ConvBLSTM, ReliefF, SMOTE

Dementia has a large negative impact on the global healthcare and society. Diagnosis is rather challenging as there is no standardised test. The purpose of this paper is to conduct an analysis on ADNI data and determine its effectiveness for building classification models to differentiate the categories Cognitively Normal (CN), Mild Cognitive Impairment (MCI), and Dementia (DEM), based on tuning three Deep Learning models: two Multi-Layer Perceptron (MLP1 and MLP2) models and a Convolutional Bidirectional Long Short-Term Memory (ConvBLSTM) model. The results show that the MLP1 and MLP2 models accurately distinguish the DEM, MCI and CN classes, with accuracies as high as 0.86 (SD 0.01). The ConvBLSTM model was slightly less accurate but was explored in view of comparisons with the MLP models, and for future extensions of this work that will take advantage of time-related information. Although the performance of ConvBLSTM model was negatively impacted by a lack of visit code data, opportunities were identified for improvement, particularly in terms of pre-processing.

Introduction

Dementia is a loss of cognitive function. People with this condition have problems with socialization and with their daily lives. The disorder leads to damage or loss of memory, language skills, problem-solving, visual perception, self-management, and the reduced ability to pay attention and to focus. Some people with dementia cannot control their emotions, and their personalities may change. Alzheimer's disease accounts for 60% to 80% of cases of dementia [START_REF]Dementia[END_REF]. Worldwide, more than 47.5 million people suffer from dementia currently, and every year there are 7.7 million new cases. The proportion of the general population aged 60 and over with dementia is estimated to be between 5% and 8% [START_REF]Dementia[END_REF]. For comparison, dementia is currently more expensive in terms of health care and social assis-tance than cancer, stroke and chronic heart disease taken together [START_REF]Dementia[END_REF]. It is estimated that by 2030, the population with dementia will be approximately 75 million and this condition will cost society US$ 2 trillion [START_REF] Prince | The Global Impact of Dementia, An analysis of prevalence, incidence, cost and trends[END_REF]. There is no treatment at the present to cure dementia, however, the life of those patients can be supported and improved. The principal goals for dementia care are: providing information and long-term support to caregivers; optimising cognition, activity, physical health and well-being; detecting and treating behavioural and psychological symptoms; and early diagnosis. In terms of diagnosing dementia, the earlier a person receives a correct diagnosis, the sooner help can be provided. There is however a significant obstacle in diagnosing dementia because there is no standardized test for detecting it [START_REF] Barrett | Dementia Revealed. What Primary Care Needs to Know[END_REF]. On the other hand, current thinking suggests that 35% of cases of dementia could be prevented if personalized risk could be estimated in advance, helping early informed decisions by clinicians and patients. As such, in addition of efforts to improve dementia diagnosis, there is lately a particular focus of researchers also in developing approaches to predicting risk of dementia [START_REF] Robinson | Dementia: risk reduction[END_REF][START_REF] Walters | Predicting dementia risk in primary care: development and validation of the Dementia Risk Score using routinely collected data[END_REF][START_REF] Morgan | Can dementia risk be predicted using routine electronic health records?[END_REF].

This work proposes a machine learning approach to predicting dementia, in particular based on deep learning. The health care sector is one of the most important areas for machine learning applications. However, it is one of the most complex fields [START_REF] Panch | Artificial intelligence, machine learning and health systems[END_REF] and one of the most challenging, especially in the areas of diagnosis and prediction [START_REF] Yu | Artificial intelligence in healthcare[END_REF].

According to literature, there are hundreds of possible predictors for dementia, which can generally be categorized based on the following types of models: neuropsychological based models, health-based models, multifactorial models and genetic risk scores [START_REF] Robinson | Dementia: risk reduction[END_REF]. The applicability of these models spreads in multiple directions [START_REF] Stamate | A metabolite-based machine learning approach to diagnose Alzheimer's-type dementia in blood: Results from the European Medical Information Framework for Alzheimer's Disease biomarker discovery cohort[END_REF][START_REF] Amoroso | Brain structural connectivity atrophy in Alzheimer's disease[END_REF][START_REF] Walters | Predicting dementia risk in primary care: development and validation of the Dementia Risk Score using routinely collected data[END_REF]. The magnetic resonance imaging (MRI), in combination with multiplex neural networks, have been used to segregate healthy brains from progressive mild cognitive impairment (pMCI), based on the structural atrophy of the brain because of Alzheimer's disease [START_REF] Amoroso | Brain structural connectivity atrophy in Alzheimer's disease[END_REF]. Routine primary care patient records in UK have been and are currently used to develop a risk score for the purposes of estimating how at risk an individual may be of developing dementia, by using conventional statistical methods and modern machine learning algorithms [START_REF] Morgan | Can dementia risk be predicted using routine electronic health records?[END_REF][START_REF] Walters | Predicting dementia risk in primary care: development and validation of the Dementia Risk Score using routinely collected data[END_REF]. Positron emission tomography (PET) scans and the regional analysis of the protein amyloid-β, have been used by a Random Forest classifier to identify patients with age-related stable MCI and pMCI [START_REF] Brauser | Machine Learning' Tool May Predict Dementia Development Up to 10 Years Later[END_REF]. In a recent EMIF-AD study [START_REF] Stamate | A metabolite-based machine learning approach to diagnose Alzheimer's-type dementia in blood: Results from the European Medical Information Framework for Alzheimer's Disease biomarker discovery cohort[END_REF], a machine learning methodology based on Extreme Gradient Boosting XGBoost, Random Forest and Deep Learning, has been proposed for Alzheimer's based dementia diagnosis using metabolites in the blood which were proven by the study to be as accurate predictors as the widely accepted but invasive to measure cerebrospinal fluid (CSF) biomarkers.

The present work proposes a new approach to predicting dementia using Deep Learning based on the ADNI (Alzheimer's Disease Neuroimaging Initiative) data [START_REF] Adnimerge | ADNIMERGE: Alzheimer's Disease Neuroimaging Initiative[END_REF][START_REF]Alzheimer's Disease Neuroimaging Initiative[END_REF]. The ADNI dataset we use in this study contains the classes Cognitive Normal (CN), Mild Cognitive Impairment (MCI), and Dementia (DEM). Information gain and ReliefF methods [START_REF] Spolaôr | ReliefF for Multi-label Feature Selection[END_REF][START_REF] Kuhn | Applied Predictive Modeling[END_REF] were alternatively used for feature selection. The training, tuning and testing of the predictive models were performed with cross-validation using Deep Neural Network algorithms. The stability of model performances was studied using Monte Carlo simulations. In particular, this work explores the use of three Deep Learning models: two Deep Feedforward Networks which are Multi-Layer Perceptron models (MLP1 and MLP2), and a Convolutional Bidirectional Long Short-Term Memory (ConvBLSTM) model [START_REF] Shih-Chung | Artificial convolution neural network for medical image pattern recognition[END_REF][START_REF] Huang | Bidirectional LSTM-CRF Models for Sequence Tagging[END_REF]. Good prediction performances were obtained with MLP1 and MLP2 for dementia: the sensitivities were 0.87 (SD 0.03) and 0.77 (SD 0.01) and the specificities were 0.97 (SD 0.01) and 0.98 (SD 0.01), respectively. The ConvBLSTM model was slightly less accurate in this study but was explored in view of comparisons with the MLP models, and also for future extensions of this work that will take advantage of time-related information in the ADNI data by using the ConvBLSTM's capabilities exploiting such information.

The remaining of the paper is organised as follows. Section 2 introduces the ADNI data used in this study, and our approach of machine learning methodology based on feature selection, missing data and data imbalance treatments, and deep learning predictive modelling. The prediction results and model performance evaluation are presented in Section 3. Finally a discussion and conclusion section 4 ends the paper.

2

Data and methods

ADNI data repository

The Alzheimer's Disease Neuroimaging Initiative (ADNI) data repository was used for this work [START_REF]Alzheimer's Disease Neuroimaging Initiative[END_REF]. The ADNI study was launched in 2003 by the National Institute on Aging (NIA), the National Institute of Biomedical Imaging and Bioengineering (NIBIB), the Food and Drug Administration (FDA), private pharmaceutical companies and non-profit organizations as a $60 million dollar, 5-year, public-private partnership.

There are three main goals of the ADNI study: [START_REF]Dementia[END_REF] to detect Alzheimer's Disease (AD) at the earliest possible stage (pre-dementia) and identify ways to track the disease's progression with biomarkers; (2) to support advances in AD intervention, prevention and treatment through the application of new diagnostic methods at the earliest possible stages (when intervention may be most effective); and (3) to continually administer ADNI's innovative data-access policy, which make access to this data possible for scientists worldwide without any embargo.

The Dataset and the description of variables

The data used in this study was downloaded via the adnimerge R package [START_REF] Adnimerge | ADNIMERGE: Alzheimer's Disease Neuroimaging Initiative[END_REF], which merges together report forms and biomarkers from the ADNI subprojects ADNIGO, ADNI1, and ADNI2 [START_REF]Alzheimer's Disease Neuroimaging Initiative[END_REF]. The data consists of several different sources: clinical and genetic data, MRI data, PET data and some additional biospecimen. There is also longitudinal information as each participant in the ADNI dataset can have more than one screening visit. In this study we did not work with medical images directly, but used features that had been extracted from the data already. The variables extracted from the original dataset were as follows [START_REF]Alzheimer's Disease Neuroimaging Initiative[END_REF]: The resulting data contained 1851 participants and 51 input attributes, and one output attribute. 75% of data was used as training data and 25% was used as test data to evaluate the performance of the models.



Feature selection

To select a set of predictors, two feature selection methods were alternatively employed here. On one hand, we employed the Information Gain method and selected attributes scoring at least 0.01 [START_REF] Kuhn | Applied Predictive Modeling[END_REF]. One the other hand, we used ReliefF method [START_REF] Spolaôr | ReliefF for Multi-label Feature Selection[END_REF][START_REF] Kuhn | Applied Predictive Modeling[END_REF] which we chose to combine with a permutation test based on 500 random permutations of the labels. For instance, features with an observed Relief score corresponding to a distance of at least 1.96 standard deviations from the centre of the normal distribution built with the Relief scores, repeatedly calculated 500 times while labels were permuted randomly, were selected for further processing. This corresponds to the application of the statistical permutation test with significance level alpha=0.05. Fig. 1 illustrates the example of such a variable mPACCdigit.bl with an observed relief score of 0.38 which is far away from the centre of the distribution, which is an indication that the variable is predictive. The analysis in our study was performed by considering alternative values for the significance level, namely 0.05 and 0.1. However, here we report results obtained with the latter value, which involves a less stringent selection of features, so leads to a larger number of predictors. Table 1 illustrates the top 10 ranked features according to the two employed feature selection methods, Information Gain, and ReliefF combined with a permutation test, whose results seem to concord significantly. Due to lack of space, the predictive modelling results reported in this paper correspond to the second feature selection method only, i.e. ReliefF with permutation test, as this led to better prediction results. Note that mPACCdigit.bl predictor illustrated in Fig. 1 is ranked top by this feature selection method, as illustrated by Table 1. However, the downside of the ReliefF method combined with a permutation test in this study, is that it becomes computationally more expensive.

Missing value imputation

For the two MLP models MLP1 and MLP2, 2-dimensional datasets were used, which did not contain longitudinal information. We imputed each visit of a participant from their first visit in order to retain the relationship between different visits and so that the final dataset consisted of only one data instance for each participant. The ConvBLSTM model used 3-dimensional data, with longitudinal information provided via screening visit data. We replaced the date of each screening with the time difference between visits in order to include information about the sequence of visits as well as the interval between visits. The number of instances of visit codes decreases rapidly after the first visit so the GAIN imputation technique [START_REF] Yoon | GAIN: Missing Data Imputation using Generative Adversarial Nets[END_REF] was used to mitigate the lack of later visit data.

Balancing Classes

Large class imbalance has, most of the times, negative consequences on the performance of the predictive models, as machine learning algorithms tend to focus more on detecting the larger classes. The class distribution for our data is as follows: CN: 617, MCI: 886, Dementia: 348, which suggests that the minority class Dementia could be poorly detected by the predictive models in this case. This problem was mitigated using SMOTE algorithm (Synthetic Minority Over-sampling TEchnique) [START_REF] Qazi | Effect of Feature Selection, SMOTE and Under Sampling on Class Imbalance Classification[END_REF] which reduces class imbalance. SMOTE chooses a data point randomly from the minority class, determines the k nearest neighbours to that point and then uses these neighbours to generate new synthetic data points using interpolation. The synthetic data was added to the minority class to overcome the gap between the majority and minority classes in terms of number of instances. Our analysis used k=5 neighbours, as a default value. This technique is to be applied only on the training set as it shouldn't affect the distribution of classes in the test set in order to obtain unbiased estimates for the performance metrics on the test/ unseen data.

Tuning the Deep Learning models

Parameter values, such as learning rate, decay value and AMSGrad option of ADAM optimiser, for the models were optimised, using Tree of Parzen Estimators (TPE) optimisation algorithm from 'hyperopt' Python package. Models were then evaluated on the test set. Figures 2 and3 show the topologies of MLP1 and MLP2 optimised models, respectively, which used LeakyReLU activation functions in the hidden layers and a softmax activation function in the output layer. The models were tuned in a 10-fold cross validation using L1 and L2 regularizations, and the dropout regularization with probabilities 0.2 and 0.4, to prevent overfitting. The ConvBLSTM model used 3D data, imputed with a generalized GAIN model. The first layers of the model applied convolutional and pooling operations [START_REF] Shih-Chung | Artificial convolution neural network for medical image pattern recognition[END_REF], with a kernel that convolutes only operations across different dates for each of the features. Theoretically, this approach could have resulted in a loss of time information but this did not apply in our case because we had a different set of features for different visit codes. The approach also guaranteed that information was preserved for the most recent visit codes with a large proportion of missing values for most persons. Follow-ing the convolutional operations, we applied a bidirectional LSTM layer [START_REF] Huang | Bidirectional LSTM-CRF Models for Sequence Tagging[END_REF][START_REF] Gers | Learning to forget: continual prediction with LSTM[END_REF] because feature distribution helps preserve time information. After that, we applied a flatten operation to the data and sent the result to the final dense layer with softmax activation function, which gave us the probabilities for each target class (DEM, MCI, and CN). Figure 4 shows the topology of the ConvBLSTM model. The stability of well-performing models MLP1, MLP2 and ConvBLSTM was investigated using a Monte Carlo simulation consisting of 100 iterations of the models' tuning and evaluation. We remind that the models' tuning consisted of performing a grid search in a 10-fold cross-validation on the training set (75% of the data) for identifying the best hyperparameters' values. The following performance metrics were evaluated on the test set (25% of the data), and recorded with each Monte Carlo iteration: accuracy, Cohen's kappa statistic, sensitivity (with respect to each class) and specificity (with respect to each class). In addition, for each iteration we recorded the area under the curve (AUC) for each class versus the rest.

Hardware and software

The MLP1 model was implemented using Python on Tesla k80 GPU, together with a number of packages, including TensorFlow, Keras, hyperopt, scikit-learn, imbalanced-learn, numpy, pandas. The MLP2 model and the ConvBLSTM model were implemented with Python on Nvidia GTX 1070 Ti GPU under CUDA API. The same Python packages were used as for the MLP1 model, with the exception of Keras, which was used as part of the embedded tf.keras API from TensorFlow.

Prediction results

The performance results obtained on the test datasets in the Monte Carlo simulations for our predictive models are presented in this section.

In particular, Fig. 5 Numeric results for the performance metrics in the Monte Carlo simulations for the MLP models MLP1 and MLP2, are presented in Tables 2 and3, and those for the ConvBLSTM model are presented in Tables 4 and5. In particular the class-specific performances of the models for dementia, such as AUC, sensitivity and specificity, as well as the non-specific performances accuracy and kappa, are reflected in Tables 2 and4. The ReliefF algorithm was the method of choice here used for selecting the most informative features and was a better technique, in this case, in comparison to Information Gain; SMOTE was used to mitigate the large class imbalance in the data.

The ConvBLSTM model was chosen in order to preserve time information in the data. However, the performance of this model was impacted by the lack of visit code data. The GAIN imputation used to mitigate this was suboptimal as the training algorithm made random imputations of the mask layers and projected an initial data distribution on the matrix of data for each person, without considering any inherent differences between various datasets in the ADNI repository. A proposed enhancement for further work is to analyse missing value groups between different visit codes instances and to train the GAIN model for meaningfully different ADNI sub-project data groups, and not for the whole distribution.

The architecture of the neural network based models may be subject of further improvements in forthcoming work. In the case of the ConvBLSTM model, we experimented with a different shape for convolutional operations, so that it would transform participant matrices feature-wise and not time-wise, but this did not lead to a good convergence. An improvement could be to use the convolution operation separately, and apply the transfer learning technique from our already trained model with different convolution operations while freezing the original layers. This would result in a model graph with two different convolution branches and two different bidirectional LSTM layers that would be multiplied before the final dense layer [START_REF] Yildirim | A novel wavelet sequence based on deep bidirectional LSTM network model for ECG signal classification[END_REF].

The magnetic resonance imaging, positron emission tomography and genetic data in the ADNI dataset were only available in numeric and categorical format, and were not as raw images in this study. This meant that the potential power of Convolutional Neural Networks (CNNs) to classify image data was not explored here.

All of the models were able to recognize patterns differentiating the three classes DEM (Dementia), MCI (Minor Cognitive Impairment) and CN (Cognitive Normal), which indicates that each of these machine learning approaches has the capacity to accurately predict dementia and mild cognitive impairment.

Potential directions for further exploration include: (1) improving the modelling of time-based associations, with GAIN imputation to mitigate the sparseness in data for recent visits; (2) exploring other neural network model architectures, such as separating the convolution operation; and (3) applying CNNs to raw image data as these are likely to provide better performance for image classification. With these enhancements it is envisaged that individualized dementia-risk scores will be created and time information will be modelled more effectively.

  Our target label consisted of three different classes: Cognitive Normal (CN), Mild Cognitive Impairment (MCI) and Dementia (DEM). The original data comprised 113 variables and 13,272 observations (visits), with multiple observations per participant.

Fig. 1 .

 1 Fig. 1. mPACCdigit.bl variable with an observed relief score of 0.38 which is far away from the centre of the distribution, is considered predictive.

Fig. 2 .

 2 Fig. 2. MLP1: Multilayer perceptron model 1.

Fig. 3 .

 3 Fig. 3. MLP2: Multilayer perceptron model 2.

Fig. 4 .

 4 Fig. 4. ConvBLSTM: the Convolutional Bidirectional Long Short-Term Memory model

Fig. 5 .

 5 Fig. 5. Monte Carlo: ROC AUC boxplots for Mild Cognitive Impairment (left), Dementia (cetre) and Cognitive Normal (right).

  Baselines Demographics: age, gender, ethnicity, race, marital status, and education level were included as predictors.  Functional Activities Questionnaire (FAQ) is a test that can be used to assess the dependency on another person that a participant requires to carry out normal daily tasks.  Mini-Mental State Exam (MMSE) is used to estimate the severity and progression of cognitive impairment and to follow the course of cognitive changes in an individual over time.  PET measurements (FDG, PIB, AV45) are participants' brain function measurements.  MRI measurements (Hippocampus, intracranial volume (ICV), MidTemp, Fusiform, Ventricles, Entorhinal and WholeBrain) are structural measurements of participants' brain.  APOE4 is an integer measurement representing the appearance of epsilon 4 allele of the APOE gene.  ABETA, TAU, PTAU are cerebrospinal fluid (CSF) biomarker measurements.

 Rey's Auditory Verbal Learning Test (RAVLT) are neurophysiological tests evaluating an individual's episodic memory.  Everyday cognitive evaluations (Ecog) are questionnaires that illustrates a participant's ability to carry out everyday tasks.  Logical Memory -Delayed Recall Total Number of Story Units Recalled (LDELTOTAL) is a neuropsychological test that evaluates a person's ability to recall information after a prescribed amount of time.  Modified Preclinical Alzheimer Cognitive Composite (mPACC) are tests that evaluate a person's cognition, episodic memory and timed executive function.  ADAS and MOCA are generalized neuropsychological tests that evaluate a person's cognitive ability (e.g. memory, visuospatial, etc.).

Table 1 :

 1 Top 10 features selected with ReliefF and Information gain methods.

	Rank	ReliefF	Information gain
	1	mPACCdigit.bl	LDELTOTAL.bl
	2	mPACCtrailsB.bl	mPACCdigit.bl
	3	LDELTOTAL.bl	mPACCtrailsB.bl
	4	ADAS13.bl	MMSE.bl
	5	FAQ.bl	FAQ.bl
	6	MMSE.bl	ADAS13.bl
	7	ADAS11.bl	EcogSPTotal.bl
	8	EcogSPTotal.bl	ADASQ4.bl
	9	EcogSPMem.bl	ADAS11.bl
	10	EcogSPPlan.bl	EcogSPMem.bl

Table 1 .

 1 Monte Carlo: Accuracy and kappa statistic for all 3 classes (DEM, MCI, CN), and AUC, sensitivity and specificity of Dementia vs all other classes -MLP1 and MLP2

	Model	ACC	KAPPA	AUCDEM	SENSDEM	SPECDEM
	MLP 1	0.86	0.78	0.92	0.87	0.97
		SD 0.01	SD 0.01	SD 0.01	SD 0.03	SD 0.01
	MLP 2	0.85	0.76	0.87	0.77	0.98
		SD 0.01	SD 0.01	SD 0.01	SD 0.01	SD 0.01

Table 2 .

 2 Monte Carlo: Sensitivity and specificity of MCI vs all other classes, and of CN vs all other classes respectively -for MLP1 and MLP2 models.

	Model	SENSMCI	SPECMCI	SENSCN	SPECCN
	MLP 1	0.86	0.87	0.94	0.87
		SD 0.03	SD 0.03	SD 0.02	SD 0.04
	MLP 2	0.88	0.83	0.87	0.94
		SD 0.01	SD 0.01	SD 0.01	SD 0.01

Table 3 .

 3 Monte Carlo: Accuracy and kappa statistic for all 3 classes (DEM, MCI, CN), and AUC, sensitivity and specificity of Dementia vs all other classes -for the ConvBLSTM model

	Model	ACC	KAPPA	AUCDEM	SENSDEM	SPECDEM
	Conv-BLSTM (GAIN)	0.82	0.72	0.90	0.86	0.94
		SD 0.01	SD 0.01	SD 0.01	SD 0.01	SD 0.01
	Conv-BLSTM (SMOTE)	0.82	0.71	0.91	0.88	0.93
		SD 0.02	SD 0.03	SD 0.01	SD 0.01	SD 0.01

Table 4 .

 4 Monte Carlo: Sensitivity and specificity of MCI vs all other classes, and of CN vs all other classes respectively -for the ConvBLSTM model

		Model	SENSMCI	SPECMCI	SENSCN	SPECCN
		Conv-BLSTM (GAIN)	0.69	0.86	0.84	0.94
			SD 0.04	SD 0.01	SD 0.03	SD 0.02
		Conv-BLSTM (SMOTE)	0.66	0.88	0.87	0.91
			SD 0.04	SD 0.01	SD 0.03	SD 0.03
	4	Discussion and conclusion
	Deep Learning requires more sophisticated data pre-processing and feature engineer-
	ing, as well as much more computational time for training a single model in compari-
	son to statistical implementations. The three Deep Learning models explored here
	were based on two different Deep Feedforward Networks which are Multi-Layer Per-
	ceptron (MLP) models, and one Convolutional Bidirectional Long Short-Term
	Memory (ConvBLSTM) model.