Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A Python implementation of Online Sequential Extreme Machine Learning (OS-ELM) for online machine learning

Project description

# pyoselm

*A Python implementation of Online Sequential Extreme Machine Learning (OS-ELM) for online machine learning*

[![Build Status](](

### Dependencies

- Numpy
- Scipy
- Scikit-learn

Original publication:

> Huang, G. B., Liang, N. Y., Rong, H. J., Saratchandran, P., & Sundararajan, N. (2005).
On-Line Sequential Extreme Learning Machine. Computational Intelligence, 2005, 232-237.


Implementation strongly based on the following repos:


### Usage

from pyoselm import OSELMRegressor, OSELMClassifier
from sklearn.datasets import load_digits, make_regression
import random

# --- Regression problem ---
# Model
oselmr = OSELMRegressor(n_hidden=20, activation_func='tanh')
# Data
x, y = make_regression(n_samples=400, n_targets=1, n_features=10)
n_batch = 20

# Fit model with chunks of data
for i in range(20):
x_batch = x[i*n_batch:(i+1)*n_batch]
y_batch = y[i*n_batch:(i+1)*n_batch], y_batch)
print("Train score for batch %i: %s" % (i+1, str(oselmr.score(x_batch, y_batch))))

# Results
print("Train score of total: %s" % str(oselmr.score(x, y)))

# --- Classification problem ---
# Model
oselmc = OSELMClassifier(n_hidden=20, activation_func='sigmoid')
# Data
x, y = load_digits(n_class=10, return_X_y=True)

# Shuffle data (to have batches with more than one class)
zip_x_y = zip(x, y)
x, y = [x_y[0] for x_y in zip_x_y], [x_y[1] for x_y in zip_x_y]

# Sequential learning
# The first batch of data should have the same size as neurons in the model to achieve the 1st phase (boosting)
batches_x = [x[:oselmc.n_hidden]] + [[x_i] for x_i in x[oselmc.n_hidden:]]
batches_y = [y[:oselmc.n_hidden]] + [[y_i] for y_i in y[oselmc.n_hidden:]]

for b_x, b_y in zip(batches_x, batches_y):, b_y)

print("Train score of total: %s" % str(oselmc.score(x, y)))


NOTE: Chuck-by-chunk is faster than one-by-one

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyoselm, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pyoselm-0.1.0.tar.gz (12.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page