wisardpkg

Wisard

constructors:

type 1

addressSize=3

wsd = Wisard(
   addressSize,              # required
   bleachingActivated=True,  # optional
   ignoreZero=False,         # optional
   completeAddressing=True,  # optional
   verbose=False,            # optional
   indexes=[],               # optional
   base=2,                   # optional
   confidence=1,             # 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.

type 2

jsonConfig = wsd.json()
wsd2 = Wisard(jsonConfig)

The wisard can be saved with json or jsonConfig methods and reloaded later with this value.

methods:

train

This method train with the data passed to it.


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

wsd.train(X, y)

classify

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


# 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 attributed to each input
out = wsd.classify(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 integer representing the learned pattern.

patterns = wsd.getMentalImages()

for key in patterns:
    print(key, patterns[key])

leaveOneOut

This will untrain an input trained before.

x = [1,1,1,0,0,0,0,0]
wsd.leaveOneOut(x,"cold")

leaveMoreOut

This will untrain a list of inputs trained before.

X = [
   [1,1,1,0,0,0,0,0],
   [0,0,0,0,1,1,1,1],
]
y = [
   "cold",
   "hot"
]
wsd.leaveMoreOut(X,y)

json

This return the configuration and ram values as JSON format converted to string.

print("Wisard: ", wsd.json())
# or pass true as parameter to save ram data in files (this is useful for huge rams)
print("Wisard: ", wsd.json(True,"path/to/save/data"))

jsonConfig

This do the same as json() method, but without ram values.

print("Wisard: ", wsd.jsonConfig())