Code refactoring is the modification of structure with out altering its functionality. The refactoring task is critical for enhancing the qualities for non-functional attributes, such as efficiency, understandability, reusability, and flexibility. Our research aims to build an optimized model for refactoring prediction at the method level with 7 ensemble techniques and verities of SMOTE techniques. This research has considered 5 open source java projects to investigate the accuracy of our anticipated model, which forecasts refactoring applicants by the use of ensemble techniques (BAG-KNN, BAG-DT, BAG-LOGR, ADABST, EXTC, RANF, GRDBST). Data imbalance issues are handled using 3 sampling techniques (SMOTE, BLSMOTE, SVSMOTE) to improve refactoring prediction efficiency and also focused all features and significant features. The mean accuracy of the classifiers like BAG- DT is 99.53% ,RANF is 99.55%, and EXTC is 99.59. The mean accuracy of the BLSMOTE is 97.21%. The performance of classifiers and sampling techniques are shown in terms of the box-plot diagram.