The accurate identification of drilling conditions is pivotal for optimizing drilling operations. Detailed condition identification enables refined management of the drilling process, facilitates the detection of non-productive time (NPT), and offers actionable insights to improve drilling performance. In this study, a novel predictive model is presented that integrates the Kepler optimization algorithm (KOA) with random forest (RF) for detailed drilling condition identification. This method enhances the granularity of the operation differentiation and improves the classification accuracy. A systematic comparison of various classification algorithms reveals the superior performance of the RF algorithm in accurately identifying drilling conditions. The incorporation of the KOA allows for the refinement of the hyperparameter randomness and for iterative optimization of the RF model’s initial weights and thresholds, leading to optimal classification results. Case studies demonstrate that three predictive models were trained and evaluated. Validation results show that the KOA-RF model achieves an accuracy of 95.65%. To demonstrate the practical applicability of this methodology in enhancing rig efficiency. The KOA-RF algorithm proposed in this study for detailed drilling condition identification can be programmed into software to enable automated, real-time, and intelligent identification of drilling conditions on-site. Key performance indicator (KPI) analysis can be performed based on the identification results, thereby identifying the sources of NPT, optimizing the drilling process, and improving drilling efficiency. In this study, the KOA-RF model achieves detailed drilling condition identification with high accuracy, providing both theoretical contributions and practical value for real-time drilling optimization.