GithubHelp home page GithubHelp logo

gbhering / wisardpkg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iazero/wisardpkg

0.0 2.0 0.0 352 KB

A set of models based on wisard.

Home Page: https://iazero.github.io/wisardpkg/

License: MIT License

Makefile 0.06% Python 1.36% C++ 98.54% Shell 0.04%

wisardpkg's Introduction

wisardpkg

Description

This is a project to make available the different models based on WiSARD, with high performance, ease of usage and installation and following a single usage pattern for simplicity. These provided models are machine learning models, with supervised, unsupervised and semi-supervised learning.

Install

pip

pip install wisardpkg

Works with both python2 and pyhton3.
If you are not in a virtual environment, you may need to run as su (by appending sudo to the beginning).

Windows

Python

To install on windows platform you can use anaconda and run:

python -m pip install wisardpkg
C++

You can include the header file include/wisardpkg.hpp in your project.

Uninstall

pip uninstall wisardpkg

Import

Python

import wisardpkg as wp

C++

# include "wisardpkg.hpp"

namespace wp = wisardpkg;

Usage

WiSARD

WiSARD with bleaching by default:

Python

# load input data, just zeros and ones  
X = [
      [1,1,1,0,0,0,0,0],
      [1,1,1,1,0,0,0,0],
      [0,0,0,0,1,1,1,1],
      [0,0,0,0,0,1,1,1]
    ]

# load label data, which must be a string array
y = [
      "cold",
      "cold",
      "hot",
      "hot"
    ]


addressSize = 3     # number of addressing bits in the ram
ignoreZero  = False # optional; causes the rams to ignore the address 0

# False by default for performance reasons,
# when True, WiSARD prints the progress of train() and classify()
verbose = True

wsd = wp.Wisard(addressSize, ignoreZero=ignoreZero, verbose=verbose)



# train using the input data
wsd.train(X,y)

# classify some data
out = wsd.classify(X)

# the output of classify() is a string list in the same sequence as the input
for i,d in enumerate(X):
   print(out[i],d)

C++

vector<vector<int>> X(4);
X[0] = {1,1,1,0,0,0,0,0};
X[1] = {1,1,1,1,0,0,0,0};
X[2] = {0,0,0,0,1,1,1,1};
X[3] = {0,0,0,0,0,1,1,1};

vector<string> y = {
      "cold",
      "cold",
      "hot",
      "hot"
};


wp::Wisard w(3, {
      {"ignoreZero", false},
      {"verbose", true}
});

w.train(X,y);

vector<string> out = w.classify(X);

for(int i=0; i<4; i++){
      cout << "i: " << i << "; class: " << out[i] << endl;
}

ClusWiSARD

ClusWiSARD with bleaching by default:

addressSize        = 3    # number of addressing bits in the ram.
minScore           = 0.1  # min score of training process
threshold          = 10   # limit of training cycles by discriminator
discriminatorLimit = 5    # limit of discriminators by clusters

# False by default for performance reasons
# when enabled,e ClusWiSARD prints the progress of train() and classify()
verbose = True

clus = ClusWisard(addressSize, minScore, threshold, discriminatorLimit, verbose=True)



# train using the input data
clus.train(X,y)

# optionally you can train using arbitrary labels for the data
# input some labels in a dict,
# the keys must be integer indices indicating which input array the entry is associated to,
# the values are the labels which must be strings
y2 = {
  1: "cold",
  3: "hot"
}

clus.train(X,y2)

# classify some data
out = clus.classify(X)

# the output of classify is a string list in the same sequence as the input
for i,d in enumerate(X):
    print(out[i], d)

Documentation

You can find the complete documentation in iazero.github.io/wisardpkg.

Built with

wisardpkg's People

Contributors

aluiziolimafilho avatar gbhering avatar gabrielguarisa avatar

Watchers

James Cloos 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.