Skip to content

Repository files navigation

SEFR

arXiv License: MIT Python 3.9+

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.


Why SEFR?

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.


Install

pip install numpy
pip install git+https://github.com/sefr-classifier/sefr.git

Or from a checkout:

git clone https://github.com/sefr-classifier/sefr.git
cd sefr
pip install -e .

Quick start

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.py

Original API (still supported)

The 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).


Arduino / embedded

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.


Project layout

sefr/
├── sefr/              # Python package
│   └── classifier.py  # SEFR & SEFRMulticlass
├── SEFR.py            # backward-compatible shim
├── arduino-c          # MCU reference implementation
├── examples/          # quickstart
└── tests/

Citation

@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}
}

License

MIT — see LICENSE.

Authors

  • Hamidreza Keshavarz
  • Mohammad Saniee Abadeh
  • Reza Rawassizadeh

About

The SEFR Classifier

Resources

Stars

62 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages