Add libocas 0.93, efficient training of SVM classifiers.

This commit is contained in:
Brendan Fabeny 2011-10-06 09:53:17 +00:00
parent 12e5a4bb2c
commit 7f3eda0a31
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=283033
6 changed files with 239 additions and 0 deletions

View file

@ -179,6 +179,7 @@
SUBDIR += liblbfgs
SUBDIR += libmath++
SUBDIR += libneural
SUBDIR += libocas
SUBDIR += liborigin
SUBDIR += libqalculate
SUBDIR += libranlip

64
math/libocas/Makefile Normal file
View file

@ -0,0 +1,64 @@
# New ports collection makefile for: libocas
# Date created: 5 Oct 2011
# Whom: b.f. <bf@FreeBSD.org>
#
# $FreeBSD$
#
PORTNAME= libocas
PORTVERSION= 0.93
CATEGORIES= math
MASTER_SITES= http://cmp.felk.cvut.cz/~xfrancv/ocas/ LOCAL/bf
DISTNAME= ${PORTNAME}_v${PORTVERSION:S/.//}
MAINTAINER= bf@FreeBSD.org
COMMENT= Efficient training of SVM classifiers
LICENSE= GPLv3
USE_GMAKE= yes
USE_LDCONFIG= yes
USE_ZIP= yes
ALL_TARGET= all linclass
LIBS= -lm ${PTHREAD_LIBS}
MAKE_ENV= MEXDETECTED=no
PLIST_FILES= bin/linclass bin/msvmocas bin/svmocas lib/libocas.so \
lib/libocas.so.1
.include <bsd.port.pre.mk>
.if ${ARCH} == sparc64
PICFLAG= -fPIC
.else
PICFLAG= -fpic
.endif
CFLAGS+= ${PICFLAG} ${PTHREAD_CFLAGS}
post-patch:
@${REINPLACE_CMD} \
-e '\|:=|d' \
-e 's|libocas\.so|&.1|' \
-e '\|$$(CC) $$(CFLAGS) -o|{s|$$(CFLAGS)|& ${LDFLAGS}|;s|$$| ${LIBS}|;}' \
${WRKSRC}/Makefile
do-install:
.for p in linclass msvmocas svmocas
@${INSTALL_PROGRAM} ${WRKSRC}/${p} ${PREFIX}/bin
.endfor
@${INSTALL_LIB} ${WRKSRC}/libocas.so.1 ${PREFIX}/lib
@${LN} -sf libocas.so.1 ${PREFIX}/lib/libocas.so
check regression-test test: build
${WRKSRC}/msvmocas -c 10 -v 1 ${WRKSRC}/data/example4_train.light \
${WRKSRC}/data/msvmocas.model
${WRKSRC}/linclass -e -v 1 -o ${WRKSRC}/data/exaple4_test.pred \
${WRKSRC}/data/example4_test.light ${WRKSRC}/data/msvmocas.model
${WRKSRC}/svmocas -c 10 -b 1 -v 1 ${WRKSRC}/data/riply_trn.light \
${WRKSRC}/data/svmocas.model
${WRKSRC}/linclass -e -v 1 -o ${WRKSRC}/data/riply_tst.pred \
${WRKSRC}/data/riply_tst.light ${WRKSRC}/data/svmocas.model
.include <bsd.port.post.mk>

2
math/libocas/distinfo Normal file
View file

@ -0,0 +1,2 @@
SHA256 (libocas_v093.zip) = 341b4b1ab5594a6d2a92fdff1654aa320b6845412c97f5493c92d48cf6618aae
SIZE (libocas_v093.zip) = 3328943

View file

@ -0,0 +1,142 @@
--- linclass.c.orig 2010-05-05 08:55:55.000000000 -0400
+++ linclass.c 2011-10-06 05:11:23.000000000 -0400
@@ -62,7 +62,7 @@
uint32_t i, j;
int len;
int recognized;
- int exitflag = 0;
+ int exitflag = 1;
int verb;
int binary_problem;
int output_type;
@@ -101,6 +101,8 @@
feat_idx = NULL;
W = NULL;
W0 = 0;
+ input_fname = NULL;
+ model_fname = NULL;
output_fname = NULL;
nClassErrors = NULL;
nClass = NULL;
@@ -275,6 +277,7 @@
if(fgets(line,LIBSLF_MAXLINELEN, fid) == NULL )
{
fprintf(stderr,"Empty example file.\n");
+ fclose(fid);
goto clean_up;
}
else
@@ -312,6 +315,7 @@
if( tmp_nCols != nCols)
{
fprintf(stderr,"Error: Model file contains lines with different number of colums.\n");
+ fclose(fid);
goto clean_up;
}
@@ -340,6 +344,7 @@
if(W == NULL)
{
fprintf(stderr,"Not enough memory for vector W.\n");
+ fclose(fid);
goto clean_up;
}
@@ -355,6 +360,7 @@
if(fgets(line,LIBSLF_MAXLINELEN, fid) == NULL )
{
fprintf(stderr,"Model file corrupted.\n");
+ fclose(fid);
goto clean_up;
}
@@ -364,6 +370,7 @@
if(val == 0 && begptr == endptr)
{
fprintf(stderr,"Model file corrupted.\n");
+ fclose(fid);
goto clean_up;
}
@@ -388,6 +395,7 @@
if(W == NULL)
{
fprintf(stderr,"Not enough memory for matrix W.\n");
+ fclose(fid);
goto clean_up;
}
@@ -403,6 +411,7 @@
if(fgets(line,LIBSLF_MAXLINELEN, fid) == NULL )
{
fprintf(stderr,"Model file corrupted.\n");
+ fclose(fid);
goto clean_up;
}
@@ -414,6 +423,7 @@
if(val == 0 && begptr == endptr)
{
fprintf(stderr,"Model file corrupted.\n");
+ fclose(fid);
goto clean_up;
}
begptr = endptr;
@@ -458,7 +468,7 @@
else
{
fout = fopen(output_fname, "w+");
- if(fid == NULL) {
+ if(fout == NULL) {
fprintf(stderr,"Cannot open output file.\n");
perror("fopen error ");
fclose(fid);
@@ -478,6 +488,9 @@
if(nClassErrors == NULL)
{
fprintf(stderr,"Not enough memory for vector nClassError.\n");
+ fclose(fid);
+ if(output_fname != NULL)
+ fclose(fout);
goto clean_up;
}
@@ -485,6 +498,9 @@
if(nClass == NULL)
{
fprintf(stderr,"Not enough memory for vector nClass.\n");
+ fclose(fid);
+ if(output_fname != NULL)
+ fclose(fout);
goto clean_up;
}
@@ -505,6 +521,9 @@
{
fprintf(stderr,"Parsing error on line %ld .\n", line_cnt);
fprintf(stderr,"Probably defective input file.\n");
+ fclose(fid);
+ if(output_fname != NULL)
+ fclose(fout);
goto clean_up;
}
@@ -612,12 +631,16 @@
fclose(fid);
- fclose(fout);
+ if(output_fname != NULL)
+ fclose(fout);
- exitflag = 1;
+ exitflag = 0;
clean_up:
+ free(input_fname);
+ free(model_fname);
+ free(output_fname);
free(W);
free(line);
free(feat_val);

View file

@ -0,0 +1,20 @@
--- msvmocas.c.orig 2010-05-05 08:55:55.000000000 -0400
+++ msvmocas.c 2011-10-06 05:20:07.000000000 -0400
@@ -91,6 +91,8 @@
total_time = get_time();
/* init */
+ input_fname = NULL;
+ model_fname= NULL;
data_X = NULL;
data_y = NULL;
W = NULL;
@@ -508,6 +510,8 @@
clean_up:
+ free(input_fname);
+ free(model_fname);
mxDestroyArray(data_X);
mxFree(data_y);
mxFree(W);

10
math/libocas/pkg-descr Normal file
View file

@ -0,0 +1,10 @@
libocas implements an Optimized Cutting Plane Algorithm (OCAS) for training
linear SVM classifiers from large-scale data. The computational effort of
OCAS scales with O(m log m) where m is the sample size. In an extensive
empirical evaluation, OCAS significantly outperforms current state-of-the-art
SVM solvers.
libocas also implements the COFFIN framework for efficient training of
translation invariant image classifiers from virtual examples.
WWW: http://cmp.felk.cvut.cz/~xfrancv/ocas/html/index.html