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.
By default the parameters ‘returnActivationDegree’, returnClassesDegrees and ‘returnConfidence’ are false, for performance reasons.
[
{'class': 'cold', 'activationDegree': 1.0, 'confidence': 0.800000011920929},
{'class': 'hot', 'activationDegree': 1.0, 'confidence': 1.0}
]
If only one of them is true, so only it will appear in the dictionary. when all are false, so the classify method will return a list of strings.
jsonConfig = wsd.json()
wsd2 = Wisard(jsonConfig)
The wisard can be saved with json or jsonConfig methods and reloaded later with this value.
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)
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)
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])
This will untrain an input trained before.
x = [1,1,1,0,0,0,0,0]
wsd.leaveOneOut(x,"cold")
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)
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"))
This do the same as json() method, but without ram values.
print("Wisard: ", wsd.jsonConfig())