In the present work, machine learning (ML) was employed to build a model, and through it, the microstructural features (parameters) affecting the stress concentration (SC) during plastic deformation of magnesium (Mg)-based materials are determined. As a descriptor for the SC, the kernel average misorientation (KAM) was used, and starting from the microstructural features of pure Mg and AZ31 Mg alloy, as recorded using electron backscattered diffraction (EBSD), the ML model was trained and constructed using various types of ML algorithms, including Logistic Regression (LR), Decision Trees (DT), Random Forest (RF), Naive Bayes Classifier (NBC), K-Nearest Neighbor (KNN), Multilayer Perceptron (MLP), and Extremely Randomized Trees (ERT). The results show that the accuracy of the ERT-based model was higher compared to other models, and accordingly, the nine most-important features in the ERT-based model, those with a Gini impurity higher than 0.025, were extracted. The feature importance showed that the grain size is the most effective microstructural parameter for controlling the SC in Mg-based materials, and according to the relative Accumulated Local Effects (ALE) plot, calculated to show the relationship between KAM and grain size, it was found that SC occurs with a lower probability in the fine range of grain size. All findings from the ML-based model built in the present work were experimentally confirmed through EBSD observations.