Chalcopyrite from 51 volcanogenic massive sulfide (VMS) and sea-floor massive sulfide (SMS) deposits from six lithostratigraphic settings was analyzed for trace elements by laser ablation-inductively coupled plasma-mass spectrometry (LA-ICP-MS) to evaluate its potential as an indicator mineral for exploration. Partial least squares discriminant analysis (PLS-DA) results reveal that chalcopyrite from different lithostratigraphic settings has different compositions reflecting host-rock assemblages and fluid composition. Three random forest (RF) classifiers were developed to distinguish chalcopyrite from the six lithostratigraphic settings with a divisive approach. This method, which primarily classifies according to the major host-rock affinity and subsequently according to VMS settings, yielded an overall accuracy higher than 0.96 on test data. The model validation with literature data having the same elements required by the models yielded the highest accuracies (>0.90). In validation using published data with missing elements, the accuracy is moderate to high (0.60–1); however, the performances decrease significantly (<0.50) when the most important elements are missing. Similarly, RF regression models developed using all sets of analyzed elements to determine ccp/(ccp + sp) ratio (ccp = chalcopyrite; sp = sphalerite) in chalcopyrite within a single VMS setting reported high performances, thus showing a potential to predict the Cu/Zn ratio (Cu-rich vs. Zn-rich) of the mineralization based on chalcopyrite composition. This study demonstrates that trace element concentrations in chalcopyrite are primarily controlled by lithotectonic setting and can be used as predictors in an RF classifier to distinguish the different VMS subtypes.