Suppression or mitigation of edge-localized mode (ELM) crashes is necessary for ITER. The strategy to suppress all the ELM crashes by the resonant magnetic perturbation (RMP) should be applied as soon as the first low-to-high confinement (L–H) transition occurs. A control algorithm based on real-time machine learning (ML) enables such an approach: it classifies the H-mode transition and the ELMy phase in real-time and automatically applies the preemptive RMP. This paper reports the algorithm design, which is now implemented in the KSTAR plasma-control system, and the corresponding experimental demonstration of typical high-δ KSTAR H-mode plasmas. As a result, all initial ELM crashes are suppressed with an acceptable safety factor at the edge (q 95) and with RMP field adjustment. Moreover, the ML-driven ELM crash suppression discharges remain stable without further degradation due to the regularization of the plasma pedestal.