diff --git a/Makefile b/Makefile index 3a5ca13..28eca4e 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,13 @@ +# These are the directories that contain everything we need after 'make setup' +# is completed. We assume that 'matlab' is available on the PATH. +export INCLUDEPATH := $(shell pwd)/libraries/include/ +export LIBPATH := $(shell pwd)/libraries/lib/ +export BINPATH := $(shell pwd)/libraries/bin/ +export JAVAPATH := $(shell pwd)/libraries/share/ +export DEBUGBINPATH := $(shell pwd)/libraries/debug/bin/ +export DEBUGINCLUDEPATH := $(shell pwd)/libraries/debug/include/ +export DEBUGLIBPATH := $(shell pwd)/libraries/debug/lib/ + # Locate the python bin. PYTHON_BIN := $(shell which python3.3) ifndef PYTHON_BIN @@ -38,52 +48,10 @@ COPY := False USER := "" PASSWORD := "" -################################################################################################ -# How to use: # -# Specify the environment variables in this file or set these variables from the command line. # -# All environment path variables should end with a slash. # -# Note that four settings need to be changed for this to work. # -# 1) SHOGUN_PATH # -# 2) PYTHONPATH # -# 3) WEKA_CLASSPATH # -# 4) MATLAB_BIN # -################################################################################################ - -# Set the environment variable for the mlpack executables. - -ifdef $(shell which mlpack_knn) - export MLPACK_BIN=$(shell dirname $(firstword $(shell which mlpack_knn)))/ -else - export MLPACK_BIN="" -endif - -# Set the environment variable for the mlpack executables. -export MLPACK_BIN_DEBUG=$(MLPACK_BIN) - -# Export the MLPACK_PATH environment variable. -export MLPACK_PATH=$(shell dirname $(MLPACK_BIN))/ +# Set the environment variable for the compiled mlpack executables. export MLPACK_BIN_SRC=methods/mlpack/src/build/ export MLPACK_BIN_DEBUG_SRC=methods/mlpack/src/build/ -# Set the environment variable for the matlab executable. -# You can use the following command to search the 'matlab' file everytime: -# export MATLAB_BIN=$(shell find / -name matlab -print 2>/dev/null -quit) -export MATLAB_BIN="" - -# Export the MATLABPATH environment variable. -export MATLABPATH=$(shell pwd)/methods/matlab/ - -# Export the WEKA_CLASSPATH environment variable. -# You can use the following command to search the 'weka.jar' file everytime: -# export WEKA_CLASSPATH=".:$(shell find / -name weka.jar -print 2>/dev/null -quit)" -export WEKA_CLASSPATH=".:/Users/marcus/Downloads/weka-3-6-11/weka.jar" - -# Export the SHOGUN_PATH environment variable. -export SHOGUN_PATH="" - -# Export the PYTHONPATH environment variable. -export PYTHONPATH="" - # Set the environment variable for the the ms_print executable. export MS_PRINT_BIN=$(shell which ms_print) @@ -92,12 +60,14 @@ export VALGRIND_BIN=$(shell which valgrind) # Export the path to the FLANN library. export FLANN_PATH=methods/flann/ - # Export the path to the ANN library. export ANN_PATH=methods/ann/ -# Export the path to the HLearn library. -export HLEARN_PATH="" +# Set LD_LIBRARY_PATH correctly. +export LD_LIBRARY_PATH=$(shell echo $(LIBPATH)) +# Set PYTHONPATH correctly. +PYVERSION=$(shell python3 -c 'import sys; print("python" + sys.version[0:3])') +export PYTHONPATH=$(shell printenv PYTHONPATH):$(shell pwd)/libraries/lib/$(shell echo $(PYVERSION))/dist-packages:$(shell pwd)/libraries/lib/$(shell echo $(PYVERSION))/site-packages # Color settings. NO_COLOR=\033[0m @@ -200,11 +170,14 @@ endif .scripts: # Compile the java files for the weka methods. - javac -cp $(shell echo $(WEKA_CLASSPATH)) -d methods/weka methods/weka/src/*.java + javac -cp $(shell echo $(JAVAPATH)/weka.jar) -d methods/weka methods/weka/src/*.java # Compile the ann scripts. - g++ -O0 -std=c++11 methods/ann/src/allknn.cpp -o methods/ann/allknn -I$(MLPACK_PATH)/include -I$(ANN_PATH)/include -L$(MLPACK_PATH)/lib -L$(ANN_PATH)/lib -lANN -lmlpack -lboost_program_options + g++ -O0 -std=c++11 methods/ann/src/allknn.cpp -o methods/ann/allknn -I$(INCLUDEPATH) -L$(LIBPATH) -lANN -lmlpack -lboost_program_options # Compile the FLANN scripts. - g++ -O0 -std=c++11 methods/flann/src/allknn.cpp -o methods/flann/allknn -I$(MLPACK_PATH)/include -I$(FLANN_PATH)/include -L$(MLPACK_PATH)/lib -L$(FLANN_PATH)/lib -lmlpack -lboost_program_options + g++ -O0 -std=c++11 methods/flann/src/allknn.cpp -o methods/flann/allknn -I$(INCLUDEPATH) -L$(LIBPATH) -lmlpack -lboost_program_options -llz4 + # Compile the mlpack scripts. (Can't do this until ANN is released or a + # git version of mlpack is used.) + #cd methods/mlpack/src/ && ./build_scripts.sh .setup: cd libraries/ && ./download_packages.sh && ./install_all.sh diff --git a/README.md b/README.md index 00cd9ff..42eb29f 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Benchmarks are run with the `make` command. * `make run` -- Perform the benchmark. * `make memory` -- Get memory profiling information. * `make test` -- Test the configuration file. Check for correct syntax and then try to open files referred in the configuration file. +* `make setup` -- Download and set up all of the libraries to compare against. * `make scripts` -- Make additional scripts. diff --git a/config.yaml b/config.yaml index f0dfde2..87beffe 100644 --- a/config.yaml +++ b/config.yaml @@ -1967,28 +1967,6 @@ methods: 'datasets/Twitter.csv', 'datasets/tinyImages100k.csv'] options: '-k 3 -s 42 -e 0.25' --- -# HLearn: Homomorphic machine learning -library: hlearn -methods: - ALLKNN: - run: ['metric'] - script: methods/hlearn/allknn.py - format: [csv, txt] - datasets: - - files: ['datasets/wine.csv', 'datasets/cloud.csv', - 'datasets/wine_qual.csv', 'datasets/isolet.csv', - 'datasets/corel-histogram.csv', 'datasets/covtype.csv', - 'datasets/1000000-10-randu.csv', 'datasets/mnist_all.csv', - 'datasets/Twitter.csv', 'datasets/tinyImages100k.csv'] - options: '-k 3' - - - files: ['datasets/wine.csv', 'datasets/cloud.csv', - 'datasets/wine_qual.csv', 'datasets/isolet.csv', - 'datasets/corel-histogram.csv', 'datasets/covtype.csv', - 'datasets/1000000-10-randu.csv', 'datasets/mnist_all.csv', - 'datasets/Twitter.csv', 'datasets/tinyImages100k.csv'] - options: '-k 4' ---- # MRPT: fast nearest neighbor search with random projection library: mrpt methods: diff --git a/libraries/ann_install.sh b/libraries/ann_install.sh index 14f2e24..7efd68e 100755 --- a/libraries/ann_install.sh +++ b/libraries/ann_install.sh @@ -5,28 +5,22 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One ann*.tar.gz file should be located in this directory containing the +# One ann.tar.gz file should be located in this directory containing the # source code of the desired mlpack version. -tars=`ls ann*.tar.gz | wc -l`; +tars=`ls ann.tar.gz | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No ann source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one ann source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source ann.tar.gz found in libraries/!" exit 1 fi # Remove any old directory. rm -rf ann/ mkdir ann/ -tar -xzpf ann*.tar.gz --strip-components=1 -C ann/ +tar -xzpf ann.tar.gz --strip-components=1 -C ann/ cd ann/ -make linux-g++ +CXXFLAGS=-fPIC make linux-g++ cp -r include/* ../include/ cp -r bin/* ../bin/ cp -r lib/* ../lib/ diff --git a/libraries/annoy_install.sh b/libraries/annoy_install.sh old mode 100644 new mode 100755 index 115c190..626eb93 --- a/libraries/annoy_install.sh +++ b/libraries/annoy_install.sh @@ -5,25 +5,20 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One annoy*.tar.gz file should be located in this directory. -tars=`ls annoy*.tar.gz | wc -l`; +# One annoy.tar.gz file should be located in this directory. +tars=`ls annoy.tar.gz | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No annoy source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one annoy source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source annoy.tar.gz found in libraries/!" exit 1 fi # Remove any old directory. rm -rf annoy/ mkdir annoy/ -tar -xzpf annoy*.tar.gz --strip-components=1 -C annoy/ +tar -xzpf annoy.tar.gz --strip-components=1 -C annoy/ cd annoy/ python3 setup.py build -python3 setup.py install --prefix=../../ -O2 +PYVER=`python3 -c 'import sys; print("python" + sys.version[0:3])'`; +PYTHONPATH=../lib/$PYVER/site-packages/ python3 setup.py install --prefix=../ -O2 diff --git a/libraries/flann_install.sh b/libraries/flann_install.sh index 4cb017c..ebd8499 100755 --- a/libraries/flann_install.sh +++ b/libraries/flann_install.sh @@ -5,25 +5,19 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One flann*.tar.gz file should be located in this directory containing the +# One flann.tar.gz file should be located in this directory containing the # source code of the desired mlpack version. -tars=`ls flann*.tar.gz | wc -l`; +tars=`ls flann.tar.gz | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No flann source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one flann source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source flann.tar.gz found in libraries/!" exit 1 fi # Remove any old directory. rm -rf flann/ mkdir flann/ -tar -xzpf flann*.tar.gz --strip-components=1 -C flann/ +tar -xzpf flann.tar.gz --strip-components=1 -C flann/ cd flann/ mkdir build/ diff --git a/libraries/hlearn_install.sh b/libraries/hlearn_install.sh index c905092..4b70a69 100755 --- a/libraries/hlearn_install.sh +++ b/libraries/hlearn_install.sh @@ -5,48 +5,39 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One HLearn*.tar.gz file should be located in this directory. Also since +# One HLearn.tar.gz file should be located in this directory. Also since # HLearn depends on subhask, a subhask*.tar.gz file should also be located in # this directory. -tars=`ls HLearn*.tar.gz | wc -l`; -if [ "$tars" -eq "0" ]; -then - echo "No HLearn source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one HLearn source .tar.gz found." - echo "Ensure only one is present in libraries/!" - exit 1 -fi +# +# HLearn doesn't work with ghc 8, so this installation is commented out. + +#tars=`ls HLearn.tar.gz | wc -l`; +#if [ "$tars" -eq "0" ]; +#then +# echo "No source HLearn.tar.gz found in libraries/!" +# exit 1 +#fi -subhasktars=`ls subhask*.tar.gz | wc -l`; -if [ "$tars" -eq "0" ]; -then - echo "No subhask source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one subhask source .tar.gz found." - echo "Ensure only one is present in libraries/!" - exit 1 -fi +#subhasktars=`ls subhask.tar.gz | wc -l`; +#if [ "$tars" -eq "0" ]; +#then +# echo "No source subhask.tar.gz found in libraries/!" +# exit 1 +#fi # Remove any old directory. -rm -rf hlearn/ -mkdir hlearn/ -tar -xzpf HLearn*.tar.gz --strip-components=1 -C hlearn/ +#rm -rf hlearn/ +#mkdir hlearn/ +#tar -xzpf HLearn.tar.gz --strip-components=1 -C hlearn/ -rm -rf subhask/ -mkdir subhask/ -tar -xvzpf subhask*.tar.gz --strip-components=1 -C subhask/ +#rm -rf subhask/ +#mkdir subhask/ +#tar -xvzpf subhask.tar.gz --strip-components=1 -C subhask/ -cd hlearn/ -cabal sandbox init -cabal sandbox add-source ../subhask -cabal update -cabal install --only-dependencies --force-reinstalls -cabal build -cabal install +#cd hlearn/ +#cabal sandbox init +#cabal sandbox add-source ../subhask +#cabal update +#cabal install --only-dependencies --force-reinstalls +#cabal build +#cabal install diff --git a/libraries/matlab_install.sh b/libraries/matlab_install.sh index e33f880..b519d0d 100755 --- a/libraries/matlab_install.sh +++ b/libraries/matlab_install.sh @@ -1,7 +1,7 @@ #!/bin/bash # # This does not install MATLAB but instead simply checks for its presence. -if [ ! -f /opt/matlab/bin/matlab ]; +if [ ! -f `which matlab` ]; then echo "MATLAB not found!" exit 1 diff --git a/libraries/mlpack_install.sh b/libraries/mlpack_install.sh index 6101da3..4ab3e80 100755 --- a/libraries/mlpack_install.sh +++ b/libraries/mlpack_install.sh @@ -5,28 +5,39 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One mlpack*.tar.gz file should be located in this directory containing the +# One mlpack.tar.gz file should be located in this directory containing the # source code of the desired mlpack version. -tars=`ls mlpack*.tar.gz | wc -l`; +tars=`ls mlpack.tar.gz | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No mlpack source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one mlpack source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source mlpack.tar.gz found in libraries/!" exit 1 fi # Remove any old directory. rm -rf mlpack/ mkdir mlpack/ -tar -xzpf mlpack*.tar.gz --strip-components=1 -C mlpack/ +tar -xzpf mlpack.tar.gz --strip-components=1 -C mlpack/ cd mlpack/ mkdir build/ cd build/ cmake -DCMAKE_INSTALL_PREFIX=../../ -DBUILD_TESTS=OFF ../ make install + +# Also install debug version. +cd .. +mkdir build-debug/ +cd build-debug/ +cmake -DDEBUG=ON -DCMAKE_INSTALL_PREFIX=../../debug/ -DBUILD_TEST=OFF ../ +make install + +# Work around bug in 2.2.0 and 2.2.1. +cd ../../bin/ +ln -s mlpack_knn mlpack_allknn +ln -s mlpack_kfn mlpack_allkfn +ln -s mlpack_krann mlpack_allkrann +cd ../debug/bin/ +ln -s mlpack_knn mlpack_allknn +ln -s mlpack_kfn mlpack_allkfn +ln -s mlpack_krann mlpack_allkrann diff --git a/libraries/mlpy_install.sh b/libraries/mlpy_install.sh index 0dfdcce..fae4c06 100755 --- a/libraries/mlpy_install.sh +++ b/libraries/mlpy_install.sh @@ -5,25 +5,19 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One mlpy*.tar.gz file should be located in this directory. -tars=`ls mlpy*.tar.gz | wc -l`; +# One mlpy.tar.gz file should be located in this directory. +tars=`ls mlpy.tar.gz | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No mlpy source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one mlpy source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source mlpy.tar.gz found in libraries/!" exit 1 fi # Remove any old directory. rm -rf mlpy/ mkdir mlpy/ -tar -xzpf mlpy*.tar.gz --strip-components=1 -C mlpy/ +tar -xzpf mlpy.tar.gz --strip-components=1 -C mlpy/ cd mlpy/ python3 setup.py build -python3 setup.py install --prefix=../../ -O2 +python3 setup.py install --prefix=../ -O2 diff --git a/libraries/scikit_install.sh b/libraries/scikit_install.sh index 48f3e90..903af98 100755 --- a/libraries/scikit_install.sh +++ b/libraries/scikit_install.sh @@ -5,25 +5,19 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One scikit*.tar.gz file should be located in this directory. -tars=`ls scikit*.tar.gz | wc -l`; +# One scikit.tar.gz file should be located in this directory. +tars=`ls scikit.tar.gz | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No scikit source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one scikit source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source scikit.tar.gz found in libraries/!" exit 1 fi # Remove any old directory. rm -rf scikit/ mkdir scikit/ -tar -xzpf scikit*.tar.gz --strip-components=1 -C scikit/ +tar -xzpf scikit.tar.gz --strip-components=1 -C scikit/ cd scikit/ python3 setup.py build -python3 setup.py install --prefix=../../ -O2 +python3 setup.py install --prefix=../ -O2 diff --git a/libraries/shogun_install.sh b/libraries/shogun_install.sh index 649ef4e..67e0eba 100755 --- a/libraries/shogun_install.sh +++ b/libraries/shogun_install.sh @@ -5,24 +5,18 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One shogun*.tar.gz file should be located in this directory. -tars=`ls shogun*.tar.gz | wc -l`; +# One shogun.tar.gz file should be located in this directory. +tars=`ls shogun.tar.gz | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No shogun source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one shogun source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source shogun.tar.gz found in libraries/!" exit 1 fi # Remove any old directory. rm -rf shogun/ mkdir shogun/ -tar -xzpf shogun*.tar.gz --strip-components=1 -C shogun/ +tar -xzpf shogun.tar.gz --strip-components=1 -C shogun/ cd shogun/ mkdir build/ diff --git a/libraries/weka_install.sh b/libraries/weka_install.sh index 3e5c986..e112ff9 100755 --- a/libraries/weka_install.sh +++ b/libraries/weka_install.sh @@ -5,23 +5,17 @@ # Include files will be installed to ../include/. # Library files will be installed to ../lib/. # -# One weka*.tar.gz file should be located in this directory. -tars=`ls scikit*.tar.gz | wc -l`; +# One weka.zip file should be located in this directory. +tars=`ls weka.zip | wc -l`; if [ "$tars" -eq "0" ]; then - echo "No weka source .tar.gz found in libraries/!" - exit 1 -fi -if [ "$tars" -ne "1" ]; -then - echo "More than one weka source .tar.gz found." - echo "Ensure only one is present in libraries/!" + echo "No source weka.zip found in libraries/!" exit 1 fi # Remove any old directory. rm -rf weka/ -unzip weka*.zip +unzip weka.zip mv weka-[0-9]-[0-9]-[0-9]/ weka/ cd weka/ diff --git a/methods/mlpack/allkfn.py b/methods/mlpack/allkfn.py index 34991b3..566c161 100644 --- a/methods/mlpack/allkfn.py +++ b/methods/mlpack/allkfn.py @@ -43,8 +43,8 @@ class ALLKFN(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/allknn.py b/methods/mlpack/allknn.py index 35b6be0..9c3a7f4 100644 --- a/methods/mlpack/allknn.py +++ b/methods/mlpack/allknn.py @@ -43,8 +43,8 @@ class ALLKNN(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/allkrann.py b/methods/mlpack/allkrann.py index 39c1b60..0360116 100644 --- a/methods/mlpack/allkrann.py +++ b/methods/mlpack/allkrann.py @@ -43,8 +43,8 @@ class ALLKRANN(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/decision_stump.py b/methods/mlpack/decision_stump.py index 615c07d..76e3359 100644 --- a/methods/mlpack/decision_stump.py +++ b/methods/mlpack/decision_stump.py @@ -51,8 +51,8 @@ class DecisionStump(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/det.py b/methods/mlpack/det.py index 07a14d7..c7735c0 100644 --- a/methods/mlpack/det.py +++ b/methods/mlpack/det.py @@ -45,8 +45,8 @@ class DET(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/emst.py b/methods/mlpack/emst.py index 381ffc9..33b074c 100644 --- a/methods/mlpack/emst.py +++ b/methods/mlpack/emst.py @@ -43,8 +43,8 @@ class EMST(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/fastmks.py b/methods/mlpack/fastmks.py index baf070b..e393906 100644 --- a/methods/mlpack/fastmks.py +++ b/methods/mlpack/fastmks.py @@ -43,8 +43,8 @@ class FastMKS(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/hmm_generate.py b/methods/mlpack/hmm_generate.py index ccdef13..a95bcb0 100644 --- a/methods/mlpack/hmm_generate.py +++ b/methods/mlpack/hmm_generate.py @@ -43,8 +43,8 @@ class HMMGENERATE(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/hmm_loglik.py b/methods/mlpack/hmm_loglik.py index dda57b5..2832932 100644 --- a/methods/mlpack/hmm_loglik.py +++ b/methods/mlpack/hmm_loglik.py @@ -44,8 +44,8 @@ class HMMLOGLIK(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/hmm_train.py b/methods/mlpack/hmm_train.py index 5a80b36..9acc9a8 100644 --- a/methods/mlpack/hmm_train.py +++ b/methods/mlpack/hmm_train.py @@ -43,8 +43,8 @@ class HMMTRAIN(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/hmm_viterbi.py b/methods/mlpack/hmm_viterbi.py index fb8376d..0c3b1dd 100644 --- a/methods/mlpack/hmm_viterbi.py +++ b/methods/mlpack/hmm_viterbi.py @@ -45,8 +45,8 @@ class HMMVITERBI(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/ica.py b/methods/mlpack/ica.py index 955cf30..cb749f4 100644 --- a/methods/mlpack/ica.py +++ b/methods/mlpack/ica.py @@ -43,8 +43,8 @@ class ICA(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/kernel_pca.py b/methods/mlpack/kernel_pca.py index a1ac03a..927b652 100644 --- a/methods/mlpack/kernel_pca.py +++ b/methods/mlpack/kernel_pca.py @@ -43,8 +43,8 @@ class KPCA(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/kmeans.py b/methods/mlpack/kmeans.py index 2e8b95c..52438b8 100644 --- a/methods/mlpack/kmeans.py +++ b/methods/mlpack/kmeans.py @@ -43,8 +43,8 @@ class KMEANS(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/lars.py b/methods/mlpack/lars.py index a3a057c..3373399 100644 --- a/methods/mlpack/lars.py +++ b/methods/mlpack/lars.py @@ -43,8 +43,8 @@ class LARS(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/linear_regression.py b/methods/mlpack/linear_regression.py index 5a36b41..a53d4d6 100644 --- a/methods/mlpack/linear_regression.py +++ b/methods/mlpack/linear_regression.py @@ -50,8 +50,8 @@ class LinearRegression(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/local_coordinate_coding.py b/methods/mlpack/local_coordinate_coding.py index 1097614..a36403d 100644 --- a/methods/mlpack/local_coordinate_coding.py +++ b/methods/mlpack/local_coordinate_coding.py @@ -43,8 +43,8 @@ class LocalCoordinateCoding(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/logistic_regression.py b/methods/mlpack/logistic_regression.py index 9932f03..de02f9e 100644 --- a/methods/mlpack/logistic_regression.py +++ b/methods/mlpack/logistic_regression.py @@ -51,8 +51,8 @@ class LogisticRegression(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/lsh.py b/methods/mlpack/lsh.py index 2f1d293..8785ba4 100644 --- a/methods/mlpack/lsh.py +++ b/methods/mlpack/lsh.py @@ -44,8 +44,8 @@ class LSH(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/mlp_backward.py b/methods/mlpack/mlp_backward.py index 6726f6a..9c86742 100644 --- a/methods/mlpack/mlp_backward.py +++ b/methods/mlpack/mlp_backward.py @@ -80,7 +80,7 @@ def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN_SRC"], successful. ''' def RunMetrics(self, options): - Log.Info("Perform MLP Backard.", self.verbose) + Log.Info("Perform MLP Backward.", self.verbose) # Split the command using shell-like syntax. cmd = shlex.split(self.path + "mlp_backward -v " + options) diff --git a/methods/mlpack/nbc.py b/methods/mlpack/nbc.py index 1e6c91a..cc374fb 100644 --- a/methods/mlpack/nbc.py +++ b/methods/mlpack/nbc.py @@ -51,8 +51,8 @@ class NBC(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/nca.py b/methods/mlpack/nca.py index f84d8b1..867466e 100644 --- a/methods/mlpack/nca.py +++ b/methods/mlpack/nca.py @@ -43,8 +43,8 @@ class NCA(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/nmf.py b/methods/mlpack/nmf.py index 77e869e..8de22e5 100644 --- a/methods/mlpack/nmf.py +++ b/methods/mlpack/nmf.py @@ -43,8 +43,8 @@ class NMF(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/pca.py b/methods/mlpack/pca.py index 9358b75..4f61169 100644 --- a/methods/mlpack/pca.py +++ b/methods/mlpack/pca.py @@ -42,8 +42,8 @@ class PCA(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/perceptron.py b/methods/mlpack/perceptron.py index 4884e26..306cafe 100644 --- a/methods/mlpack/perceptron.py +++ b/methods/mlpack/perceptron.py @@ -51,8 +51,8 @@ class PERCEPTRON(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/range_search.py b/methods/mlpack/range_search.py index ffbd387..17225e5 100644 --- a/methods/mlpack/range_search.py +++ b/methods/mlpack/range_search.py @@ -43,8 +43,8 @@ class RANGESEARCH(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/mlpack/sparse_coding.py b/methods/mlpack/sparse_coding.py index fca1168..86a7647 100644 --- a/methods/mlpack/sparse_coding.py +++ b/methods/mlpack/sparse_coding.py @@ -43,8 +43,8 @@ class SparseCoding(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["MLPACK_BIN"], - verbose=True, debug=os.environ["MLPACK_BIN_DEBUG"]): + def __init__(self, dataset, timeout=0, path=os.environ["BINPATH"], + verbose=True, debug=os.environ["DEBUGBINPATH"]): self.verbose = verbose self.dataset = dataset self.path = path diff --git a/methods/weka/allknn.py b/methods/weka/allknn.py index dc1f43c..d377a54 100644 --- a/methods/weka/allknn.py +++ b/methods/weka/allknn.py @@ -37,7 +37,7 @@ class ALLKNN(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], + def __init__(self, dataset, timeout=0, path=os.environ["JAVAPATH"], verbose = True): self.verbose = verbose self.dataset = dataset @@ -58,13 +58,14 @@ def RunMetrics(self, options): # If the dataset contains two files then the second file is the query file. # In this case we add this to the command line. if len(self.dataset) == 2: - inputCmd = "-r " + self.dataset[0] + " -q " + self.dataset[1] + " " + options + inputCmd = "-r " + self.dataset[0] + " -q " + self.dataset[1] + " " + \ + options else: inputCmd = "-r " + self.dataset + " " + options # Split the command using shell-like syntax. - cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + - " AllKnn " + inputCmd + " " + options) + cmd = shlex.split("java -classpath " + self.path + "/weka.jar" + + ":methods/weka" + " AllKnn " + inputCmd + " " + options) # Run command with the nessecary arguments and return its output as a byte # string. We have untrusted input so we disable all shell based features. diff --git a/methods/weka/kmeans.py b/methods/weka/kmeans.py index 0c43aed..b9302ed 100644 --- a/methods/weka/kmeans.py +++ b/methods/weka/kmeans.py @@ -37,7 +37,7 @@ class KMEANS(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], + def __init__(self, dataset, timeout=0, path=os.environ["JAVAPATH"], verbose=True): self.verbose = verbose self.dataset = dataset @@ -56,7 +56,7 @@ def RunMetrics(self, options): Log.Info("Perform K-Means.", self.verbose) # Split the command using shell-like syntax. - cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + + cmd = shlex.split("java -classpath " + self.path + "/weka.jar:methods/weka" + " KMeans -i " + self.dataset[0] + " " + options) # Run command with the nessecary arguments and return its output as a byte diff --git a/methods/weka/linear_regression.py b/methods/weka/linear_regression.py index d8f49af..0e3118e 100644 --- a/methods/weka/linear_regression.py +++ b/methods/weka/linear_regression.py @@ -45,7 +45,7 @@ class LinearRegression(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], + def __init__(self, dataset, timeout=0, path=os.environ["JAVAPATH"], verbose=True): self.verbose = verbose self.dataset = dataset @@ -79,9 +79,9 @@ def RunMetrics(self, options): # If the dataset contains two files then the second file is the responses # file. In this case we add this to the command line. if len(self.dataset) >= 2: - cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + - " LinearRegression -i " + self.dataset[0] + " -t " + self.dataset[1] - + " " + options) + cmd = shlex.split("java -classpath " + self.path + "/weka.jar" + + ":methods/weka" + " LinearRegression -i " + self.dataset[0] + " -t " + + self.dataset[1] + " " + options) else: cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + " LinearRegression -i " + self.dataset[0] + " " + options) diff --git a/methods/weka/logistic_regression.py b/methods/weka/logistic_regression.py index 8a46030..c9eb824 100644 --- a/methods/weka/logistic_regression.py +++ b/methods/weka/logistic_regression.py @@ -45,7 +45,7 @@ class LogisticRegression(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], + def __init__(self, dataset, timeout=0, path=os.environ["JAVAPATH"], verbose=True): self.verbose = verbose self.dataset = dataset @@ -79,9 +79,9 @@ def RunMetrics(self, options): # If the dataset contains two files then the second file is the responses # file. In this case we add this to the command line. if len(self.dataset) >= 2: - cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + - " LogisticRegression -i " + self.dataset[0] + " -t " + self.dataset[1] - + " " + options) + cmd = shlex.split("java -classpath " + self.path + "/weka.jar" + + ":methods/weka LogisticRegression -i " + self.dataset[0] + " -t " + + self.dataset[1] + " " + options) else: cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + " LogisticRegression -i " + self.dataset[0] + " " + options) diff --git a/methods/weka/nbc.py b/methods/weka/nbc.py index ceff4d2..05b6a6b 100644 --- a/methods/weka/nbc.py +++ b/methods/weka/nbc.py @@ -46,7 +46,7 @@ class NBC(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], + def __init__(self, dataset, timeout=0, path=os.environ["JAVAPATH"], verbose=True): self.verbose = verbose self.dataset = dataset @@ -69,8 +69,9 @@ def RunMetrics(self, options): return -1 # Split the command using shell-like syntax. - cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + - " NBC -t " + self.dataset[0] + " -T " + self.dataset[1] + " " + options) + cmd = shlex.split("java -classpath " + self.path + "/weka.jar" + + ":methods/weka" + " NBC -t " + self.dataset[0] + " -T " + + self.dataset[1] + " " + options) # Run command with the nessecary arguments and return its output as a byte # string. We have untrusted input so we disable all shell based features. diff --git a/methods/weka/pca.py b/methods/weka/pca.py index 383110f..fd935e4 100644 --- a/methods/weka/pca.py +++ b/methods/weka/pca.py @@ -37,7 +37,7 @@ class PCA(object): @param path - Path to the mlpack executable. @param verbose - Display informational messages. ''' - def __init__(self, dataset, timeout=0, path=os.environ["WEKA_CLASSPATH"], + def __init__(self, dataset, timeout=0, path=os.environ["JAVAPATH"], verbose=True): self.verbose = verbose self.dataset = dataset @@ -56,8 +56,8 @@ def RunMetrics(self, options): Log.Info("Perform PCA.", self.verbose) # Split the command using shell-like syntax. - cmd = shlex.split("java -classpath " + self.path + ":methods/weka" + - " PCA -i " + self.dataset + " " + options) + cmd = shlex.split("java -classpath " + self.path + "/weka.jar" + + ":methods/weka" + " PCA -i " + self.dataset + " " + options) # Run command with the nessecary arguments and return its output as a byte # string. We have untrusted input so we disable all shell based features. diff --git a/util/loader.py b/util/loader.py index 7d3c80a..0305512 100644 --- a/util/loader.py +++ b/util/loader.py @@ -21,12 +21,6 @@ class Loader(object): ''' @staticmethod def ImportModuleFromPath(path): - if hasattr(os, "getcwdu"): - # Returns a unicode object represantation. - realPath = os.path.realpath(os.getcwdu()) - else: - realPath = os.path.realpath(os.path.curdir) - destinationPath = os.path.dirname(path) if destinationPath == "": @@ -40,16 +34,14 @@ def ImportModuleFromPath(path): else: modName = scriptName - os.chdir(destinationPath) fileHandle = None try: - tup = imp.find_module(modName, ['.']) + tup = imp.find_module(modName, [destinationPath]) module = imp.load_module(modName, *tup) fileHandle = tup[0] finally: - os.chdir(realPath) if fileHandle is not None: fileHandle.close() # Return the name of the module. - return module \ No newline at end of file + return module