Pyrite geochemistry is crucial for the discrimination of the types of ore-forming fluids in gold deposits, such as metamorphic-hydrothermal fluids and magmatic-hydrothermal fluids. With the assistance of supervised machine learning algorithms, this application can be leveraged maximally. Here, laser ablation inductively coupled plasma mass spectrometry (LA-ICP-MS) geochemical data for 4683 pyrite samples worldwide were collected to train seven classification models. The top three algorithms, including Random Forest (RF), Support Vector Machines (SVM), and Multilayer Perceptron (MLP), were used to build classifiers to predict the type of pyrite. The established classifiers were applied to new geochemical data for pyrite samples collected from the Jinkeng and Huanggou gold deposits in the Xuefengshan Orogen (XFSO). The findings suggest that the classifiers are capable of accurately distinguishing between two main types of ore-forming fluids, with good predictive outcomes. This performance surpasses that of traditional, two-dimensional diagram-based methods. The classifiers determined that the geochemical constituents of pyrite from the Jinkeng and Huanggou originated from metamorphic-hydrothermal sources, consistent with geological and geochemical evidence. The results further reveal that the Jinkeng and Huanggou are classified mostly as orogenic gold deposit. This study proves that data-driven methods based on machine learning can provide compelling evidence for distinguishing between the types of ore-forming fluids, understanding deposit genesis, and providing prospecting ideas. Additionally, this research boosts confidence in the use of machine learning to geological classification challenges.