Constructor
new Perceptron()
- Source:
- See:
-
- of
Example
const m = Perceptron.of([0.2365698, 0.4567897, 0.95989898, -0.457878787])
Members
Methods
(static) of(weights) → {Perceptron}
Creates a Perceptron object
- Source:
Parameters:
Name | Type | Description |
---|---|---|
weights |
array
|
Weights for predicting |
Returns:
- Type:
-
Perceptron
Example
const weights = [0.123456, 0.458789, 0.9987454]
const m = Perceptron.of(weights)
predict(row) → {Boolean}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
row |
Array
|
Array of values to predict |
Returns:
- Type:
-
Boolean
Example
const m = Perceptron.of()
const train = [...] // dataset: [[0,1,2], [1,2,3]]
m.train(train, 0.1, 10000)
m.predict([1,2,1]) // returns 1 or 0
train(train, lRate, nEpoch)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
train |
Array
|
Dataset to train the preceptron |
lRate |
Number
|
Set the learning rate of the perceptron |
nEpoch |
Number
|
Set the number of iterations to train the perceptron |
Example
const m = Perceptron.of()
const train = [...] // dataset: [[0,1,2], [1,2,3]]
m.train(train, 0.1, 10000)
m.weights = [0.213131, -0.45464, 0.789797]