{"slug": "what-shap-revealed-about-molecular-properties-four-models-four-different-answers", "title": "What Shap Revealed About Molecular Properties: Four Models, Four Different Answers", "summary": "An XGBoost model trained on RDKit descriptors predicted aqueous solubility (logS) with RMSE 0.52 log units and R² 0.89 on held-out compounds, more than twice as accurate as the classic Delaney (2004) formula's RMSE of 1.15, according to a cheminformatics study published on GitHub (cheminformatics-ml). SHAP attributed 63% of the solubility model's feature importance to Crippen LogP, while the top driver flipped to BertzCT for boiling point (XGBoost RMSE 28.5 °C, R² 0.84 versus a molecular-weight-only baseline at RMSE 47.7 °C). For Crippen LogP itself, ElasticNet reached RMSE 0.75 and R² 0.84 but lost to Crippen's atom-contribution method at RMSE 0.65 and R² 0.88, and for Ames mutagenicity logistic regression ranked first on the held-out test set with AUC 0.987 and recall 0.909.", "body_md": "*Disclosure: I drafted this article with AI assistance from my own notebooks and results. I reviewed and edited it, and checked every number against my code.*\n\nMost chemistry notebooks on Kaggle treat molecules as just another tabular dataset. Compute some descriptors, fit XGBoost, report R², done. I wanted to know something else: when a model predicts a molecular property well, is it learning chemistry, or a shortcut?\n\nSo I built four models from the same family of RDKit descriptors, for four different properties, and asked SHAP what drove each one. The answer was different every time, and each time it matched the physical chemistry. Two of the four also ended with a result I didn’t expect: the fancy model lost.\n\nAll notebooks and data are on [GitHub (cheminformatics-ml)](https://github.com/shehanmakani/cheminformatics-ml).\n\nEvery notebook follows the same recipe, so the differences come from the chemistry, not the pipeline.\n\nThe baselines matter most. A model that beats LightGBM but loses to a 20-year-old formula hasn’t learned anything useful.\n\nXGBoost predicted aqueous solubility (logS) with RMSE 0.52 log units and R² 0.89 on held-out compounds. The classic Delaney (2004) formula [1], applied across the dataset, scored RMSE 1.15, more than twice the error.\n\nSHAP put Crippen LogP far ahead, at 63% of XGBoost’s feature importance. That is the thermodynamics of water exclusion: hydrophobic molecules don’t dissolve. Polycyclic aromatics such as pyrene (logS −5.18) set the insolubility floor, with high LogP and no heteroatoms to bond with water. Tree models beat linear ones because the effect isn’t additive: LogP and ring count interact.\n\nXGBoost reached RMSE 28.5 °C and R² 0.84 across compounds boiling from −162 to +365 °C. A molecular-weight-only baseline managed RMSE 47.7 °C.\n\nThe top SHAP driver flipped. It was BertzCT, a measure of structural complexity, not LogP. More complex molecules have more surface for van der Waals contact, so they hold together longer as liquids. H-bond donors push boiling points well above non-polar molecules of the same weight.\n\nHere I removed RDKit’s own Crippen LogP from the features and asked whether ML could rebuild it from structure. The best model, ElasticNet, reached RMSE 0.75 and R² 0.84. Crippen’s atom-contribution method [2] still won, at RMSE 0.65 and R² 0.88.\n\nThat isn’t a failure; it’s the point. Crippen encodes a measured contribution for each atom type, which 119 molecules can’t relearn. SHAP’s top driver was molar refractivity (MolMR), a proxy for electron polarizability, which is the physical reason a molecule prefers octanol to water. ML was competitive in the LogP 1–3 range, where most drug molecules sit.\n\nFor Ames mutagenicity, a binary yes/no, logistic regression ranked first on the held-out test set: AUC 0.987 and recall 0.909. In 5-fold cross-validation, though, SVM and XGBoost scored higher (AUC 0.98 vs. 0.90). With 122 compounds, that ranking is fragile.\n\nThe structural alerts were not fragile. Every compound with a nitro or nitroso group in the set was mutagenic [4, 5], because these groups become electrophiles that attack DNA. Aromatic amines were mutagenic 30% of the time, and alkyl halides 43%. I optimized for recall, because in toxicology a missed mutagen costs far more than a false alarm.\n\nThe whole loop fits on one screen. This is the boiling-point version, trimmed from the notebook:\n\n``` python\nimport numpy as np, pandas as pd, shap, xgboost as xgbfrom rdkit import Chemfrom rdkit.Chem import Descriptors, Crippen, rdMolDescriptorsfrom sklearn.model_selection import train_test_split\npython\ndef featurize(smiles):    mol = Chem.MolFromSmiles(smiles)    return {        \"MW\": Descriptors.MolWt(mol),        \"LogP\": Crippen.MolLogP(mol),        \"HBD\": rdMolDescriptors.CalcNumHBD(mol),        \"TPSA\": Descriptors.TPSA(mol),        \"MolMR\": Crippen.MolMR(mol),        \"BertzCT\": Descriptors.BertzCT(mol),        # ...the full notebooks use more descriptors    }\nX = pd.DataFrame([featurize(s) for s in df[\"smiles\"]])y = df[\"bp_celsius\"]\n# 70/15/15 train/validation/test splitX_train, X_tmp, y_train, y_tmp = train_test_split(X, y, test_size=0.30, random_state=42)X_val, X_test, y_val, y_test = train_test_split(X_tmp, y_tmp, test_size=0.50, random_state=42)\nmodel = xgb.XGBRegressor(n_estimators=300, learning_rate=0.05, max_depth=5,                         subsample=0.8, colsample_bytree=0.8, random_state=42)model.fit(X_train, y_train)\n# Which descriptor drives the prediction?shap_vals = shap.TreeExplainer(model).shap_values(X_test)importance = pd.Series(np.abs(shap_vals).mean(axis=0), index=X.columns)print(importance.sort_values(ascending=False).head())\n```\n\nSwap the target column and the same code answers a different chemistry question. That is what makes the comparison fair.\n\n**The top SHAP driver for each property:**\n\nI run a specialty chemical formulation company, and these are the questions I ask before choosing a surfactant or a solvent. ML earned its place in that work only once I could check that it was reasoning like a chemist. SHAP is how I check.\n\nThe four notebooks, data and figures are on [GitHub](https://github.com/shehanmakani/cheminformatics-ml) and [Kaggle](https://www.kaggle.com/shehanmakani).\n\n[1] J. S. Delaney, “ESOL: Estimating aqueous solubility directly from molecular structure,” *J. Chem. Inf. Comput. Sci.*, vol. 44, no. 3, pp. 1000–1005, 2004.\n\n[2] S. A. Wildman and G. M. Crippen, “Prediction of physicochemical parameters by atomic contributions,” *J. Chem. Inf. Comput. Sci.*, vol. 39, no. 5, pp. 868–873, 1999.\n\n[3] S. M. Lundberg and S.-I. Lee, “A unified approach to interpreting model predictions,” *Advances in Neural Information Processing Systems 30*, 2017.\n\n[4] K. Hansen et al., “Benchmark data set for in silico prediction of Ames mutagenicity,” *J. Chem. Inf. Model.*, vol. 49, no. 9, pp. 2077–2081, 2009.\n\n[5] J. Kazius, R. McGuire and R. Bursi, “Derivation and validation of toxicophores for mutagenicity prediction,” *J. Med. Chem.*, vol. 48, no. 1, pp. 312–320, 2005.\n\n[What Shap Revealed About Molecular Properties: Four Models, Four Different Answers](https://pub.towardsai.net/what-shap-revealed-about-molecular-properties-four-models-four-different-answers-32b185e30300) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.", "url": "https://wpnews.pro/news/what-shap-revealed-about-molecular-properties-four-models-four-different-answers", "canonical_source": "https://pub.towardsai.net/what-shap-revealed-about-molecular-properties-four-models-four-different-answers-32b185e30300?source=rss----98111c9905da---4", "published_at": "2026-11-20 00:01:02+00:00", "updated_at": "2026-11-20 00:15:09.552558+00:00", "lang": "en", "topics": ["machine-learning", "ai-research"], "entities": ["XGBoost", "SHAP", "RDKit", "Crippen", "Delaney", "ElasticNet", "GitHub", "BertzCT"], "also_reported_by": [], "takeaway": "XGBoost on RDKit descriptors predicted logS at RMSE 0.52 versus 1.15 for the Delaney (2004) formula, but ElasticNet could not rebuild Crippen LogP from structure (RMSE 0.75 versus 0.65), so keep the atom-contribution method where it applies.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/what-shap-revealed-about-molecular-properties-four-models-four-different-answers", "markdown": "https://wpnews.pro/news/what-shap-revealed-about-molecular-properties-four-models-four-different-answers.md", "text": "https://wpnews.pro/news/what-shap-revealed-about-molecular-properties-four-models-four-different-answers.txt", "jsonld": "https://wpnews.pro/news/what-shap-revealed-about-molecular-properties-four-models-four-different-answers.jsonld"}}