We explore the use of random forest and gradient boosting, two powerful tree-based machine learning algorithms, for the detection of cosmic strings in maps of the cosmic microwave background (CMB), through their unique Gott-Kaiser-Stebbins effect on the temperature anisotropies.The information in the maps is compressed into feature vectors before being passed to the learning units. The feature vectors contain various statistical measures of processed CMB maps that boost the cosmic string detectability. Our proposed classifiers, after training, give results improved over or similar to the claimed detectability levels of the existing methods for string tension, $G\mu$. They can make $3\sigma$ detection of strings with $G\mu \gtrsim 2.1\times 10^{-10}$ for noise-free, $0.9'$-resolution CMB observations. The minimum detectable tension increases to $G\mu \gtrsim 3.0\times 10^{-8}$ for a more realistic, CMB S4-like (II) strategy, still a significant improvement over the previous results.