Skip to content
This repository has been archived by the owner on May 12, 2019. It is now read-only.

Commit

Permalink
Minimal interface to libSVM
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmyleswhite committed Jan 16, 2013
0 parents commit 8474f5e
Show file tree
Hide file tree
Showing 23 changed files with 5,829 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/svm*
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
All Julia code under MIT license.

All libSVM code under the license found in deps/COPYRIGHT. This copyright
covers all files in:

* bin: svm-train, svm-predict
* deps: libsvm-3.14 code
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SVM.jl
======

# About

An interface to libSVM from Julia

# Installation

* Go into `deps`
* Run `make`
* Run `cp svm-train ../bin`
* Run `cp svm-predict ../bin`

# Usage

using SVM

labels = [1, -1, -1, 1, 1, -1]

features = [1.0 0.0;
0.0 -1.0;
0.0 -0.9;
0.9 0.1;
1.0 1.0;
-1.0 -1.0;]

model = svm(labels, features)

predictions = predict(model, features)

# To Do

* Use binary interface to libSVM instead of libSVM text format
* Convert sparse matrices to libSVM format
* Restore `Makefile.win` and `windows` in `deps`
* Allow users to configure SVM model fitting process
Empty file added bin/.gitignore
Empty file.
31 changes: 31 additions & 0 deletions deps/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Copyright (c) 2000-2012 Chih-Chung Chang and Chih-Jen Lin
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither name of copyright holders nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 changes: 25 additions & 0 deletions deps/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CXX ?= g++
CFLAGS = -Wall -Wconversion -O3 -fPIC
SHVER = 2
OS = $(shell uname)

all: svm-train svm-predict svm-scale

lib: svm.o
if [ "$(OS)" = "Darwin" ]; then \
SHARED_LIB_FLAG="-dynamiclib -Wl,-install_name,libsvm.so.$(SHVER)"; \
else \
SHARED_LIB_FLAG="-shared -Wl,-soname,libsvm.so.$(SHVER)"; \
fi; \
$(CXX) $${SHARED_LIB_FLAG} svm.o -o libsvm.so.$(SHVER)

svm-predict: svm-predict.c svm.o
$(CXX) $(CFLAGS) svm-predict.c svm.o -o svm-predict -lm
svm-train: svm-train.c svm.o
$(CXX) $(CFLAGS) svm-train.c svm.o -o svm-train -lm
svm-scale: svm-scale.c
$(CXX) $(CFLAGS) svm-scale.c -o svm-scale
svm.o: svm.cpp svm.h
$(CXX) $(CFLAGS) -c svm.cpp
clean:
rm -f *~ svm.o svm-train svm-predict svm-scale libsvm.so.$(SHVER)
Loading

0 comments on commit 8474f5e

Please sign in to comment.