lalvim / Perceptrons.jl

A set of perceptron algorithms
Other
5 stars 1 forks source link
averaged-perceptron bigdata julia-language julia-package julialang kernel-perceptron machine-learning machine-learning-algorithms online-learning perceptron sparse-perceptron structured-perceptron voted-perceptron

Perceptrons.jl

A package with several types of Perceptron classifiers. Perceptrons are fast classifiers and can be used even for big data. Up to now, this package contains a linear perceptron, voted perceptron and a Kernel perceptron for binary classification problems. This project will have the following perceptron classifiers: Multiclass, Kernel, Structured, Voted, Average and Sparse. Some state-of-the-art must be included after these.

Build Status

Coverage Status

codecov.io

Install

Pkg.add("Perceptrons")

Using

using Perceptrons

Examples

using Perceptrons

# training a linear perceptron (solving the OR problem)
X_train        = [1.0 1.0; 0.0 1.0; 1.0 0.0; 0.0 0.0]
Y_train        = [1; 1; 1; 0.0]
X_test         = [.8 .9; .01 1; .9 0.2; 0.1 0.2]

model          = Perceptrons.fit(X_train,Y_train)
Y_pred         = Perceptrons.predict(model,X_test)

println("[Perceptron] accuracy : $(acc(Y_train,Y_pred))")

# training a voted perceptron (solving the OR problem)
model   = Perceptrons.fit(X_train,Y_train,centralize=true,mode="voted")
Y_pred  = Perceptrons.predict(model,X_test)

println("[Voted Perceptron] accuracy : $(acc(Y_train,Y_pred))")

# training a averaged perceptron (solving the OR problem)
model   = Perceptrons.fit(X_train,Y_train,centralize=true,mode="averaged")
Y_pred  = Perceptrons.predict(model,X_test)

println("[Averaged Perceptron] accuracy : $(acc(Y_train,Y_pred))")

# training a kernel perceptron (solving the XOR problem)
X_train = [1.0 1.0; 0.0 1.0; 1.0 0.0; 0.0 0.0]
Y_train = [0.0 ; 1.0; 1.0; 0.0]
X_test  = X_train .+ .03 # adding noise

model   = Perceptrons.fit(X_train,Y_train,centralize=true,mode="kernel",kernel="rbf",width=.01)
Y_pred  = Perceptrons.predict(model,X_test)

println("[Kernel Perceptron] accuracy : $(acc(Y_train,Y_pred))")

# if you want to save your model
Perceptrons.save(model,filename=joinpath(homedir(),"perceptron_model.jld"))

# if you want to load back your model
model = Perceptrons.load(filename=joinpath(homedir(),"perceptron_model.jld"))

What is Implemented

What is Upcoming

Method Description

References

TODO

License

The Perceptrons.jl is free software: you can redistribute it and/or modify it under the terms of the MIT "Expat" License. A copy of this license is provided in LICENSE.md