---
title: Extended-Connectivity Fingerprint (ECFP)
url: https://www.emergentmind.com/topics/extended-connectivity-fingerprint-ecfp
type: topic
---

# Extended-Connectivity Fingerprint (ECFP)

Extended-Connectivity Fingerprint (ECFP) is a circular substructure-based molecular fingerprinting method that has become a foundational feature extraction technique in computational chemistry and molecular machine learning. ECFP encodes local molecular environments by iteratively hashing atomic neighborhoods up to a fixed radius, yielding variable-length sets of substructure identifiers that are typically folded into fixed-length vectors for use in statistical and machine learning models. The method is widely used for structure-activity prediction, virtual screening, and quantitative structure–activity relationship (QSAR) studies due to its capacity to represent both detailed local chemical motifs and broad scaffold diversity [2403.17954, 2310.00174]. Recent methodological advances, such as the introduction of the Sort & Slice pooling algorithm, have addressed major limitations in classical ECFP vectorisation, notably the issue of hash-based bit collisions.

## 1. ECFP Construction and Algorithmic Details

The ECFP algorithm represents a molecule as a graph $G = (V,E)$, with atoms $i \in V$ and bonds $(i, j) \in E$. Each atom is initially assigned a unique integer identifier $h_i^{(0)}$, encoding atomic invariants such as atomic number, isotope, heavy-atom neighbor count, formal charge, and ring status. Iteratively for $t = 1, \ldots, r$ (where $r$ is the radius parameter), each atom gathers a multiset of tuples containing the bond type and neighboring hash values. The atomic environment at each radius is defined as
$$
U_i^{(t)} = [ h_i^{(t-1)} \,\|\, \text{sort}(S_i^{(t-1)}) ]
$$
where $\|\ $ denotes concatenation. A hash function compresses each atomic environment into a new identifier $h_i^{(t)} = \text{HASH}(U_i^{(t)})$. The set of all such hashed identifiers across all atoms and radii forms the set of detected substructures for the molecule:
$$
I = \{ h_i^{(t)} \,:\, i\in V,\, t=0\ldots r \}
$$
These identifiers are then folded into a fixed-length bit vector of length $N$ by mapping each identifier to index $k = h_i^{(t)} \bmod N$ and setting the corresponding bit (or incrementing a count for the count variant).

The standard parameterisation ECFP4 uses a radius $r = 2$, yielding a molecular diameter of 4 bonds, and a typical bit vector length of 1,024 or 2,048 [2310.00174].

## 2. Mathematical Framework for Substructure Pooling

Let $\mathcal{J} = \{J_1, \ldots, J_m\}$ denote the universe of possible circular substructures (i.e., unique ECFP fragment identifiers). The substructure enumeration process is a function:
$$
\varphi: \mathcal{M} \rightarrow \mathcal{P}(\mathcal{J})
$$
assigning to each molecule $M \in \mathcal{M}$ the subset $\varphi(M) \subseteq \mathcal{J}$ comprising its detected substructures.

A substructure-pooling operator $\Psi$ of output dimension $L$ is any set function:
$$
\Psi: \mathcal{P}(\mathcal{J}) \rightarrow \mathbb{R}^{L}
$$
that converts $\varphi(M)$ into a real (practically binary or count) vector $F = \Psi(\varphi(M))$. In conventional ECFP, $\Psi$ is implemented by hash-based folding; in enhanced schemes, alternative pooling methods are deployed [2403.17954].

## 3. Hash-Based Folding and Its Limitations

Classical ECFP pooling employs a data-agnostic hash function $h: \mathcal{J} \to \{ 1, \ldots, L \}$, mapping substructures to fingerprint indices. The fingerprint $F$ is then defined componentwise as:
$$
F_i = 1_{\{ \exists\, J \in \varphi(M): h(J) = i \}}
$$
or equivalently:
$$
\Psi_h(I)_i = 
\begin{cases}
    1, & \text{if}\ \exists\, J \in I: h(J) = i \\
    0, & \text{otherwise}
\end{cases}
$$
Hash-based folding introduces collisions when $|\varphi(M)|$ or the total number of observed substructures $m$ exceeds $L$, degrading interpretability and potentially predictive power. Bit collisions prevent direct mapping of fingerprint bits to unique chemical fragments, complicating downstream analyses and feature attribution [2403.17954].

## 4. The Sort & Slice Algorithm for Collision-Free Pooling

Sort & Slice is a recently proposed, collision-free pooling algorithm that vectorises ECFP substructures by solely employing substructure frequencies in the training set. For each substructure $J$, its support count on the training set $\mathcal{T}$ is $c(J) = | \text{supp}_\mathcal{T}(J) | = | \{ M \in \mathcal{T} \,:\, J \in \varphi(M) \} |$. The algorithm proceeds by sorting all observed substructures by descending $c(J)$ (using the numerical identifier $J$ to break ties), and selecting the $L$ most prevalent (top-$L$) substructures, denoted $J_{(1)},\dots,J_{(L)}$. Each molecule $M$ is then vectorised by a binary fingerprint $F \in \{0,1\}^L$, where $F_i = 1$ if and only if $J_{(i)} \in \varphi(M)$.

This process is formally specified as:
\[
\begin{array}{l}
\textbf{Input:}\quad\mathcal T=\{M_{1},\dots,M_{n}\},\quad\{\varphi(M_i)\},\quad L\in\mathbb N.\\
\textbf{1.  Prevalence:}\;c(J)\;=\;\left|\left\{\,M\in\mathcal T: J\in\varphi(M)\right\}\right|\quad
  \forall\,J\in\bigcup_{i=1}^n\varphi(M_i).\\
\textbf{2.  Sort:}\;\{J_{(1)},J_{(2)},\dots\}\;\text{such that}\;
  c(J_{(1)})\ge c(J_{(2)})\ge\cdots\quad(\text{tie-break by }J).\\
\textbf{3.  Slice:}\;\mathcal J_L=\{J_{(1)},\ldots,J_{(L)}\}.\\
\textbf{4.  Pooling:}\;\forall\,M\in\mathcal M,\quad
  \Psi_{\text{Sort\&Slice}}( \varphi(M))\;=\;F\in\{0,1\}^L,\\
\quad\text{where}\quad
  F_i=1_{\{J_{(i)}\in\varphi(M)\}}\quad(i=1,\dots,L).
\end{array}
\]
Sort & Slice thus guarantees collision-free bit assignment, as each bit position corresponds to one and only one substructure. This directly addresses the interpretability and information loss limitations of hash-based folding and requires only basic prevalence statistics, making implementation straightforward [2403.17954].

## 5. Comparative Substructure Selection Methods

In addition to Sort & Slice, two supervised substructure selection schemes have been benchmarked:

- **Filtered Fingerprints:** Substructures observed only once in the training set are filtered out. Redundant substructures with identical training-set support as smaller patterns (non-closed) are also removed. The remaining substructures are then ranked by their $\chi^2$ contingency p-value with respect to the labels; the top $L$ are selected.

- **Mutual-Information Maximisation (MIM):** Each substructure is scored by its empirical mutual information with the (possibly binarised) labels; duplicate-support features are merged for redundancy control, and the top $L$ are retained.

Both methods result in one-hot encodings of the selected fragment set, ensuring collision-free assignments but potentially injecting task-specific label information into the fingerprint [2403.17954].

## 6. Empirical Validation and Performance

Large-scale benchmark experiments distinguished the effectiveness of pooling methods for ECFP-based molecular property prediction. Key findings include:

- **Sort & Slice outperformed hash-folding** on five molecular prediction tasks (lipophilicity, aqueous solubility, SARS-CoV-2 $M^{\text{pro}}$ binding, Ames mutagenicity, ERα antagonism), across different data splits (random, scaffold-based), and for both random forest and MLP models.
- **Relative improvement:** On lipophilicity with ECFP4 (1024 bits) and MLP, Sort & Slice achieved mean absolute error (MAE) ≈ 0.60 versus hash-folding's MAE ≈ 0.68, an $\sim$11.4 % MAE reduction [2403.17954].
- **Factor dependence:** Gains from Sort & Slice increase when $L$ is small (higher hash collision rate), when ECFP diameter $D$ is large (more unique substructures), and when standard atom invariants are used (greater substructure diversity).
- **Supervised selection:** Filtered Fingerprints generally outperform standard hashing but not Sort & Slice, while MIM yields inconsistent improvements and trails Sort & Slice in nearly all settings.

Complementary work underscores that even classical hash-based ECFP with random forests, SVMs, or GBDT models outperforms modern D-MPNNs and chemical language models on ADMET property prediction, but these results do not employ collision-free pooling [2310.00174].

## 7. Recommendations and Implementation Considerations

Current consensus recommends replacing hash-based folding with Sort & Slice for ECFP vectorisation in supervised molecular machine learning. The method provides full feature interpretability, eliminates bit collisions, and requires minimal computational resources. Increasing the fingerprint length $L$ is only marginally beneficial beyond a certain point, as Sort & Slice prioritises the most informative substructures even at smaller $L$. Supervised selection (filtering or MIM) may not confer additional predictive value and can risk overfitting due to label dependence.

Limitations of Sort & Slice include the potential exclusion of rare but highly predictive fragments; hybrid strategies that combine frequency-based with supervised refinement may alleviate this. Possible advances involve trainable set functions for substructure-pooling, e.g., deep set architectures for end-to-end fragment embedding and pooling, as well as adaptive or task-specific selection of $L$.

In summary, ECFP with Sort & Slice pooling constitutes a robust, interpretable, and empirically superior strategy for molecular feature extraction in cheminformatics and supervised molecular machine learning [2403.17954, 2310.00174].

Source: https://www.emergentmind.com/topics/extended-connectivity-fingerprint-ecfp