SEFR (Scalable, Efficient, and Fast classifieR) is a linear-time binary classifier designed for ultra-low power and resource-constrained devices. Training and inference are a single pass over the data — no iterative optimization, no hyperparameters.
Keshavarz, Abadeh, Rawassizadeh — SEFR: A Fast Linear-Time Classifier for Ultra-Low Power Devices (2020)
Train on a microcontroller. Classify in microseconds. Model size = n_features + 1.
| SEFR | Typical sklearn pipeline | |
|---|---|---|
| Hyperparameters | None | Often many |
| Training complexity | O(n·m) | Varies (trees, SVM, …) |
| Model size | m + 1 floats | Often much larger |
| On-device training | Yes (Arduino demo) | Usually no |
SEFR assigns each feature a weight in ([-1, 1]) from class-conditional means (Eqs. 3–9 in the paper), then classifies with one dot product and a bias.
pip install numpy
pip install git+https://github.com/sefr-classifier/sefr.gitOr from a checkout:
git clone https://github.com/sefr-classifier/sefr.git
cd sefr
pip install -e .Scale features to [0, 1] (Min–Max, as in the paper). Labels must be 0 and 1.
from sefr import SEFR
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
clf = SEFR()
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)Multiclass (one-vs-all, paper Sec. 3.4):
from sefr import SEFRMulticlass
clf = SEFRMulticlass().fit(X_train, y_train)
y_pred = clf.predict(X_test)Run the included example:
python examples/quickstart.pyThe original repository exposed a single SEFR.py module:
from SEFR import SEFR # or: from sefr import SEFR
clf = SEFR()
clf.fit(X_train, y_train)
clf.predict(X_test)After training, clf.weights and clf.bias hold the learned model (same as the C/Arduino port).
The file arduino-c is the reference C implementation used in the paper’s Arduino Uno experiments (Gisette subsamples, sub-millisecond inference). See Section 4.6 of the paper.
sefr/
├── sefr/ # Python package
│ └── classifier.py # SEFR & SEFRMulticlass
├── SEFR.py # backward-compatible shim
├── arduino-c # MCU reference implementation
├── examples/ # quickstart
└── tests/
@article{keshavarz2020sefr,
title={SEFR: A Fast Linear-Time Classifier for Ultra-Low Power Devices},
author={Keshavarz, Hamidreza and Abadeh, Mohammad Saniee and Rawassizadeh, Reza},
journal={arXiv preprint arXiv:2006.04620},
year={2020}
}MIT — see LICENSE.
- Hamidreza Keshavarz
- Mohammad Saniee Abadeh
- Reza Rawassizadeh