liveBook · Manning

Unsupervised learning

As explained in Build AI Drug Discovery Pipelines

Unsupervised learning trains a model from data without provided target labels.

Unsupervised learning finds hidden patterns, relationships, and data distributions without provided target labels. Unlike supervised learning, it learns from inputs rather than input-output pairs, making it useful when life-science data is abundant but mostly unlabeled. section 1.2.2 section 7.0

Common goals include:

  • Dimensionality reduction compresses high-dimensional data, preserves useful signal, removes noise, and supports visualization. section 7.0 section 7.1
  • Clustering divides compounds into similar subsets and learns its own grouping structure. section 7.0
  • Density estimation models the probability distribution underlying the data and can flag low-probability points as possible outliers. section 7.0

Molecular screening and drug repurposing

A workflow loads 2,062 synthesized compounds from high-throughput screening, converts their SMILES strings into 2,048-bit Morgan fingerprints with radius 2, and uses dimensionality reduction to visualize the molecular data. IC50-based active and inactive labels are added only for supplementary analysis; the unsupervised approaches do not require them. section 7.1

Listing 7.1 Load & Featurize COVID Moonshot Data
import numpy as np
import pandas as pd
from rdkit import Chem, DataStructs
from rdkit.Chem import rdFingerprintGenerator
 
file_path = 'data/ch07/raw/CH07_activity_data.csv'
data = pd.read_csv(file_path)
 
def generate_morgan_fingerprint(smiles, radius=2, n_bits=2048):
    mol = Chem.MolFromSmiles(smiles)
    if mol is None:
        return None
    fp_gen = rdFingerprintGenerator.GetMorganGenerator(
        radius=radius, fpSize=n_bits)
    fp = fp_gen.GetFingerprint(mol)
    arr = np.zeros((n_bits,), dtype=int)
    DataStructs.ConvertToNumpyArray(fp, arr)
    return arr
 
data['Morgan_Fingerprint'] = data['SMILES'].apply(generate_morgan_fingerprint)
data = data.dropna(subset=['Morgan_Fingerprint'])
 
data['label'] = np.select(    #A
    [data['f_avg_IC50'] < 5, data['f_avg_IC50'] >= 5],    #A
    [1, 2],    #A
    default=3,    #A
)    #A
 
fingerprints = np.array([list(fp) for fp in data['Morgan_Fingerprint']])
label_names = {1: 'Active', 2: 'Inactive', 3: 'Unknown'}

Runnable Python code loads the screening dataset, parses SMILES with RDKit, generates Morgan fingerprints, converts them to NumPy arrays, and removes invalid molecules. section 7.1

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Defines three major task families and demonstrates molecular featurization, while deferring detailed algorithmic treatment to their applications.
Examples
Uses high-throughput screening compounds, SMILES strings, Morgan fingerprints, IC50 measurements, and molecular visualizations.
What it assumes
Assumes basic molecule representations and IC50 terminology, while contrasting labeled supervised learning with unlabeled analysis.
What you can do after
Apply it via RDKit and Python to featurize compounds and explore unlabeled molecular datasets with unsupervised methods.
How it connects
Connects supervised learning, dimensionality reduction, clustering, density estimation, drug repurposing, and generative modeling.

Also explained in

Compare how 22 books explain unsupervised learning →

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.