Skip to content
Back to skills

Morgan Fingerprint Features

ASecurity

Converts molecular SMILES strings to fixed-length Morgan fingerprint bit vectors using RDKit for use as tabular ML features.

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
datapython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill morgan-fingerprint-features --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Morgan Fingerprint Features?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Morgan Fingerprint Features
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-morgan-fingerprint-features/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-morgan-fingerprint-features)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: tabular-morgan-fingerprint-features
description: >
  Converts molecular SMILES strings to fixed-length Morgan fingerprint bit vectors using RDKit for use as tabular ML features.
---
# Morgan Fingerprint Features

## Overview

Morgan fingerprints (Extended-Connectivity Fingerprints / ECFP) encode the structural neighborhood of each atom in a molecule as a fixed-length binary vector. Each bit represents whether a particular circular substructure of radius R exists in the molecule. This converts variable-length SMILES strings into fixed-size feature vectors suitable for any tabular ML model (LGBM, XGBoost, random forest). Morgan FPs are the most widely used molecular representation in cheminformatics — they capture functional groups, ring systems, and local topology in a compact, hashable form.

## Quick Start

```python
import numpy as np
from rdkit import Chem
from rdkit.Chem import AllChem

def smiles_to_morgan(smiles, radius=2, n_bits=1024):
    """Convert SMILES to Morgan fingerprint bit vector."""
    mol = Chem.MolFromSmiles(smiles)
    if mol is None:
        return np.zeros(n_bits)
    fp = AllChem.GetMorganFingerprintAsBitVect(mol, radius, nBits=n_bits)
    return np.array(fp)

# Vectorize a dataset
X = np.vstack([smiles_to_morgan(s) for s in df['SMILES']])
# X shape: (n_samples, 1024) — ready for LGBM/XGBoost
```

## Workflow

1. Parse SMILES string to RDKit Mol object
2. Generate Morgan fingerprint with chosen radius and bit count
3. Convert to numpy array
4. Stack into feature matrix for downstream ML

## Key Decisions

- **Radius**: 2 (ECFP4) is standard; 3 (ECFP6) captures larger substructures but is sparser
- **n_bits**: 1024 is default; 2048 reduces hash collisions for diverse datasets
- **Count vs binary**: `GetMorganFingerprint` returns counts; `AsBitVect` returns binary — binary is usually sufficient
- **Combining**: Stack with RDKit descriptors or graph features for richer representations

## References

- [NeurIPS 2025 Open Polymer Challenge Tutorial](https://www.kaggle.com/code/alexliu99/neurips-2025-open-polymer-challenge-tutorial)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.