liveBook · Manning

CART

As explained in Build AI Drug Discovery Pipelines

CART is a decision-tree learning algorithm that recursively constructs binary trees by selecting feature thresholds that optimize node purity.

CART (Classification and Regression Trees) builds a binary decision tree by repeatedly choosing a feature and threshold that produce the purest child nodes. In molecular-property classification, this can separate cytochrome P450 inhibitors from noninhibitors using descriptors such as molecular weight and logP. Splitting continues until limits such as maximum depth, minimum node size, or pure leaves stop the process. section 5.2.1

A CART classification workflow:

  • Evaluate candidate feature thresholds and select the split with the greatest weighted purity gain. section 5.2.1
  • Measure node impurity with Gini impurity; zero means every training instance has the same class. section 5.2.1
  • Assign each leaf a predicted class, and optionally estimate class probability from the fitted tree. section 5.2.1
Listing 5.3 Train Decision Tree Classifier
from rdkit.Chem import Descriptors
from sklearn.tree import DecisionTreeClassifier, export_graphviz, plot_tree
 
RDKIT_DESCRIPTORS = {
  'MolWt' : Descriptors.MolWt,
  'logP' : Descriptors.MolLogP,
}
 
for desc, func in RDKIT_DESCRIPTORS.items():
  train_df[desc] = train_df["Molecule"].apply(func)
  val_df[desc] = val_df["Molecule"].apply(func)
 
tree_clf = DecisionTreeClassifier(max_depth=2)
tree_clf.fit(train_df[['MolWt', 'logP']], train_df.Inhibitor)
val_df['Predicted Class'] = tree_clf.predict(val_df[['MolWt', 'logP']])
val_df['Probability Estimate'] = tree_clf.predict_proba(
  val_df[['MolWt', 'logP']]
)[:,1] 

Train a depth-two scikit-learn tree from RDKit molecular-weight and logP descriptors, then predict validation classes and inhibitor probabilities. section 5.2.1

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Explains recursive splitting, Gini impurity, stopping conditions, leaf labels, and weighted child-node costs.
Examples
Uses molecular weight, logP, validation molecules, and a depth-two tree visualization as concrete examples.
What you can do after
Build a classifier with RDKit descriptors and scikit-learn, then produce validation labels and probability estimates.
How it connects
Connects decision trees with Gini impurity, entropy, feature thresholds, molecular descriptors, and binary classification.

Also explained in

Compare how 3 books explain CART →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.