The paper considers the problem of natural harmonic oscillations of an elastic rod with stress-free ends in the presence of one or a set of defects. Defects are modeled by the inhomogeneity of the Young's modulus. The location of the defects, their geometric size, which is considered small, and the change in elastic properties are the parameters of the defects. The analysis of natural frequency shifts caused by the defect of the rod is the subject of the study. The aim of the work is a mathematical substantiation for the construction of fast and stable algorithms for determining the defect parameters of elastic bodies by analyzing free oscillations. The paper uses and compares fundamentally different research methods. The first methods are classical mathematical methods of mechanics, applied to the analysis of deterministic systems and based on analytical studies combined with numerical implementation. In contrast, a composite machine learning meta-algorithm used in standard statistical classification and regression - Bootstrap-aggregated Regression Trees (BART) - is used to solve the inverse problem. When comparing the constructed algorithms, the statistical method Sampling was used, which allowed to quantify the accuracy and stability of the algorithms.