# Towards a Machine Learning Model for Detection of Dementia Using Lifestyle Parameters
## 2 Materials and Method
### Work Plan
#### 2.3.4 Choice of Machine Learning Method  
The purpose of our study was not limited to the creation of a classification model of dementia based on data. We also needed information about how the model decides the onset of dementia. A large part of that process is understanding which parameter(s) have the greatest impact on the decision-making of the model. We chose the random forest algorithm for this purpose as it not only gives a classification model but also the relative importance of parameters for the model (unlike artificial neural networks, whose processing functions are a form of 'black box'). To understand random forest algorithm, we need to discuss one of its critical components, the decision tree.  
The decision tree algorithm is a machine learning method that constructs a hierarchical model resembling a tree to facilitate decision-making or prediction. It operates by iteratively dividing the dataset into smaller subsets, using the most informative features, creating a tree structure in which each internal node signifies a decision based on a feature and each leaf node signifies an outcome or prediction.  
Random forest is an ensemble machine learning technique that enhances predictive accuracy while mitigating overfitting by amalgamating multiple decision trees. The algorithm accomplishes this by training numerous decision trees on random subsets of the dataset and then combining their predictions. Each individual tree in the forest makes its  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Parameter Name** & **Description** \\ \hline cg9 clkdraw & Clock drawing capability \\ sn9 dnumsn & Total people that the subject trusts \\ hc9 depresan1 & Little interest or pleasure \\ wb9 aggwrstmt1 & Perception of control of one’s own life \\ cg9 presidna2 & Ability to recall the last name of the president \\ mo9 douthelp & Needs help moving outside house \\ te9 cellphone & Use of cell phone \\ cg9 presidna4 & Ability to recall the first name of the president \\ pa9 outfrenjy & Enjoys an outing with friends \\ sc9 bathlp & Needs help while bathing \\ sc9 drekslp & Needs help while dressing \\ mo9 insdhlp & Needs help moving inside the house \\ cg9 probreca3 & Problems recalling date \\ Cg9 probreca5 & Problems recalling month \\ \hline \hline \end{tabular}
\end{table}
Table 10: List of final parameters.  
prediction independently, and the ultimate output is determined via a majority vote (in the case of classification) or an averaging process (for regression) [31].  
We also designed a second model using an artificial neural network. We used this secondary technique to check whether the accuracy of our random forest model was comparable to it. As mentioned earlier, ANNs being black boxes, we would not get any insights regarding the importance and impact of input parameters.  
We randomly split the data into 80% for training and 20% for testing. We then applied the following algorithms to the data:  
1. random forest
2. neural networks  
The data was analysed using Python 3.0 using packages TensorFlow and sklearn. We applied 5-fold cross-validation for model validation.  
The random forest algorithm also has the additional benefit of inferring the relative ranking of parameter's impact on the onset of dementia. We used 100 estimators for random forest [32].  
For neural networks, the input shape indicated the number of parameters we were testing. The configuration of Neural Network is highlighted in Table 11.  
This architecture is typically referred to as a feedforward neural network or a multi-layer perceptron (MLP). It is a type of artificial neural network where information flows in one direction from the input layer through one or more hidden layers (in our case, 2 hidden layers with 16 neurons each), and finally to the output layer (with 1 neuron and sigmoid activation) [33].  
We used the 'Adam' optimizer for the neural model for faster convergence towards minima. We used sigmoid as an activation function for the output layer as it is best suited for binary classification [34].