Changeset 8981:db95844528c6 in orange


Ignore:
Timestamp:
09/19/11 14:38:15 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
71a8fcfb9e5e14904e91061ed6ca8b542de59a2c
Message:

Refactored the code for LibSVM and LIBLINEAR. The sources are unmodified in liblinear and libsvm directories. Can be excluded from the build and instead linked to a system libraries instead.
The most significant change is in the way custom kernels are handled for SVMLearner - it now uses 'PRECOMPUTED' kernel functionality from LibSVM (as a bonus the results seem to be better then before (was there a bug in the previous code?), also faster)

Location:
source/orange
Files:
14 added
4 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • source/orange/Makefile

    r8980 r8981  
    66 
    77 
    8 r_imports.jpp: r_imports.hpp 
    9     $(PYTHON) ../pyxtract/jitlink_build.py R.so r_imports.hpp 
    10 r_imports.ipp: r_imports.hpp 
    11     $(PYTHON) ../pyxtract/jitlink_build.py R.so r_imports.hpp 
     8######################################################################### 
     9# If BLAS_LIB is not defiend then include a minimal subset of blas into 
     10# orange library. If BLAS_LIB is defined it must be the name of the blas 
     11# library to link with (e.g. blas). The libraries must be on the 
     12# search path.  
     13######################################################################### 
     14 
     15ifndef BLAS_LIB 
     16BLAS_OBJECTS = obj/daxpy.o obj/ddot.o obj/dnrm2.o obj/dscal.o obj/dcopy.o 
     17else 
     18BLAS_OBJECTS = 
     19LINKOPTIONS += -l$(BLAS_LIB) 
     20endif 
     21 
     22obj/%.o : blas/%.c blas/blas.h blas/blasp.h 
     23    $(CCOMPILER) $(COMPILEOPTIONS) -c $< -o $@ 
    1224 
    1325 
    14 # TODO: Dont compile BLAS if we can link with system (or user 
    15 # supplied) blas 
     26######################################################################### 
     27# If LIBLINEAR_LIB is not defiend then include a minimal subset of LIBLINEAR 
     28# into orange library. If LIBLINEAR_LIB is defined it must be the name of the 
     29# liblinear library to link with (e.g. linear). The library must be on the 
     30# search path.  
     31#########################################################################  
    1632 
    17 BLAS_OBJECTS = obj/daxpy.o obj/ddot.o obj/dnrm2.o obj/dscal.o obj/dcopy.o 
     33ifndef LIBLINEAR_LIB 
     34LIBLINEAR_OBJECTS = obj/linear.o obj/tron.o 
     35COMPILEOPTIONS += -Iliblinear # Add liblinear inclue dir to compile options 
     36else 
     37LIBLINEAR_OBJECTS = 
     38LINKOPTIONS += -l$(LIBLINEAR_LIB) 
     39endif 
     40 
     41obj/%.o : liblinear/%.cpp liblinear/%.h 
     42    $(COMPILER) $(COMPILEOPTIONS) -c $< -o $@ 
     43 
     44 
     45######################################################################### 
     46# If LIBSVM_LIB is not defiend then include a minimal subset of LIBSVM 
     47# into orange library. If LIBSVM_LIB is defined it must be the name of the 
     48# libsvm library to link with (e.g. svm). The library must be on the  
     49# search path.  
     50######################################################################### 
     51 
     52ifndef LIBSVM_LIB 
     53LIBSVM_OBJECTS = obj/svm.o 
     54else 
     55LIBSVM_OBJECTS = 
     56LINKOPTIONS += -l$(LIBSVM_LIB) 
     57endif 
     58 
     59obj/%.o : libsvm/%.cpp libsvm/%.h 
     60    $(COMPILER) $(COMPILEOPTIONS) -c $< -o $@ 
    1861     
    19 obj/%.o : blas/%.c blas/blas.h blas/blasp.h 
    20     $(CCOMPILER) $(COMPILEOPTIONS) -c $< -o $@ 
    2162 
    2263LINPACK_OBJECTS = obj/dqrsl.o obj/dqrdc2.o obj/dtrsl.o obj/linpack.o 
     
    2566    $(CCOMPILER) $(COMPILEOPTIONS) -c $< -o $@ 
    2667 
    27 $(OLD)/orange.so:   ppp/stamp px/stamp $(ORANGE_OBJECTS) $(BLAS_OBJECTS) $(LINPACK_OBJECTS) 
    28     $(LINKER) $(ORANGE_OBJECTS) $(BLAS_OBJECTS) $(LINPACK_OBJECTS) $(LINKOPTIONS) -o $(OLD)/orange.so 
     68ALL_OBJECTS = $(ORANGE_OBJECTS) $(BLAS_OBJECTS) $(LINPACK_OBJECTS) $(LIBLINEAR_OBJECTS) $(LIBSVM_OBJECTS) 
     69 
     70$(OLD)/orange.so:   ppp/stamp px/stamp $(ALL_OBJECTS) 
     71    $(LINKER) $(ALL_OBJECTS) $(LINKOPTIONS) -o $(OLD)/orange.so 
    2972ifeq ($(OS), Darwin) 
    3073    install_name_tool -id $(DESTDIR)/orange.so $(OLD)/orange.so 
     
    3376 
    3477clean: cleantemp 
    35     rm -f r_imports.ipp r_imports.jpp 
     78#   rm -f r_imports.ipp r_imports.jpp 
    3679    rm -f $(OLD)/orange.so $(OLD)/liborange.so 
  • source/orange/callback.hpp

    r6531 r8981  
    229229}; 
    230230 
    231 #include "svm.hpp" 
     231#include "libsvm_interface.hpp" 
    232232 
    233233class ORANGE_API TKernelFunc_Python : public TKernelFunc{ 
  • source/orange/lib_learner.cpp

    r8980 r8981  
    12571257 
    12581258/************ Linear **********/ 
    1259 #include "linear.hpp" 
     1259#include "liblinear_interface.hpp" 
    12601260C_CALL(LinearLearner - Orange.classification.svm.LinearLearner, Learner, "([examples] -/-> Classifier)") 
    12611261C_NAMED(LinearClassifier - Orange.classification.svm.LinearClassifier, ClassifierFD, " ") 
     
    12951295} 
    12961296 
    1297 /************* SVM ************/ 
    1298  
    1299 #include "svm.hpp" 
     1297/************* LIBSVM ************/ 
     1298 
     1299#include "libsvm_interface.hpp" 
    13001300C_CALL(SVMLearner - Orange.core.SVMLearner, Learner, "([examples] -/-> Classifier)") 
    13011301C_CALL(SVMLearnerSparse - Orange.core.SVMLearnerSparse, SVMLearner, "([examples] -/-> Classifier)") 
     
    14741474    if (!model) 
    14751475        raiseError("Error building LibSVM Model"); 
    1476     model->param.learner = NULL; 
    1477     PSVMClassifier svm = mlnew TSVMClassifier(classVar, examples, model, NULL); 
    1478     svm->kernelFunc = kernel; 
     1476//  model->param.learner = NULL; 
     1477    PSVMClassifier svm = mlnew TSVMClassifier(classVar, examples, model, NULL, kernel); 
     1478//  svm->kernelFunc = kernel; 
    14791479    svm->supportVectors = supportVectors; 
    14801480    return WrapOrange(svm); 
     
    15011501    if (!model) 
    15021502        raiseError("Error building LibSVM Model"); 
    1503     model->param.learner = NULL; 
    1504     PSVMClassifier svm = mlnew TSVMClassifierSparse(classVar, examples, model, NULL, useNonMeta != 0); 
    1505     svm->kernelFunc = kernel; 
     1503//  model->param.learner = NULL; 
     1504    PSVMClassifier svm = mlnew TSVMClassifierSparse(classVar, examples, model, NULL, useNonMeta != 0, kernel); 
     1505//  svm->kernelFunc = kernel; 
    15061506    svm->supportVectors = supportVectors; 
    15071507    return WrapOrange(svm); 
Note: See TracChangeset for help on using the changeset viewer.