GithubHelp home page GithubHelp logo

vladperervenko / pyoselm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leferrad/pyoselm

0.0 1.0 0.0 25 KB

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

License: Apache License 2.0

Python 100.00%

pyoselm's Introduction

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.

Link: https://pdfs.semanticscholar.org/2ebd/fa3852e4ad68a0cfde9f0f69b95953d69178.pdf

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]

    oselmr.fit(x_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)
random.shuffle(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):
    oselmc.fit(b_x, b_y)

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

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

pyoselm's People

Contributors

leferrad avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.