# Understanding and Predicting the Usage of Shared Electric Scooter Services on University Campuses
## 3 Methodology
### Feature Selection  
Feature selection is an option in statistics to detect significant factors that use measures of confidence intervals as well as hypothesis testing. After conducting model evaluation, the elements (independent variables) must be examined further to see how they lead to measurement accuracy. Hence, machine learning algorithms are built-in with the feature selection technique to analyze the variables or features in the input data. The distribution of these features contributes to the prediction of the final outcome using machine learning models. Feature selection helps to understand the model better by focusing only on the important variables. This statistical technique eliminates variables which are insignificant or highly correlated with any other variable. Based on significance score, the order of variables can be illustrated to realize the accuracy of prediction. The reliability of important variables depends on the accuracy of a specific algorithm. The objectives of feature selection in machine learning are to reduce the complexity of the mode and to promote the performance of the model. Feature selection evaluates the relationship between the input variables and target variable.  
The supervised and unsupervised feature selection methods vary considering the target variables. While the supervised learning model requires a target variable to specify the important variables, the unsupervised learning model disregards the target variable and chooses important variables using correlation. Figure 2 shows the study methodology workflow.  
Clustering  
The unsupervised learning model clusters the input variables based on correlation between each other, and without considering the target variable. The important variables obtained from the random forest feature selection are used to perform clustering. There are two steps in clustering: (a) determination of the optimal number of clusters, and (b) hierarchical clustering.  
To determine the optimal number of clusters:  
The optimal number of clusters is specified using the Gap Statistics method. The _fuz_nolclust()_ function in _factoextra_ R package is employed to compute the optimal number of clusters. The Gap Statistics algorithm works as follows [53]:  
* The observed data of 1000 samples with \(n\) variables is analyzed by changing the number of clusters from \(k=1,\ \ldots,\ k_{max}\), and the total within intra-cluster variation \(W_{k}\) is computed.
* \(B\) reference datasets with a random uniform distribution is generated. Each reference dataset is clustered with varied number of clusters \(k=1,\ \ldots,\ k_{max}\), and the corresponding total within intra-cluster variation \(W_{kb}\) is computed.
* The estimated gap statistic is computed as the deviation of the observed \(W_{k}\) value from its expected value, \(W_{kb}\) under the null hypothesis: \(\textit{Gap}(k)=1B\sum b=1 Blog(W*kb)\ -\ log(Wk)\). The standard deviation of the statistics is also computed.
* The number of clusters is chosen as the smallest value of \(k\) such that the gap statistic is within one standard deviation of the gap at \(k+1\): \(\textit{Gap}(k)\geq\textit{Gap}(k+1)\ -sk+1\).  
The optimal number of clusters is used to perform hierarchical clustering using the _hclust_ R package. Hierarchical clustering is an agglomerative clustering algorithm, which can be cut at a chosen height to produce the desired number of clusters [54; 55]. The clusters produced in a dendrogram are joined together in order of their closeness measured by dissimilarity. The steps of hierarchical clustering are as follows:  
* Divide \(n\) variables into \(k\) groups by cutting at a desired similarity level.
* Calculate the dissimilarity matrix between variables using function _dist ()_ in _hclust_ package.
* Plot the dendrogram using _fuz_dend ()_ function in _factoextra_ package with dissimilarity matrix as the input.  
Correlation analysis is performed using R _corplot_ function to assess the relationship between the variables.