## 4 Analysis and Results
### Results Based on Confusion Matrix  
Customer churn is a critical issue for telecom companies, as it can significantly impact their revenue and profitability. Therefore, accurate prediction of customer churn is an important task in the industry. This study applied five different ML algorithms to predict customer churn in the telecom industry, including Logistic Regression, KNN model, Naive Bayes, Decision Tree, and Random Forest. Their performance was first evaluated using a Confusion Matrix, which consisted of values of true negatives (_TN_) and true positives (_TP_), false negatives (_FN_) and false positives (_FP_). As stated in Section 3.4.1, _TN_s are cases where the actual negative is also predicted to be negative, while _TP_s are cases where the actual positive is also predicted to be positive. _FN_s are cases that are positive but predicted to be negative, while _FP_s are cases that are actually negative but predicted to be positive. See Figure 5.  
Figure 4: Heatmap of Correlation Matrix. Figure 3: Bar plot for customer churn distribution. A clustered bar chart was drawn to illustrate the performance of these algorithms in terms of these four metrics. Random Forest appeared to have the highest number of TP and _TN_ and the lowest number of _FN_ and _FP_, indicating that it may be the best-performing model of the five. It can be observed that 641 customers from the test dataset are correctly classified as non-churner, 109 of the customers who are non-churners are incorrectly classified as churners, 88 of the customers that are churners are misclassified as non-churners, and 670 of the customers are classified correctly as churners. The prediction accuracy of the Random Forest algorithm was computed to be equal to 0.8694. This implies that 86.94% of the customers are correctly classified by the Random Forest model. Random Forest is effective in identifying both customers at risk of churn (_TP_) and those unlikely to churn (_TN_), while avoiding misclassification of non-churning customers, which can lead to customer dissatisfaction, or churning customers as non-churning and missed opportunities to take action to retain them, leading to loss of profit. In terms of the _TP_ metric, Decision Tree was the second-best choice after Random Forest, indicating that it was excellent at identifying customers at risk of churn (_TP_: 614). However, its relatively lower _TN_ values of 593 compared to the other algorithms indicate that it performs poorly in identifying non-churning customers. Furthermore, its relatively low _FN_ values (144) and high _FP_ values (157) confirm that the Decision Tree has a tendency to classify customers as those at risk of churn. Therefore, telecom companies may want to carefully assess the accuracy of the algorithm's positive predictions before taking any retention action. Naive Bayes and Logistic Regression performed similarly with moderate levels of performance, with high numbers of true negatives (TNNB: 617; TNLR: 555) and true positives (TPNB: 587; TPLR: 584) as well as high numbers of false negatives (FNNB: 171; FNLR: 174) and false positives (FPNB: 133; FPLR: 195). This suggests that these algorithms can effectively identify customers who are likely to churn (_TP_) and those who are unlikely to churn (_TN_), but it may also misclassify some customers as either those who will not churn (_FN_) or those who will churn (_FP_). The KNN model is the worst performer of all the algorithms. Although it performs well in identifying non-churning customers, as evidenced by the high number of _TN_s (635 customers), it performs rather poorly in identifying customers at risk of churning (_TP_: 440 customers). In addition, it has a high number of _FN_ (318 customers) and a relatively low number of _FP_ (115 customers) compared to the other models, which could indicate a tendency to misclassify positive instances (i.e., customers who will churn) as negative  
Figure 5: Confusion Matrix values for the five algorithms. (i.e., customers who will not churn).