N-nitrosamine contaminants in medicinal products are of concern due to their high carcinogenic potency; however, not all nitrosamines are created equal, and some are relatively benign chemicals. Understanding the structure-activity relationships (SARs) that drive hazard in one molecule versus another is key to both protecting human health and alleviating costly and sometimes inaccurate animal testing. Here, we report on an extension of the CADRE (Computer-Aided Discovery and REdesign) platform, used broadly by the pharmaceutical and personal care industries to assess environmental and human health endpoints, to predict carcinogenic potency of N-nitrosamines. The model distinguishes compounds in three potency categories with 78% accuracy in external testing, which surpasses reproducibility of rodent cancer bioassays and constraints imposed by limited (quality) data. Robustness of predictions for more complex pharmaceutical nitrosamines is maximized by capturing key SARs using quantum mechanics., i.e., by hinging the model on the underlying chemistry vs. chemicals in the training set. To this end, the present approach can be leveraged in a quantitative hazard assessment and to offer qualitative guidance using electronic-structure comparison between well-studied analogs and unknown contaminants.