Understanding quantum phenomena that go beyond classical concepts is a focus of modern quantum physics. Here, we show how the theory of non-negative polynomials emerging around Hilbert's 17th problem, can be used to optimally exploit data capturing the nonclassical nature of light. Specifically, we show that non-negative polynomials can reveal nonclassicality in data even when it is hidden from standard detection methods up to now. Moreover, the abstract language of non-negative polynomials also leads to a unified mathematical approach to nonclassicality for light and spin systems, allowing us to map methods for one to the other. Conversely, the physical problems arising also inspire several mathematical insights into characterization of non-negative polynomials.