# Analyzing Student Behavioral Patterns in MOOCs Using Hidden Markov Models in Distance Education
## 2 Materials and Methods  
In this study, we extend the work of [2; 32; 33; 34] on behavioral pattern mining. Specifically, Ref. [32] uses association rules with the Apriori algorithm to model the socialization of the students in a distance learning course. The dataset used in the current work is sourced from Kaggle and pertains to the dataset described in [35]. It includes data from a MOOC with 4037 students. The dataset was deposited on Kaggle by a researcher from Riga Technical University, Latvia, who specializes in material science ([[https://www.kaggle.com/datasets/martinsseniders/moodle-grades-and-action-logs](https://www.kaggle.com/datasets/martinsseniders/moodle-grades-and-action-logs)]([https://www.kaggle.com/datasets/martinsseniders/moodle-grades-and-action-logs](https://www.kaggle.com/datasets/martinsseniders/moodle-grades-and-action-logs)), accessed 1 November 2023). We employ the Baum-Welch algorithm to train HMMs, aiming to predict student behavior based on the provided data. This approach focuses on identifying the most probable combinations of states. For the observed data, we have used the grades provided in the data set (0, 4, 5, 6, 7, 8, 9, 10). For the hidden data, we have considered significant states related to student interactions in Moodle, including forum_discussion_viewed, forum_post_created, forum_post_deleted, forum_post_updated, quiz_attempt_started, quiz_attempt_submitted, wiki_comment_created, wiki_comments_viewed and wiki_page_viewed. We regard forums, wikis, and quizzes as the key resources of interest. Some limitations of the dataset are the following. It lacks demographic elements. While the creation time of each activity is provided, we do not consider time in our methodology. Instead, we have adopted a sequence of IDs and the corresponding Moodle states, and the final grades in our 2-layer Hidden Markov Model. We have assumed that the states that we have defined are the most time-consuming resources, which justifies ignoring time in our analysis. Although other states not considered in the model may consume more time, they may not reflect the true dedication to the course. Additionally, only the time of resource creation is available, while the actual time students spend on these resources is not recorded in the log files. We use the R 4.2.0 packages \"HMM\", \"markovchain\", \"igraph\". The experiments were performed in a standard processor, with sufficient memory in a satisfactory time, and the analysis was completed in a satisfactory time despite the large size of the dataset. This makes the implementation relatively straightforward. Therefore, it is easy to implement. The key algorithm parameters include the number of hidden and observed states, the transition and emission probability matrixes, and the initial state distribution. We have trained the model with the Baum-Welch algorithm and the Expectation Maximization algorithm to estimate HMM parameters. The decoding algorithm is Viterbi, which identifies the most likely sequence of hidden states, while the Forward-Backward algorithm computes the probabilities of states and observations for parameter estimation. For hyperparameter selection, we used a 2-layer Hidden Markov Model with 4037 records. We have cleaned the dataset so that it retains only the required records. We decided not to apply cross-validation due to the sequential nature of the data. The sequence consists of two layers, and there is no reason to train multiple independent sequences as proposed in [36]. Observed states are considered the grades and the hidden are the significant states of the MOOC. We have determined the significance by the natural impact of each state and not the statistical significance. In other scenarios, such as speech recognition, where many sequences are presented, the cross-validation in HMMs is efficient. However, in the context of MOOCs, there is no need to create HMMs with more than two layers due to the nature of the educational problem at hand.