Global volcanic and plutonic olivines record the compositional characteristics and physicochemical conditions of the parental magmas. Thus, they have significant potential for use as petrogenetic discriminators of the olivine formation environment and prospecting indicators for potential host rocks of magmatic sulfide deposits.Several data visualization approaches have been proposed by researchers to determine olivine origins. However, they can only discriminate specific olivine populations and require the incorporation of trace elements for which data are lacking globally. In this study, a machine-learning method consisting of the random forest algorithm and the synthetic minority oversampling technique (SMOTE) is used to discriminate the crystallization environments of olivine and predict the sulfide potential of olivine-bearing mafic-ultramafic intrusions. We employ a global dataset of 24341 olivine samples from twelve environments to determine the contents of MgO, FeO, Ni, Ca, Mn, and Cr and the Fo number (100×Mg/(Mg+Fe)). The results indicate that the proposed method can classify olivine into genetically distinct populations and distinguish olivine derived from mineralized intrusions from that derived from sulfide-barren intrusions with high accuracies (higher than 99% on average). We develop a dimensionality reduction algorithm to visualize the olivine classifications using low-dimensional vectors and an olivine classifier (accessible at http://cugb.online:8080/olivine_web/main.html). The model is used successfully to identify the contributions of distinct sources to regional magmatism using olivines from the late Permian picrite and basalt along the western margin of the Yangtze This is the peer-reviewed, final accepted version for American Mineralogist, published by the Mineralogical Society of America.The published version is subject to change. Cite as Authors (Year) Title. American Mineralogist, in press.