The earthquake early warning algorithm measures the energy of the P‐wave coda on the vertical component in the period to make a magnitude threshold estimation. The algorithm is based on two parameters: the logarithm of the peak ground acceleration, and the logarithmic cumulative acceleration . The model is built using a learning algorithm that iteratively parameterizes the linear fit of and to in segments. Training datasets were based on 324 accelerograms from 101 earthquakes () in the Mexican subduction zone from 1985 to 2013. The algorithm is supervised to avoid outliers in the data. The process results in a family of linear equations parameterizing the observations to magnitude calibrated to the observed . The algorithm was successfully tested using a dataset of 28 earthquakes in the Mexican subduction zone, from 2014 to 2017. The performance of algorithm was tested as a warning tool using 89 earthquakes in the Mexican subduction zone from 1985 to 2017, that met the criterion of having at least two stations within 70 km from the epicenter. The results show that 79 were correctly screened. The magnitude of six events was overestimated and four were underestimated. These earthquakes had an unfavorable station distribution. The 6 South Napa, California, earthquake of 24 August 2014 was used also as a test case. The two closest stations identified it as within 2 s after the arrival of the P phase. This resulted in a lead time of 10 s in Berkeley and 12 s in San Francisco, prior to the arrival of the S waves. Thus, the algorithm proves to be a reliable tool for seismic early warning where hypocenters are close to the target cities.