Code Monkey home page Code Monkey logo

simple-extreme-learning-machine's Introduction

Build Status License: MIT Scala

A simple implementation of Extreme Learning Machine

This is a simple scala & Breeze implementation of an Extreme Learning Machine.

This library is designed to have great performances in scientific computation thanks to the linear algebra optimizations.

How to

In order to use take a look to the following example:

 import com.sircamp.elm.ExtremeLearningMachine


 var featuresLength = 28*28 //MINST dataset
 var hiddenLayerDimension = 1024
 val elm = new ExtremeLearningMachine(featuresLength, hiddenLayerDimension)
 
 /**
  Initialize the weights of the hidden layer with random uniform distribution
  Otherwise you can set the weights by your own. 
  Weights must be a DenseMatrix[Double] where rows are equal to the featuresLength
 **/
 elm.initializeWeights() 

 /**
  fit the model.
  XTrain and yTrain must be DenseMatrix[Double].
  yTrain must be the one hot encoded version of the original label
**/
 elm.fit(XTrain, yTrain)

/**
  predictClasses return a DenseVector[Int] with the index of the predicted class 
**/
 var yPred = elm.predictClasses(XTest)


/**
  predict return a DenseMatrix[Double] where each row contains the probability of the element to belongs to the class 
**/
 var yProbabilityPred = elm.predict(XTest)

 println("Accuracy: "+Metrics.accuracy_score(yPlain,yPred))

Set a different Activation function

import com.sircamp.elm.ExtremeLearningMachine


 var featuresLength = 28*28 //MINST dataset
 var hiddenLayerDimension = 1024
 val elm = new ExtremeLearningMachine(featuresLength, hiddenLayerDimension)
 
 /**
  Initialize the weights of the hidden layer with random uniform distribution
  Otherwise you can set the weights by your own. 
  Weights must be a DenseMatrix[Double] where rows are equal to the featuresLength
 **/
 elm.initializeWeights() 

 /**
   This return the LeakyReLu function with the alpha param
 **/
 elm.setActivationFunction(ActivationFunctions.leakyReLu(0.2))


 /**
   This return the Tanh function
 **/
 elm.setActivationFunction(ActivationFunctions.tanh)

For more example take a look to the tests

simple-extreme-learning-machine's People

Contributors

sircamp avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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