Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

some cleanups and license changes for the release.

  • Loading branch information...
commit 1de7d12097eb22ff1ca6d67bfad6d05e38203223 1 parent 0836fcd
@jwf authored
View
25 BuildTree.cpp
@@ -1,19 +1,12 @@
//============================================================================
-// Name : ManifoldExperiment.cpp
-// Author :
-// Version :
-// Copyright : BSD
+// Name : BuildTree.cpp
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
// Description : Constructs a time-delay embedding of the data, equipped with
// a model of the dynamics using an approximation of the
// one step transition matrix based on averaging the sample
// dynamics of the k-nearest neighbours.
//============================================================================
-/*
- * main.cpp
- *
- * Created on: Jun 28, 2009
- * Author: jordan
- */
#include <stdlib.h>
#include <cstring>
@@ -34,23 +27,21 @@ using namespace std;
void show_options(char *progname) {
what_i_do(progname, (char*)WID_STR);
- fprintf(stderr,"\nUsage: %s [options]\n",progname);
+ fprintf(stderr,"\nUsage: %s [options] [datafile]\n",progname);
fprintf(stderr,"Options:\n");
- fprintf(stderr,"Everything not being a valid option will be interpreted as a"
- " possible datafile.\nIf no datafile is given stdin is read."
+ fprintf(stderr,"If no datafile is given stdin is read."
" Just - also means stdin\n");
fprintf(stderr,"\t-l # of data [default: whole file]\n");
fprintf(stderr,"\t-x # of rows to ignore [default: 0]\n");
- fprintf(stderr,"\t-M num. of columns to read [default: 1]\n");
- fprintf(stderr,"\t-c columns to read [default: 1,...,M]\n");
+ fprintf(stderr,"\t-M num. of columns to read [default: 1 (1 is the only value supported currently)]\n");
+ fprintf(stderr,"\t-c columns to read [default: 1]\n");
fprintf(stderr,"\t-m dimension [default: 2]\n");
fprintf(stderr,"\t-p # dimension to reduce to using PCA [default: same as m, ie. no reduction]\n");
fprintf(stderr,"\t-d delay [default: 1]\n");
fprintf(stderr,"\t-V verbosity level [default: 1]\n\t\t"
"0='only panic messages'\n\t\t"
"1='+ input/output messages'\n");
- fprintf(stderr,"\t-o output file [default: 'datafile'.del, "
- "without -o: stdout]\n");
+ fprintf(stderr,"\t-o output file [default: datafile.dmp]\n");
fprintf(stderr,"\t-h show these options\n");
exit(0);
}
View
11 BuildTree.h
@@ -1,9 +1,8 @@
-/*
- * ManifoldExperiment.h
- *
- * Created on: 2009-06-29
- * Author: jfrank8
- */
+//============================================================================
+// Name : BuildTree.h
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+//============================================================================
#ifndef MANIFOLDEXPERIMENT_H_
#define MANIFOLDEXPERIMENT_H_
View
13 Classifier.cpp
@@ -1,9 +1,10 @@
-/*
- * Classifier.cpp
- *
- * Created on: 2009-06-30
- * Author: jfrank8
- */
+//============================================================================
+// Name : Classifier.cpp
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+// Description : Implements the Geometric Template Matching algorithm for
+// time-series classification.
+//============================================================================
#include <stdlib.h>
#include <vector>
View
11 Classifier.h
@@ -1,9 +1,8 @@
-/*
- * Classifier.h
- *
- * Created on: 2009-06-30
- * Author: jfrank8
- */
+//============================================================================
+// Name : Classifier.h
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+//============================================================================
#include <stdlib.h>
#include "ClassifyTrajectory.h"
View
28 ClassifyTrajectory.cpp
@@ -1,9 +1,9 @@
-/*
- * ClassifyTrajectory.cpp
- *
- * Created on: 2009-06-30
- * Author: jfrank8
- */
+//============================================================================
+// Name : ClassifyTrajectory.cpp
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+// Description : Application for running the GTM classifier on a data set.
+//============================================================================
#include <stdlib.h>
#include <cstring>
@@ -28,23 +28,20 @@ using namespace std;
void show_options(char *progname) {
what_i_do(progname, (char*)WID_STR);
- fprintf(stderr,"\nUsage: %s [options]\n",progname);
+ fprintf(stderr,"\nUsage: %s [options] [datafile]\n",progname);
fprintf(stderr,"Options:\n");
- fprintf(stderr,"Everything not being a valid option will be interpreted as a"
- " possible datafile.\nIf no datafile is given stdin is read."
+ fprintf(stderr,"If no datafile is given stdin is read."
" Just - also means stdin\n");
fprintf(stderr,"\t-l # of data [default: whole file]\n");
fprintf(stderr,"\t-x # of rows to ignore [default: 0]\n");
fprintf(stderr,"\t-M num. of columns to read [default: 1]\n");
- fprintf(stderr,"\t-c columns to read [default: 1,...,M]\n");
+ fprintf(stderr,"\t-c columns to read [default: 1]\n");
fprintf(stderr,"\t-n number of neighbours to match [default: 4]\n");
fprintf(stderr,"\t-s length of matched segments [default: 32]\n");
- fprintf(stderr,"\t-A # of algorithm to use (1: old, 2: new, 3: fancy new) [default: old algorithm (1)]\n");
+ fprintf(stderr,"\t-A # of algorithm to use (1: old, 2: new (unpublished), 3: fancy new (still buggy)) [default: old algorithm (1)]\n");
fprintf(stderr,"\t-V verbosity level [default: 0]\n\t\t"
"0='only panic messages'\n\t\t"
"1='+ input/output messages'\n");
- fprintf(stderr,"\t-o output file [default: 'datafile'.del, "
- "without -o: stdout]\n");
fprintf(stderr,"\t-h show these options\n");
exit(0);
}
@@ -70,11 +67,6 @@ void scan_options(int n,char **str, Settings *settings) {
}
if ((out=check_option(str,n,'V','u')) != NULL)
sscanf(out,"%u",&settings->verbosity);
- if ((out=check_option(str,n,'o','o')) != NULL) {
- settings->stdo=0;
- if (strlen(out) > 0)
- settings->outfile=out;
- }
}
int main (int argc, char *argv[]) {
View
11 ClassifyTrajectory.h
@@ -1,9 +1,8 @@
-/*
- * ClassifyTrajectory.h
- *
- * Created on: 2009-06-30
- * Author: jfrank8
- */
+//============================================================================
+// Name : ClassifyTrajectory.h
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+//============================================================================
#include "TDEModel.h"
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2011 by Jordan Frank (jordan.frank@cs.mcgill.ca)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
4 Makefile
@@ -1,9 +1,9 @@
-CXXFLAGS = -O2 -ftree-vectorize -march=native -pthread -Wall -I${HOME}/include `pkg-config --cflags opencv` -I/opt/local/include
+CXXFLAGS = -O3 -ftree-vectorize -march=native -pthread -Wall -I${HOME}/include `pkg-config --cflags opencv` -I/opt/local/include
#CXXFLAGS = -g -ggdb -pthread -Wall -I${HOME}/include `pkg-config --cflags opencv` -I/opt/local/include
LIBS = -L${HOME}/lib -L/usr/lib -lANN -lddtsa `pkg-config --libs opencv`
TARGETS = $(buildtree_TARGET) $(classifytrajectory_TARGET)
OBJS = $(buildtree_OBJS) $(classifytrajectory_OBJS)
-CXX = g++-4.2
+CXX = g++
buildtree_TARGET = buildtree
buildtree_OBJS = BuildTree.o TDEModel.o Utils.o
View
68 README
@@ -0,0 +1,68 @@
+Time-Delay Embedding Classification Apps
+----------------------------------------
+
+License: MIT
+
+This project contains proof-of-concept tools for time-series classification using time-delay embeddings (See Frank et al., 2010).
+
+Depends on:
+ - OpenCV (http://http://opencv.willowgarage.com) 1.1.0 (should work with 2.x, but untested).
+ - Tisean (http://www.mpipks-dresden.mpg.de/~tisean/Tisean_3.0.1/index.html) 3.0.1
+ - ANN (http://www.cs.umd.edu/~mount/ANN/) 1.1.2
+
+There are currently two applications that can be built using make (ensuring that the paths are correct in the included Makefile).
+
+To build a model from a time series represented in CSV format, use the buildtree command:
+
+Usage: ./buildtree [options] [datafile]
+Options:
+Everything not being a valid option will be interpreted as a possible datafile.
+If no datafile is given stdin is read. Just - also means stdin
+ -l # of data [default: whole file]
+ -x # of rows to ignore [default: 0]
+ -M num. of columns to read [default: 1]
+ -c columns to read [default: 1]
+ -m dimension [default: 2]
+ -p # dimension to reduce to using PCA [default: same as m, ie. no reduction]
+ -d delay [default: 1]
+ -V verbosity level [default: 1]
+ 0='only panic messages'
+ 1='+ input/output messages'
+ -o output file [default: datafile.dmp]
+ -h show these options
+
+
+To classify a data set, put the filenames of the models, one per line, in a file called models.ini and run the classifytrajectory command:
+Usage: ./classifytrajectory [options]
+Options:
+Everything not being a valid option will be interpreted as a possible datafile.
+If no datafile is given stdin is read. Just - also means stdin
+ -l # of data [default: whole file]
+ -x # of rows to ignore [default: 0]
+ -M num. of columns to read [default: 1]
+ -c columns to read [default: 1,...,M]
+ -n number of neighbours to match [default: 4]
+ -s length of matched segments [default: 32]
+ -A # of algorithm to use (1: old, 2: new (unpublished), 3: fancy new(buggy)) [default: old algorithm (1)]
+ -V verbosity level [default: 0]
+ 0='only panic messages'
+ 1='+ input/output messages'
+ -h show these options
+
+
+The classifytrajectory command will send the similarity scores to STDOUT, where the order of the scores corresponds to the order of the models in the models.ini file.
+
+Included is a script, run-walks-test.sh, which gives a simple example of how to use these two applications. It takes three parameters, the embedding dimension, the noise-reduced dimension, and the delay, then uses these parameters to build four models for data from four different people walking. Finally, it classifies a test data file, storing the scores in tmp/walks-out.dat. Running this with values M=5, P=5, D=2, for example, and plotting the values for each column of the output file, you should see that the each of the subjects is recognized, in turn.
+
+If you use this code in your research, we ask you to cite:
+Jordan Frank, Shie Mannor, and Doina Precup. Activity and Gait Recognition with Time-Delay Embeddings. AAAI. 2010.
+
+@inproceedings{frank10actrec
+ author = {J. Frank and S. Mannor and D. Precup},
+ title = {Activity and Gait Recognition with Time-Delay Embeddings},
+ booktitle = {Proceedings of the Twenty-Fourth AAAI Conference on Artificial Intelligence (AAAI 2010)},
+ location = {Atlanta, Georgia, USA},
+ year = {2010},
+}
+
+This is proof-of-concept code, but was implemented with efficiency in mind, and has been used to classify large data sets. Please report any bugs to jordan.frank@cs.mcgill.ca. Feel free to email me if you'd like statically compiled x86 Linux binaries.
View
12 TDEModel.cpp
@@ -1,9 +1,9 @@
-/*
- * TDEModel.cpp
- *
- * Created on: 2009-06-29
- * Author: jfrank8
- */
+//============================================================================
+// Name : TDEModel.cpp
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+// Description : Implementation for the time-delay embedding model.
+//============================================================================
#include <stdlib.h>
#include <ctype.h>
View
11 TDEModel.h
@@ -1,9 +1,8 @@
-/*
- * TDEModel.h
- *
- * Created on: 2009-06-29
- * Author: jfrank8
- */
+//============================================================================
+// Name : TDEModel.h
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+//============================================================================
#include <opencv/cxcore.h>
#include "Utils.h"
View
12 Utils.cpp
@@ -1,9 +1,9 @@
-/*
- * Utils.cpp
- *
- * Created on: 2009-06-30
- * Author: jfrank8
- */
+//============================================================================
+// Name : Utils.cpp
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+// Description : Some helpful utility methods.
+//============================================================================
#include <stdlib.h>
#include <cstring>
View
12 Utils.h
@@ -1,9 +1,9 @@
-/*
- * Utils.h
- *
- * Created on: 2009-06-30
- * Author: jfrank8
- */
+//============================================================================
+// Name : Utils.h
+// Author : Jordan Frank (jordan.frank@cs.mcgill.ca)
+// Copyright : MIT
+// Description : Some helpful utility methods.
+//============================================================================
#include <stdlib.h>
#include <ANN/ANN.h>
View
7,935 data/amin-train.dat.dmp
3,987 additions, 3,948 deletions not shown
View
7,893 data/cosmin-train.dat.dmp
3,966 additions, 3,927 deletions not shown
View
7,335 data/robert-train.dat.dmp
3,687 additions, 3,648 deletions not shown
View
7,943 data/sophia-train.dat.dmp
3,991 additions, 3,952 deletions not shown
View
10 run-walks-test.sh
@@ -4,8 +4,8 @@ M=$1
P=$2
D=$3
-./buildtree -m $M -p $P -d $D data/sophia-train.dat
-./buildtree -m $M -p $P -d $D data/amin-train.dat
-./buildtree -m $M -p $P -d $D data/cosmin-train.dat
-./buildtree -m $M -p $P -d $D data/robert-train.dat
-./classifytrajectory data/walks-test.dat > /tmp/walks-out.dat
+./buildtree -m $M -p $P -d $D data/sophia-train.dat && echo "data/sophia-train.dat.dmp > models.ini"
+./buildtree -m $M -p $P -d $D data/amin-train.dat && echo "data/amin-train.dat.dmp >> models.ini"
+./buildtree -m $M -p $P -d $D data/cosmin-train.dat && echo "data/cosmin-train.dat.dmp >> models.ini"
+./buildtree -m $M -p $P -d $D data/robert-train.dat && echo "data/robert-train.dat.dmp >> models.ini"
+./classifytrajectory data/walks-test.dat > tmp/walks-out.dat
Please sign in to comment.
Something went wrong with that request. Please try again.