The defect is an error state, which is not according to the requirement of the given software. The error in the software system can affect the efficiency and reliability of the software therefore, early prediction of software defects can save the companies from a bigger loss. For this purpose, multiple algorithms have been proposed in the past decade. Still, the accuracy achieved is not suitable for the market demand which means that a lot of improvement needs to be done. In this paper, we have proposed an efficient and reliable framework for the prediction of the software defects. The framework is divided into three main steps which involves data preprocessing steps that includes: removal of noise and normalization. After that, feature extraction is done using correlation-based analysis and relevant features are selected, and finally applies machine learning models including naive Bayes and linear regression. Results show that the proposed method can reach an accuracy of 98.7% using Naive Bayes algorithm. Consequently, the significance of the proposed technique is that it will lower the cost of maintenance and reduce the code complexity by predicting the defects earlier in the software systems that will help the developers to remove those defects and ultimately improves the software quality before the deployment phase.