Skip to content

Perceptron with associative array #1

@erelsgl

Description

@erelsgl

I wrote a perceptron with a small modification - allowing the weights (and features) to be strings. This may be more natural in settings such as text caterogization. Example:

var bird = perceptron()
bird.train({'wings': 2, 'legs': 2}, 1)
bird.train({'wings': 0, 'legs': 2}, 0)
bird.train({'wings': 2, 'legs': 4}, 0)
bird.train({'wings': 0, 'legs': 4}, 0)
while(!bird.retrain());

test.equal(bird.perceive({'wings': 2, 'legs': 2}), 1)
test.equal(bird.perceive({'wings': 0, 'legs': 2}), 0)
test.equal(bird.perceive({'wings': 2, 'legs': 4}), 0)
test.equal(bird.perceive({'wings': 0, 'legs': 4}), 0)

Would you like to add it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions