Commit f2beb02f authored by Michal Balazia's avatar Michal Balazia
Browse files

gitignore

parent 6b4584d7
build/
config/
dist/
nbproject/
dist/
build.xml
catalog.xml
\ No newline at end of file
......@@ -66,7 +66,7 @@ public class Executor {
private static final boolean extractDatabase = false;
private static final boolean learnClassifiers = false;
private static final boolean performClassifications = false;
private static final boolean evaluateMethods = false;
private static final boolean evaluateMethods = true;
/*
Select evaluation set-ups at evaluateMethods()
......@@ -78,23 +78,23 @@ public class Executor {
All implemented MoCap-based gait recognition methods
*/
private static final Method[] methods = new Method[]{
new MethodAhmed(),//0
new MethodAli(),//1
new MethodAndersson(),//2
new MethodBall(),//3
new MethodDikovski(),//4
// new MethodAhmed(),//0
// new MethodAli(),//1
// new MethodAndersson(),//2
// new MethodBall(),//3
// new MethodDikovski(),//4
new MethodGavrilova(),//5
new MethodJiang(),//6
new MethodKrzeszowski(),//7
new MethodKumar(),//8
new MethodKwolek(),//9
new MethodPreis(),//10
new MethodSedmidubsky(),//11
new MethodSinha(),//12
new Method_MMC(),//13
new Method_PCALDA(),//14
new Method_Random(),//15
new Method_Raw(),//16
// new MethodJiang(),//6
// new MethodKrzeszowski(),//7
// new MethodKumar(),//8
// new MethodKwolek(),//9
// new MethodPreis(),//10
// new MethodSedmidubsky(),//11
// new MethodSinha(),//12
// new Method_MMC(),//13
// new Method_PCALDA(),//14
// new Method_Random(),//15
// new Method_Raw(),//16
};
/*
......@@ -395,16 +395,16 @@ public class Executor {
public static String printTime(double time) {
String unit = "ms";
if (time > 1000) {
if (time >= 1000) {
time /= 1000;
unit = "s";
if (time > 60) {
if (time >= 60) {
time /= 60;
unit = "m";
if (time > 60) {
if (time >= 60) {
time /= 60;
unit = "h";
if (time > 24) {
if (time >= 24) {
time /= 24;
unit = "d";
}
......
......@@ -42,7 +42,7 @@ public abstract class Method implements Serializable {
private List<Double> scoresAUC;
private List<Double> scoresMAP;
private List<Double> scoresDCT;
private List<Double> scoresTS;
private List<Double> scoresTD;
private List<List<Double>> scoresListCMC;
private List<List<Double>> scoresListFARFRR0;
private List<List<Double>> scoresListFARFRR1;
......@@ -244,7 +244,7 @@ public abstract class Method implements Serializable {
scoresAUC = new ArrayList();
scoresMAP = new ArrayList();
scoresDCT = new ArrayList();
scoresTS = new ArrayList();
scoresTD = new ArrayList();
scoresListCMC = new ArrayList();
for (int rank = 0; rank < classesEvaluation; rank++) {
scoresListCMC.add(new ArrayList());
......@@ -266,7 +266,7 @@ public abstract class Method implements Serializable {
}
private void printEvaluation() {
System.out.print("DBI,DI,SC,FDR,CCR,EER,AUC,MAP,DCT,TS\r\n");
System.out.print("DBI,DI,SC,FDR,CCR,EER,AUC,MAP,DCT,TD\r\n");
System.out.print(toString(scoresDBI));
System.out.print(toString(scoresDI));
System.out.print(toString(scoresSC));
......@@ -276,7 +276,7 @@ public abstract class Method implements Serializable {
System.out.print(toString(scoresAUC));
System.out.print(toString(scoresMAP));
System.out.print(toString(scoresDCT));
System.out.print(toString(scoresTS));
System.out.print(toString(scoresTD));
System.out.print("\r\n");
System.out.print("CMC\r\n");
for (List<Double> scoresCMC : scoresListCMC) {
......@@ -410,7 +410,7 @@ public abstract class Method implements Serializable {
List<Double> scoresAttemptAUC = new ArrayList();
List<Double> scoresAttemptMAP = new ArrayList();
List<Double> scoresAttemptDCT = new ArrayList();
List<Double> scoresAttemptTS = new ArrayList();
List<Double> scoresAttemptTD = new ArrayList();
List<List<Double>> scoresListAttemptCMC = new ArrayList();
for (int rank = 0; rank < numberOfClassesEvaluation; rank++) {
scoresListAttemptCMC.add(new ArrayList());
......@@ -429,29 +429,10 @@ public abstract class Method implements Serializable {
scoresListAttemptRCLPCN0.add(new ArrayList());
scoresListAttemptRCLPCN1.add(new ArrayList());
}
int size = templatesEvaluation.size();
DistanceMatrix distanceMatrix = new DistanceMatrix(classifier.getDistanceTemplates());
long beginning = System.currentTimeMillis();
int k = 0;//
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
distanceMatrix.putDistance(templatesEvaluation.get(i), templatesEvaluation.get(j));
int pBefore = (100 * k) / (size * size);//
k++;//
int pAfter = (100 * k) / (size * size);//
long time = System.currentTimeMillis() - beginning;//
if (pBefore < pAfter) {//
System.out.println(Executor.printTime(time) + ": " + pAfter + "%, remaining: " + Executor.printTime(100 * time / pAfter - time));//
}//
}
}
scoresAttemptDCT.add(getDistanceComputationTime(beginning, size * size));
scoresAttemptTS.add(getTemplateSize(templatesEvaluation));
// distanceMatrix.print();
// exportCSV(getName() + "_" + System.currentTimeMillis() + ".csv", templatesEvaluation);
long begin = System.currentTimeMillis();
classifier.setDistanceMatrix(distanceMatrix);
retriever.setDistanceMatrix(distanceMatrix);
setDistanceMatrix(templatesEvaluation);
scoresAttemptDCT.add((System.currentTimeMillis() - beginning) / Math.pow(templatesEvaluation.size(), 2));
scoresAttemptTD.add(getTemplateDimensionality(templatesEvaluation));
List<List<Template>> foldsEvaluation = new ArrayList();
for (int fFoldEvaluation = 0; fFoldEvaluation < nFoldsEvaluation; fFoldEvaluation++) {
foldsEvaluation.add(new ArrayList());
......@@ -584,7 +565,7 @@ public abstract class Method implements Serializable {
scoresAUC.add(getAverage(scoresAttemptAUC));
scoresMAP.add(getAverage(scoresAttemptMAP));
scoresDCT.add(getAverage(scoresAttemptDCT));
scoresTS.add(getAverage(scoresAttemptTS));
scoresTD.add(getAverage(scoresAttemptTD));
for (int rank = 0; rank < numberOfClassesEvaluation; rank++) {
scoresListCMC.get(rank).add(getAverage(scoresListAttemptCMC.get(rank)));
}
......@@ -596,7 +577,6 @@ public abstract class Method implements Serializable {
scoresListRCLPCN0.get(f).add(getAverage(scoresListAttemptRCLPCN0.get(f)));
scoresListRCLPCN1.get(f).add(getAverage(scoresListAttemptRCLPCN1.get(f)));
}
System.out.println("time=" + Executor.printTime(System.currentTimeMillis() - begin));
}
private List<double[]> sortCurve(List<double[]> curve, int index) {
......@@ -625,6 +605,27 @@ public abstract class Method implements Serializable {
return sum / scores.size();
}
private void setDistanceMatrix(List<Template> templatesEvaluation) {
DistanceMatrix distanceMatrix = new DistanceMatrix(classifier.getDistanceTemplates());
int size = templatesEvaluation.size();
long beginning = System.currentTimeMillis();//
int k = 0;//
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
distanceMatrix.putDistance(templatesEvaluation.get(i), templatesEvaluation.get(j));
int pBefore = (100 * k) / (size * size);//
k++;//
int pAfter = (100 * k) / (size * size);//
long time = System.currentTimeMillis() - beginning;//
if (pBefore < pAfter) {//
System.out.println(Executor.printTime(time) + ": " + pAfter + "%, remaining: " + Executor.printTime(100 * time / pAfter - time));//
}//
}
}
classifier.setDistanceMatrix(distanceMatrix);
retriever.setDistanceMatrix(distanceMatrix);
}
private double[] getCumulativeMatchCharacteristic(List<Template> templatesTest, List<Template> templatesGallery) {
List<List<Template>> split = new ClassifiableList(templatesGallery).splitClasses();
int classes = split.size();
......@@ -799,18 +800,14 @@ public abstract class Method implements Serializable {
return centroid;
}
public double getTemplateSize(List<Template> templatesEvaluation) {
public double getTemplateDimensionality(List<Template> templatesEvaluation) {
int sum = 0;
for (Template sample : templatesEvaluation) {
sum += sample.getDimension() * sample.getLength();
for (Template template : templatesEvaluation) {
sum += template.getDimension() * template.getLength();
}
return (double) sum / templatesEvaluation.size();
}
public double getDistanceComputationTime(long beginning, int numberOfClassifications) {
return (double) (System.currentTimeMillis() - beginning) / numberOfClassifications;
}
public double[] getFARFRR(double radius, List<Template> templatesTest, List<Template> templatesGallery) {
double far = 0;
double frr = 0;
......@@ -995,7 +992,7 @@ public abstract class Method implements Serializable {
return rtv;
}
private void exportCSV(String fileNameCSV, List<Template> templates) {
private void exportTemplatesToCSV(String fileNameCSV, List<Template> templates) {
try {
System.out.print("saving " + fileNameCSV + "\r\n");
FileWriter writer = new FileWriter(fileNameCSV);
......
package methods;
import algorithms.Classifier;
import algorithms.ClassifierKNNMV;
import algorithms.Classifier1NN;
import algorithms.DistanceTemplatesDTW;
import algorithms.DistanceVectors;
import algorithms.DistanceVectorsL1;
import algorithms.RetrieverKNNQuery;
import executor.Executor;
import java.io.File;
import java.io.IOException;
......@@ -14,7 +11,6 @@ import java.util.List;
import objects.Feature;
import objects.Motion;
import objects.MotionJointCoordinates;
import objects.Template;
public class MethodGavrilova extends Method {
......@@ -28,15 +24,7 @@ public class MethodGavrilova extends Method {
@Override
public void learnClassifier(List<Motion> motionsLearning) {
ClassifierGavrilova classifier = new ClassifierGavrilova();
DistanceTemplatesDTW distanceTemplatesJRD = new DistanceTemplatesDTW();
DistanceTemplatesDTW distanceTemplatesJRA = new DistanceTemplatesDTW();
DistanceVectorsGavrilovaJRD distanceVectorsJRD = new DistanceVectorsGavrilovaJRD();
DistanceVectorsGavrilovaJRA distanceVectorsJRA = new DistanceVectorsGavrilovaJRA();
distanceTemplatesJRD.setDistanceVectors(distanceVectorsJRD);
distanceTemplatesJRA.setDistanceVectors(distanceVectorsJRA);
classifier.setDistanceTemplatesJRD(distanceTemplatesJRD);
classifier.setDistanceTemplatesJRA(distanceTemplatesJRA);
Classifier1NN classifier = new Classifier1NN();
DistanceTemplatesDTW distanceTemplates = new DistanceTemplatesDTW();
distanceTemplates.setDistanceVectors(new DistanceVectorsL1());
classifier.setDistanceTemplates(distanceTemplates);
......@@ -85,80 +73,4 @@ public class MethodGavrilova extends Method {
features.add(motionMJC.extractJointAngleFeature("rhipjoint", "root", "rtibia"));
return features;
}
public class ClassifierGavrilova extends Classifier {
private final int k = 3; // 3-NN
private DistanceTemplatesDTW distanceFunctionJRD;
private DistanceTemplatesDTW distanceFunctionJRA;
public ClassifierGavrilova() {
}
public void setDistanceTemplatesJRD(DistanceTemplatesDTW distanceFunctionJRD) {
this.distanceFunctionJRD = distanceFunctionJRD;
}
public void setDistanceTemplatesJRA(DistanceTemplatesDTW distanceFunctionJRA) {
this.distanceFunctionJRA = distanceFunctionJRA;
}
@Override
public int classify(Template querySample, List<Template> trainingSamples) {
RetrieverKNNQuery retrieverJRD = new RetrieverKNNQuery(k);
RetrieverKNNQuery retrieverJRA = new RetrieverKNNQuery(k);
retrieverJRD.setDistanceTemplates(distanceFunctionJRD);
retrieverJRA.setDistanceTemplates(distanceFunctionJRA);
List<Template> retrievedJRD = retrieverJRD.retrieve(querySample, trainingSamples);
List<Template> retrievedJRA = retrieverJRA.retrieve(querySample, trainingSamples);
List<Template> retrieved = new ArrayList();
retrieved.addAll(retrievedJRD);
retrieved.addAll(retrievedJRA);
ClassifierKNNMV classifier = new ClassifierKNNMV(2 * k);
DistanceTemplatesDTW distanceFunction = new DistanceTemplatesDTW();
distanceFunction.setDistanceVectors(new DistanceVectorsL1());
classifier.setDistanceTemplates(distanceFunction);
return classifier.classify(querySample, retrieved);
}
}
public final class DistanceVectorsGavrilovaJRD extends DistanceVectors {
public DistanceVectorsGavrilovaJRD() {
}
@Override
public double getDistance(double[] pose1, double[] pose2) {
if (pose1.length != pose2.length) {
System.out.println("wrong dimensions");
}
double distance = 0;
for (int d = 0; d < pose1.length; d++) {
if (d <= 20) {
distance += Math.abs(pose1[d] - pose2[d]);
}
}
return distance;
}
}
public final class DistanceVectorsGavrilovaJRA extends DistanceVectors {
public DistanceVectorsGavrilovaJRA() {
}
@Override
public double getDistance(double[] pose1, double[] pose2) {
if (pose1.length != pose2.length) {
System.out.println("wrong dimensions");
}
double distance = 0;
for (int d = 0; d < pose1.length; d++) {
if (d >= 21) {
distance += Math.abs(pose1[d] - pose2[d]);
}
}
return distance;
}
}
}
......@@ -4,6 +4,7 @@ import Jama.Matrix;
import Jama.SingularValueDecomposition;
import algorithms.Classifier;
import algorithms.Classifier1NN;
import algorithms.ClassifierLinear;
import algorithms.DistanceTemplatesBaseline;
import algorithms.DistanceVectorsMahalanobis;
import executor.Executor;
......@@ -19,8 +20,8 @@ import objects.Sample;
public class Method_MMC extends Method {
private final boolean dataType = true; // true = BoneRotations, false = JointCoordinates
private final Classifier classifier = new Classifier1NN(); // Classifier1NN, ClassifierLinear
private final boolean dataType = false; // true = BoneRotations, false = JointCoordinates
private final Classifier classifier = new ClassifierLinear(); // Classifier1NN, ClassifierLinear
private final int length = 150;
public Method_MMC() {
......
......@@ -4,6 +4,7 @@ import Jama.EigenvalueDecomposition;
import Jama.Matrix;
import algorithms.Classifier;
import algorithms.Classifier1NN;
import algorithms.ClassifierLinear;
import algorithms.DistanceTemplatesBaseline;
import algorithms.DistanceVectorsMahalanobis;
import com.mkobos.pca_transform.PCA;
......@@ -20,8 +21,8 @@ import objects.Sample;
public class Method_PCALDA extends Method {
private final boolean dataType = true; // true = BoneRotations, false = JointCoordinates
private final Classifier classifier = new Classifier1NN(); // Classifier1NN, ClassifierLinear
private final boolean dataType = false; // true = BoneRotations, false = JointCoordinates
private final Classifier classifier = new ClassifierLinear(); // Classifier1NN, ClassifierLinear
private final int length = 150;
public Method_PCALDA() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment