NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Protein sequence classification using feature hashing

Cornelia Caragea, Adrian Silvescu, Prasenjit Mitra

Abstract

Recent advances in next-generation sequencing technologies have resulted in an exponential increase in the rate at which protein sequence data are being acquired. The k-gram feature representation, commonly used for protein sequence classification, usually results in prohibitively high dimensional input spaces, for large values of k. Applying data mining algorithms to these input spaces may be intractable due to the large number of dimensions. Hence, using dimensionality reduction techniques can be crucial for the performance and the complexity of the learning algorithms. In this paper, we study the applicability of feature hashing to protein sequence classification, where the original high-dimensional space is "reduced" by hashing the features into a low-dimensional space, using a hash function, i.e., by mapping features into hash keys, where multiple features can be mapped (at random) to the same hash key, and "aggregating" their counts. We compare feature hashing with the "bag of k-grams" approach. Our results show that feature hashing is an effective approach to reducing dimensionality on protein sequence classification tasks.

Introduction

In the era of next-generation sequencing, the volume of protein sequence data is growing exponentially. Classifying these sequences—for instance, to determine their subcellular localization—is a fundamental task in computational biology. Traditionally, proteins are represented as sequences of amino acids, and researchers employ $k$-gram features (contiguous sub-sequences of length $k$) to capture local structural and functional information.

However, this approach faces the "curse of dimensionality." With 20 standard amino acids, the number of possible $k$-grams grows as $20^k$. For $k=4$, there are 160,000 possible features; for $k=5$, this jumps to 3.2 million. Storing and processing such high-dimensional vectors is computationally expensive and memory-intensive, often making standard machine learning algorithms intractable.

Methodology: The Feature Hashing Approach

To address the dimensionality bottleneck, this study explores the use of feature hashing (also known as the "hashing trick"). Instead of maintaining an explicit dictionary of all possible $k$-grams, feature hashing uses a hash function to map features directly into a fixed-size vector of dimension $b$.

Figure 1: The feature hashing pipeline, from protein sequence to classification.

The process involves three main steps:

  1. Feature Generation: Sequences are decomposed into $k$-grams. The authors found that variable-length $k$-grams (e.g., combining 1-grams through 4-grams) provide a richer signal than fixed-length representations.
  2. Hashing: Each $k$-gram is mapped to an index in a vector of size $b$. To mitigate the impact of collisions (where different $k$-grams map to the same index), a second hash function determines a sign (+1 or -1) for the feature value. This ensures that the expected value of the inner product in the hashed space remains an unbiased estimator of the inner product in the original space.
  3. Classification: The resulting compressed vectors are used as input for a linear Support Vector Machine (SVM) using the LibLinear library.

Experimental Results

The effectiveness of feature hashing was evaluated on three datasets: psortNeg (bacterial sequences), plant, and non-plant protein sequences.

Dimensionality and Performance

The experiments demonstrated that feature hashing achieves performance parity with the full "bag of $k$-grams" approach while using significantly less memory. On the non-plant dataset, the model achieved 82.83% accuracy using (1-4)-grams. A key finding was the "sweet spot" for hash size: accuracy improves as the hash size $b$ increases but plateaus around $2^{16}$ (65,536 dimensions). Beyond this point, further increases in dimensionality yield negligible gains, suggesting that the essential biological information is successfully captured even with significant compression.

Discussion: Why Hashing Works for Proteins

The success of feature hashing in this domain is largely explained by the distribution of $k$-grams. Like many natural languages, protein $k$-grams follow a Zipf distribution.

Figure 6: Log-log plot showing the Zipf distribution of k-grams in the psortNeg dataset.

As shown in Figure 6, a small number of $k$-grams appear very frequently, while the vast majority are rare. In a hashed space, the probability of two high-frequency (highly informative) features colliding is low. Most collisions occur between rare "noise" features, which has a minimal impact on the overall classification performance. This inherent property of biological sequences makes them ideal candidates for hashing-based dimensionality reduction.

Conclusion

Feature hashing provides a robust and efficient alternative to traditional $k$-gram representations for protein sequence classification. By decoupling the feature space from the vocabulary size, it enables the processing of massive datasets with a fixed memory footprint. Future work may involve comparing this approach to specialized biological kernels, such as mismatch string kernels, and exploring feature abstraction techniques to further enhance the signal-to-noise ratio.

Summary updated

BibTeX
@inproceedings{caragea2012protein,
  author = {Cornelia Caragea and Adrian Silvescu and Prasenjit Mitra},
  title = {{Protein sequence classification using feature hashing}},
  booktitle = {Proteome},
  year = {2012},
  doi = {10.1186/1477-5956-10-s1-s14},
}
Figure