# Comparing Commit Messages and Source Code Metrics for the Prediction Refactoring Activities
## 3 Research Methodology and Conduction  
### Approach Overview  
Refactoring is necessary for improving software quality, and developers often perform refactoring to maintain their software systems, add new features, and fix problems with existing ones. While performing these changes, it is quite difficult to identify the correct refactoring. The methods described in this paper can help developers and maintenance teams to decide necessary refactoring for their software. We have implemented multiple machine learning models to predict the correct refactoring type based on the commits of project and code metrics. Our approach will also help the development team to decide if any commit is unusual. Detecting anomalies in commits was necessary since we are in the era of the open source community. The models built for this study are based on two approaches: commit message based and code metrics based. After performing some initial analyses, we found that code metrics based models were producing better accuracy than compared to the commit messages since code metrics are the key factors in deciding cohesion, coupling, and complexity of refactoring class. The following section will discuss the methodology we followed to collect the data, to preprocess it, and the methods used to build various ML models. As depicted in Figure 1, we followed a commit classification approach similar to [23; 24; 44]. As an illustrative example, Figure 2 details a commit for which its message states the relocation of the method _classFor(asmType)_ to an internal class utility class for the purpose of applying the single responsibility principle and code reusability link to the commit: [[https://github.com/modelmapper/modelmapper/commit/6796071](https://github.com/modelmapper/modelmapper/commit/6796071) fc6 ad98150b6 afaf654c8200164977 aa4]([https://github.com/modelmapper/modelmapper/commit/6796071](https://github.com/modelmapper/modelmapper/commit/6796071) fc6 ad98150b6 afaf654c8200164977 aa4) (accessed on 20 September 2021). After running Refactoring Miner, we detected the existence of a _Move method_ refactoring from the class _ExplicitMappingVisitor_ to the class _Types_. The detected refactoring matches the description of the commit message and provides more insights about the old placement of the method. In a nutshell, the goal of our work is to automatically predict refactoring activity from commit messages and code metrics. In the data collection layer, we collected commits for projects from GitHub with web crawling for every project, and we prepared csv files with project commits and code metrics for further machine learning analysis. After this initial collection process, data were preprocessed to remove noise for model building. Extracting features helped us achieve results. Since we were dealing with text data, it was necessary to convert it with useful feature engineering. Preprocessed data with useful features were used for training various supervised learning models. We split our analysis into two parts based on our initial experiments. Only commit messages were not quite robust for predicting the refactoring type; thus, we tried to use code metrics. The following section will briefly describe the procedure used to build models with these three inputs.