Overview

4 Solubility Deep Dive with Linear Models

Drug solubility is presented as a central problem in pharmaceutical modeling because it strongly influences bioavailability, especially for oral drugs that must dissolve and survive the gastrointestinal environment before reaching circulation. The chapter uses solubility as a practical case study for linear models, showing how experimentally measured values can be paired with molecular descriptors to build predictive models that help prioritize compounds with better chances of success. It also emphasizes that real solubility data can be noisy, inconsistent across studies, and populated by outliers, so careful dataset inspection is essential before modeling.

The workflow begins with scaffold-based splitting of the AqSolDB dataset to avoid overly optimistic evaluation caused by structurally similar molecules appearing in both train and test sets. The text then walks through descriptor calculation, correlation analysis, and feature engineering, using properties such as molecular weight, logP, hydrogen-bond donors, and aromatic proportion. It shows how some descriptors correlate strongly with solubility while others add little signal, and it introduces applicability domain reasoning so the model is only trusted within chemical space similar to the training data. A baseline linear regression is then fitted, and the chapter explains the underlying learning mechanics, including ordinary least squares, gradient descent, feature scaling, and the use of MSE, MAE, and R² for evaluation.

After establishing the basics, the chapter surveys several Scikit-Learn linear approaches, including Ridge regression, sequential feature selection, and more robust SGD-based models such as RANSAC and support vector regression. It compares these against an ESOL benchmark and a y-scrambled baseline to test whether the models are truly learning meaningful structure rather than chance patterns. The strongest model uses an epsilon-insensitive loss with polynomial features, inverse learning-rate scaling, and early stopping, giving the best test performance among the methods examined. The chapter closes by connecting these results to the bias-variance trade-off, showing how learning curves and validation curves reveal when a model is underfitting, overfitting, or balanced well enough to generalize.

Comparison of solubility distributions for train and validation data sets.
The least soluble molecules (top row) and the most soluble molecules (bottom row) in the training data set.
Three molecules with the greatest number of fragments in the training data set.
Scatterplots of each descriptor with respect to solubility, our target variable.
Correlation heatmap for each pair of descriptors and solubility.
Estimated model AD based off of regions defined by the bounding box (dashed line) and convex hull (dotted line) methods.
Example depiction of simple linear regression
Performance of our simple linear regression model on the training data.
Adjusting the model’s weights results in different regression lines, ideally minimizing the MSE.
Example cost function surface we may navigate with gradient descent.
Impact of learning step size on the ability for gradient descent to converge.
A combination of gradient descent stopping criterion works best to mitigate early termination when hitting the first plateau.
Gradient cliffs impact converging to an optimal minimum of model weights.
Effect of feature scaling on the convergence of gradient descent.
Ridge regressor coefficients for each descriptor.
Loss curves as a function of learning rate schedular and number of epochs.
Impact of model complexity on the fitted model’s training and testing performance.
How high bias or high variance impact a model’s sensitivity to the training data it learns from.
Learning curves for RANSAC and SVR models.
Validation curves for SVR and preprocessing hyperparameters.
How different errors (train, validation, generalization) and bias and variance change as a function of the number of data points (left, learning curve) or the model complexity (right, validation curve).

Summary

  • Using AqSolDB, we explored another fundamental problem to drug discovery – characterizing a molecule’s solubility. Poor solubility can lead to reduced absorption, necessitating higher drug doses and potentially causing adverse effects, while good solubility can enhance a drug's therapeutic profile.
  • We reviewed the underlying mechanics of linear models through the specifics of linear regression. We explored closed-form (normal equation) and iterative (gradient descent) solutions in determining the optimal set of linear weights.
  • Gradient descent has additional variants in the form of batch, mini-batch, and stochastic gradient descent. These variants have implications on runtime and memory, as well as convergence on a performative set of weights. Additional peculiarities to consider when using gradient descent are the learning rate, convergence criteria, gradient clipping, and feature scaling.
  • We gained exposure to a greater breadth of linear models that are easily accessible in Scikit-Learn. Expanding our toolkit beyond linear regression, RANSAC is an iterative method used for robust estimation and model fitting in the presence of outliers and SVR finds a hyperplane that fits the data while allowing for a margin of error (epsilon-tube) around the predicted values.
  • A model with high bias makes overly simplistic assumptions about the target function’s complexity and is incapable of capturing the underlying patterns in the training data. A more complex model with more learnable parameters may have smaller bias that allows it to better approximate the target function, but the additional complexity makes it harder to find and pin down the best approximation.

FAQ

What is solubility and why does it matter in drug discovery?Solubility is a drug candidate’s ability to dissolve in biological fluids such as water or gastric juice. It matters because poor solubility can reduce absorption and bioavailability, which can lower efficacy, require higher doses, and increase adverse effects.
Why does the chapter use linear regression instead of classification for solubility prediction?Because solubility is a continuous numeric property, not a class label. Linear regression is designed to predict continuous values, whereas classification predicts discrete categories.
What dataset is used for the solubility example in this chapter?The chapter uses AqSolDB, a benchmark solubility dataset available through Therapeutics Data Commons. It contains experimental aqueous solubility measurements for 9,982 compounds and supports predefined splits such as scaffold-based splitting.
Why is scaffold splitting preferred over random splitting for chemical datasets?Scaffold splitting keeps structurally similar molecules in the same split, which makes evaluation more realistic. Random splitting can place very similar compounds in both train and test sets, making performance look better than it really is.
What kind of feature engineering is done before training the models?RDKit molecular descriptors are computed as features, including molecular weight, logP, TPSA, number of H-bond donors, number of rotatable bonds, number of rings, LabuteASA, BalabanJ, BertzCT, and aromatic proportion. These descriptors capture size, polarity, lipophilicity, and aromaticity.
Why are outliers and multi-fragment molecules filtered out?Extreme outliers can distort model learning and may not represent the intended production domain. Molecules with multiple fragments, salts, metals, or unusual structures can behave very differently from typical small-molecule drug candidates, so the chapter filters to single-fragment molecules.
What is the applicability domain of a solubility model?The applicability domain is the region of chemical space where the model is expected to make reliable predictions. In the chapter, simple geometric methods like bounding boxes and convex hulls are used to estimate whether a new molecule lies within the model’s reliable range.
How are model performance and regression quality evaluated in this chapter?The chapter uses metrics such as MSE, MAE, RMSE, and R². RMSE is emphasized because it puts error back into the original target scale, making the results easier to interpret.
What is the difference between ordinary least squares and gradient descent?Ordinary least squares gives a closed-form solution by directly computing the best weights. Gradient descent instead updates weights iteratively by following the negative gradient of the loss function, which is useful when a closed-form solution is unavailable or impractical.
What causes overfitting, and how is it addressed in this chapter?Overfitting happens when a model is too flexible and learns noise instead of the true pattern. The chapter addresses it through regularization, feature selection, early stopping, learning-curve analysis, validation curves, and bias-variance trade-off reasoning.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build AI Drug Discovery Pipelines ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build AI Drug Discovery Pipelines ebook for free