A classifier predicts a discrete class label for an input. It learns through supervised learning: training examples contain both inputs and their known labels. For example, a toxicity classifier can learn from molecules labeled “toxic” or “not toxic” and then predict labels for new molecules. Unlike classification, regression predicts a continuous numerical quantity. section 1.2.2
Inputs need a representation the model can use. A molecule can be described by a feature vector containing properties such as molecular weight and counts of atoms or bond types. Binary classification chooses between two classes; multiclass classification chooses among more than two. section 1.2.2 section 3.1.1
Screening for hERG blockers
The hERG potassium channel is an antitarget: blocking it can cause an undesirable effect, in this case cardiotoxicity. A classifier trained on labeled compounds predicts blocker (1) or non-blocker (0). Missing a blocker and incorrectly discarding a useful compound are different errors. Low-confidence predictions can be deferred for experimental follow-up; a predicted non-blocker is not necessarily safe. section 3.1 section 3.1.1
A classifier can produce probability estimates as well as class predictions. Logistic regression uses a decision threshold to turn its estimates into labels; precision-recall and ROC curves help assess performance across thresholds. Decision trees instead make a sequence of feature-based decisions, while random forests combine multiple trees. section 5.1.2 section 5.5
Evaluating CYP3A4 inhibition
A logistic regression classifier for inhibition of CYP3A4, a drug-metabolizing enzyme, reaches 0.78 validation accuracy. An always-negative dummy model reaches 0.55; precision is 0.76 and recall is 0.74. Comparing these measures matters because accuracy alone can be misleading, especially when classes are imbalanced. section 5.0 section 5.1.2
Listing 5.1 Train and Evaluate Logistic Regressor on the CYP3A4 Inhibition Data Set
from sklearn.metrics import accuracy_score, precision_score, recall_score
from sklearn.linear_model import LogisticRegression
from tdc.single_pred import ADME
from utils import compute_fingerprint
import numpy as np
import pandas as pd
from rdkit.Chem import PandasTools
def process_df(df):
df = df.rename(columns={'Y': 'Inhibitor'})
PandasTools.AddMoleculeColumnToFrame(df, 'Drug', 'Molecule')
df = df.dropna()
df['fingerprints'] = df['Molecule'].apply(
compute_fingerprint, r=2, nBits=2048 # r = Morgan radius; 2048-bit vector
)
fingerprints = np.stack(df.fingerprints.tolist())
return df, fingerprints
data = ADME(name='CYP3A4_Veith')
splits = data.get_split('scaffold')
train_df, valid_df, test_df = \
splits['train'], splits['valid'], splits['test']
train_df, train_fingerprints = process_df(train_df)
val_df, val_fingerprints = process_df(valid_df)
test_df, test_fingerprints = process_df(test_df)
lr_model = LogisticRegression()
lr_model.fit(train_fingerprints, train_df.Inhibitor)
val_preds = lr_model.predict(val_fingerprints) #A
val_proba_inhibitor = lr_model.predict_proba(val_fingerprints)[:, 1] #B
print(f"Accuracy: {accuracy_score(val_df.Inhibitor, val_preds):.2f}")
# Output -> Accuracy: 0.78
print(f"Precision: {precision_score(val_df.Inhibitor, val_preds):.2f}")
# Output -> Precision: 0.76
print(f"Recall: {recall_score(val_df.Inhibitor, val_preds):.2f}")
# Output -> Recall: 0.74Inspect the workflow for preparing molecular fingerprints and training and evaluating the CYP3A4 classifier. section 5.1.2
Classification also applies to protein sequences. An antibody classifier can use heavy-chain sequences labeled by virus target, pool token representations into a sequence vector, and score HIV-1 versus SARS-CoV-2. Evaluation includes accuracy, precision, recall, F1, AUC, and checks across sequence lengths. section 12.3.4



































