Understanding species’ roles in food webs requires an accurate assessment of their trophic niche. However, it is challenging to delineate potential trophic interactions across an ecosystem, and a paucity of empirical information often leads to inconsistent definitions of trophic guilds based on expert opinion, especially when applied to hyperdiverse ecosystems. Using coral reef fishes as a model group, we show that experts disagree on the assignment of broad trophic guilds for more than 20% of species, which hampers comparability across studies. Here, we propose a quantitative, unbiased, and reproducible approach to define trophic guilds and apply recent advances in machine learning to predict probabilities of pairwise trophic interactions with high accuracy. We synthesize data from community-wide gut content analyses of tropical coral reef fishes worldwide, resulting in diet information from 13,961 individuals belonging to 615 reef fish. We then use network analysis to identify 8 trophic guilds and Bayesian phylogenetic modeling to show that trophic guilds can be predicted based on phylogeny and maximum body size. Finally, we use machine learning to test whether pairwise trophic interactions can be predicted with accuracy. Our models achieved a misclassification error of less than 5%, indicating that our approach results in a quantitative and reproducible trophic categorization scheme, as well as high-resolution probabilities of trophic interactions. By applying our framework to the most diverse vertebrate consumer group, we show that it can be applied to other organismal groups to advance reproducibility in trait-based ecology. Our work thus provides a viable approach to account for the complexity of predator–prey interactions in highly diverse ecosystems.