wisardpkg

ClusWisard

constructor:

from wisardpkg import ClusWisard

addressSize = 3 
minScore = 0.1 
threshold = 10
discriminatorLimit = 5

clus = ClusWisard(
   addressSize,              # required
   minScore,                 # required
   threshold,                # required
   discriminatorLimit,       # required
   bleachingActivated=True,  # optional
   ignoreZero=False,         # optional
   completeAddressing=True,  # optional
   verbose=False,            # optional
   indexes=[],               # optional
   base=2,                   # optional

   ## types of return of classify
   returnActivationDegree=False, # optional
   returnConfidence=False,       # optional
   returnClassesDegrees=False    # optional
)

The default value for the optional parameters are showing in the example above.

Types of return of classify:

By default the parameters ‘returnActivationDegree’, returnClassesDegrees and ‘returnConfidence’ are false, for performance reasons.

methods:

train

This method train with the data passed to it. In the case of labels, can be a list for supervised learning or a dictinary to semi-supervised learning.


# 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"
    ]

# load label data, which must be a dictionary with key integer and value string
y2 = {
       1: "cold",
       2: "hot
     }

# to supervised learning
clus.train(X, y)

# to semi-supervised learning
clus.train(X, y2)

Keep in mind that when a dataset is passed to this method, first it will train with supervised piece and after it will train with unsupervised piece.

trainUnsupervised

This method train with the data passed to it. This use the unsupervised learning.


# 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]
    ]

# to unsupervised learning
clus.trainUnsupervised(X)

classify

This method classify the data passed to it, based on what it learn, for supervised and semi-supervised learning.


# 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]
    ]

# the output is a list of string, this represent the classes atributed to each input
out = clus.classify(X)

for oneout in out:
    print(oneout)

classifyUnsupervised

This method classify the data passed to it, based on what it learn, for unsupervised learning.


# 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]
    ]

# the output is a list of string, this represent the classes atributed to each input
out = clus.classifyUnsupervised(X)

for oneout in out:
    print(oneout)

getMentalImages

This one show the pattern learned by the model, it return a dictionary where the key is of type string and it is the class and value is the list of list of integers representing the learned pattern for each discriminator in the cluster.

patterns = clus.getMentalImages()

for key in patterns:
    cluster = patterns[key]
    for index,discriminator in enumerate(cluster)
        print(key, index, discriminator)