liveBook · Manning

Manifold learning

As explained in Build AI Drug Discovery Pipelines

Manifold learning is a family of dimensionality-reduction methods that models high-dimensional data as lying on or near a lower-dimensional manifold.

Manifold learning reduces high-dimensional data by modeling it as lying on or near a lower-dimensional surface. Unlike PCA’s linear assumption, nonlinear methods can preserve structure that is locally simple but globally curved, such as a rolled Swiss roll. section 7.1.4

A practical manifold-learning workflow can:

  • Represent compounds with fingerprints, then project them into two dimensions with UMAP. section 7.1.4
  • Tune neighborhood size and minimum distance with cross-validation before using the embedding with a k-nearest-neighbors classifier. section 7.1.4
  • Inspect projections for relationships involving compound activity and chemical series. section 7.1.4
Listing 7.4 Apply UMAP on COVID Moonshot Data Set
import umap
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.neighbors import KNeighborsClassifier
 
drh_data["retro_hit"] = \
    drh_data.pert_iname.isin(set(retrospective_hits_in_drh))
train_labels = (data["label"] == 1).values    #A
test_labels = drh_data["retro_hit"].values    #B
train_fps = fingerprints
test_fps = unseen_fingerprints
 
umap_params = {
    'umap__n_neighbors': [5, 10, 15],
    'umap__min_dist': [0.1, 0.2, 0.3],
}
 
pipeline = Pipeline([
    ('umap', umap.UMAP(metric="jaccard", n_components=2)),
    ('knn', KNeighborsClassifier(n_neighbors=5)),
])    #C
 
grid_search = GridSearchCV(
    pipeline, umap_params, cv=3, scoring='f1_micro', n_jobs=-1)
grid_search.fit(train_fps, train_labels)
print(f"Best parameters: {grid_search.best_params_}")
print(f"Best cross-validation score: {grid_search.best_score_}")
 
best_model = grid_search.best_estimator    #D
best_model.fit(train_fps, train_labels)

Runnable Python demonstrates UMAP with a Jaccard metric, a two-dimensional embedding, a k-nearest-neighbors classifier, and GridSearchCV. section 7.1.4

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Explains the manifold assumption, contrasts PCA with nonlinear structure, and demonstrates tuned UMAP with classification.
Examples
Uses the Swiss roll, COVID Moonshot compounds, fingerprints, activity labels, and chemical-series projections.
What it assumes
Defines manifolds, PCA, and local structure before applying UMAP to molecular fingerprints.
What you can do after
Apply UMAP through a scikit-learn pipeline and evaluate parameters with cross-validation.
How it connects
Connects dimensionality reduction with PCA, self-organizing maps, local structure, fingerprints, and nearest-neighbor classification.

Also explained in

Compare how 2 books explain manifold 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.