Software defects can be costly to fix and can lead to reduced system reliability, decreased user satisfaction, and increased development time. To mitigate these risks, software defect prediction techniques have been proposed to identify potentially problematic areas of code before defects occur. In this paper, we propose an effective method to detect software flaws using the Naive Bayes classifier. We used a publicly available dataset for our study and performed preprocessing steps such as removing duplicate records and missing values. We splitted the data into training and testing and trained a Naive Bayes classifier on training. We evaluated the performance of our approach using precision, recall, and F1 score metrics. Our results demonstrate that the Naive Bayes classifier was effective in detecting software defects, achieving an accuracy of 98.16% on the testing set and area under ROC curve of 0.965. These findings suggest that the Naive Bayes classifier could be a valuable tool for software defect prediction and could help practitioners and researchers improve the quality of software systems.