The CALICE Semi-Digital Hadronic CALorimeter (SDHCAL) prototype using Glass Resistive Plate Chambers as a sensitive medium is the first technological prototype in a family of high-granularity calorimeters developed by the CALICE collaboration to equip the experiments of future leptonic colliders. It was exposed to beams of hadrons, electrons and muons several times on the CERN PS and SPS beamlines in 2012, 2015 and 2016. We present here a new method of particle identification within the SDHCAL using the Boosted Decision Tree (BDT) method applied to the data collected in 2015. The performance of the method is tested first with GEANT4-based simulated events and then on the data collected in the SDHCAL in the energy range between 10 and 80 GeV with 10 GeV energy steps. The BDT method is then used to reject the electrons and muons which contaminate the SPS hadron beams.