Skip to main content

A library of wisard with some models based on wisard

Project description

wisardpkg

Description:

This is a project to make available the different models based on WiSARD, with high performance, easy to use and to install and following a pattern of use. These provided models are machine learning models, with supervised, unsupervised and semi-supervised learning.

to install:

python:

pip install wisardpkg

Works to python2 and pyhton3.
If you are on Linux and not in a virtual environment, you may need to run as superuser.

obs:

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

python -m pip install wisardpkg

c++: copy the file wisardpkg.hpp inside your project

include/wisardpkg.hpp

to uninstall:

pip uninstall wisardpkg

to import:

python:

import wisardpkg as wp

c++:

# include "wisardpkg.hpp"

namespace wp = wisardpkg;

to use:

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 the page.

Build on libraries:

pybind11 nlohmann/json

Project details


Download files

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

Source Distribution

wisardpkg-1.6.3.tar.gz (126.5 kB view details)

Uploaded Source

File details

Details for the file wisardpkg-1.6.3.tar.gz.

File metadata

  • Download URL: wisardpkg-1.6.3.tar.gz
  • Upload date:
  • Size: 126.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for wisardpkg-1.6.3.tar.gz
Algorithm Hash digest
SHA256 c4d8cd15389c7945a9ed4ca79591a495912fd91842468abc83ac23a1951d17de
MD5 6c7a3a73103ce62a05493715df5438c2
BLAKE2b-256 f16d02c4cc15ce041f26710fdf319bbb469372b22212fe5c8364615fe8b25f72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page