Giter Site home page Giter Site logo

svm.jl's Introduction

SVM.jl

THIS PACKAGE IS FORKED FROM https://github.com/JuliaStats/SVM.jl, AND ADAPTING JULIA 1.1.1.

SVMs in Julia

Native Julia implementations of standard SVM algorithms. Currently, there are textbook style implementations of two popular linear SVM algorithms:

  • Pegasos (Shalev-Schwartz et al., 2007)
  • Dual Coordinate Descent (Hsieh et al., 2008)

The svm function is a wrapper for pegasos, but it is possible to call cddual explicitly. See the source code for the hyperparameters of the cddual function.

Usage

The demo below shows how SVMs work:

# To show how SVMs work, we'll use Fisher's iris data set
using SVM
using RDatasets
using Random

# We'll learn to separate setosa from other species
iris = dataset("datasets", "iris")

# SVM format expects observations in columns and features in rows
X = convert(Array, iris[:, 1:4])'
p, n = size(X)

# SVM format expects positive and negative examples to +1/-1
y = [species == "setosa" ? 1.0 : -1.0 for species in iris[:Species]]

# Select a subset of the data for training, test on the rest.
train = bitrand(n)

# We'll fit a model with all of the default parameters
model = svm(X[:,train], y[train])

# And now evaluate that model on the testset
accuracy = sum(predict(model, X[:, .!train]) .== y[.!train])/sum(.!train)

You may specify non-default values for the various parameters:

# The algorithm processes minibatches of data of size k
model = svm(X, y, k = 150)

# Weight regularization is controlled by lambda
model = svm(X, y, lambda = 0.1)

# The algorithm performs T iterations
model = svm(X, y, T = 1000)

svm.jl's People

Contributors

johnmyleswhite avatar rottenfruits avatar lucasb-eyer avatar iainnz avatar dovahcrow avatar ararslan avatar chezou avatar stnava avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.