-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclassify-histograms.cpp
More file actions
50 lines (44 loc) · 1.69 KB
/
classify-histograms.cpp
File metadata and controls
50 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdlib.h>
#include <iostream>
#include <cstdio>
#include "project/Importer.h"
/**
* Implementation of histogram classification using svm-light.
*
* \author: mack
*/
int main(int argc, char **argv) {
//TODO: use svm light training and classifying methods
//model file has to be stored in "data/model" and named "model.dat",
//predicition file in "data/prediction" and named "prediction.dat"
char* trainFile = "data/histograms/train/histograms.dat";
char* testFile = "data/histograms/test/histograms.dat";
char* modelFile = "data/model/model.dat";
char* predicationFile = "data/prediction/prediction.dat";
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-help") == 0) {
std::cout << "The following parameters are available: \n"
<< "-Tr: The path of Histogram Training File (default: data/histograms/train/histograms.dat) \n"
<< "-Te: The path of Histogram Testing File (default: data/histograms/test/histograms.dat) \n"
<< "-M: The path of the generated Model File (default: data/model/model.dat) \n"
<< "-P: The path of the generated predication File (default: data/prediction/prediction.dat) \n"
<< std::endl;
return 1;
}
if (strcmp(argv[i], "-Tr") == 0) {
trainFile = argv[++i];
} else if (strcmp(argv[i], "-Te") == 0) {
testFile = argv[++i];
} else if (strcmp(argv[i], "-M") == 0) {
modelFile = argv[++i];
} else if (strcmp(argv[i], "-P") == 0) {
predicationFile = argv[++i];
}
}
char trainCmd[100];
char classifyCmd[100];
sprintf(trainCmd,"./svm_light/svm_learn %s %s",trainFile,modelFile);
system(trainCmd);
sprintf(classifyCmd,"./svm_light/svm_classify %s %s %s",testFile,modelFile,predicationFile);
system(classifyCmd);
}