Commits

Oliver Gu committed 3a736b3

Made script more robust and readable.

Comments (0)

Files changed (1)

 # www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf and executes the second
 # command set on page 9 with the OCaml command line interface.
 
-DATA_URL="http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary"
-DATA_DIR="./data"
-SVM_CLI="./svm_cli.native"
+URL="http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary"
+DATADIR="./data"
 
-if [ ! -e "$DATA_DIR" ]
+TRAINFILE=svmguide1
+TESTFILE=svmguide1.t
+
+SVM="./svm_cli.native"
+
+if [ ! -f "$DATADIR/$TRAINFILE" ] || [ ! -f "$DATADIR/$TESTFILE" ]
 then
   printf "Downloading training and testing data..."
-  mkdir $DATA_DIR &&
-  wget -q -P $DATA_DIR $DATA_URL/svmguide1 &&
-  wget -q -P $DATA_DIR $DATA_URL/svmguide1.t
+  mkdir   -p $DATADIR &&
+  wget -q -P $DATADIR "$URL/$TRAINFILE" &&
+  wget -q -P $DATADIR "$URL/$TESTFILE"
   printf " finished!\n"
 fi
 
-if [ ! -f "$SVM_CLI" ]
+if [ ! -f "$SVM" ]
 then
-  echo "$SVM_CLI not found. Type 'make' for building it."
+  echo "$SVM not found. Type 'make' for building it."
   exit 1
 fi
 
-TRAIN_SET_FILE="$DATA_DIR/svmguide1"
-TEST_SET_FILE="$DATA_DIR/svmguide1.t"
-SCALE_PARAMS_FILE="$DATA_DIR/range1"
-
-export CAML_LD_LIBRARY_PATH=$CAML_LD_LIBRARY_PATH:./_build/lib
+TRAINFILE="$DATADIR/$TRAINFILE"
+TESTFILE="$DATADIR/$TESTFILE"
+SCALEPARAMSFILE="$DATADIR/range1"
 
-$SVM_CLI scale -l -1 -u 1 -s $SCALE_PARAMS_FILE $TRAIN_SET_FILE > $TRAIN_SET_FILE.scale &&
-$SVM_CLI scale -r $SCALE_PARAMS_FILE $TEST_SET_FILE > $TEST_SET_FILE.scale &&
-$SVM_CLI train $TRAIN_SET_FILE.scale $TRAIN_SET_FILE.scale.model &&
-$SVM_CLI predict $TEST_SET_FILE.scale $TRAIN_SET_FILE.scale.model $TEST_SET_FILE.predict
+$SVM scale -l -1 -u 1 -s $SCALEPARAMSFILE $TRAINFILE > $TRAINFILE.scale &&
+$SVM scale -r $SCALEPARAMSFILE $TESTFILE > $TESTFILE.scale &&
+$SVM train $TRAINFILE.scale &&
+$SVM predict $TESTFILE.scale $TRAINFILE.scale.model $TESTFILE.predict
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.