A machine learning approach to detecting unknown or anomalous signals in a complicated background of interfering signals and noise is presented. A hidden Markov model (HMM) is trained to represent the interference and noise environment via a Bayesian nonparametric hierarchical Dirichlet process (HDP)-HMM technique. An unknown signal is detected if the Viterbi hidden state path of the test data is sufficiently unlikely under the learned background HMM. The detection scheme is derived as a generalized likelihood ratio test (GLRT) for an unknown deterministic signal in HMM noise. In simple additive white Gaussian noise (AWGN), the proposed scheme trivially reduces to an energy detector. However, experimental results on a software-defined radio (SDR) testbed demonstrate that the proposed scheme substantially outperforms energy detection in a more challenging interference and noise background. The approach can be employed in spectrum monitoring applications to efficiently detect transmissions that deviate from a typical signal environment.