Skip to content

Commit d6f1b1d

Browse files
committed
first runnable with trainData given by our teacher, just 2 trees, each 22s to run 7 train data and 3 test data. Using all the features at nodes split.
1 parent 38881c9 commit d6f1b1d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

LoadData.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ void LoadData::convertRawDataToExamples() {
6161
if(y_u<cropingWidth&&x_v>=0)
6262
{
6363
t.x[j]= rawData[i].terms[x*cropingWidth+y_u]-rawData[i].terms[x_v*cropingWidth+y];
64-
cout<<t.x[j]<<endl;
6564
}
6665
//out of bound , during training we don't use this feature if any picture is out of bound case.
6766
else

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ExampleInput/ *Stores some small examples of input data file.
3333
* g++ * The C++ compiler, or you can use anything equvalent.
3434
* Armadillo-7.400.2 * A linear algebra C++ open library.
3535

36-
**How to installi the prerequests?**
36+
**How to install the prerequests?**
3737
First download the `armdillo-7.400.2.zip` from [this link](http://pan.baidu.com/s/1o7Um4Sa), then uppack it.
3838
Alternatively, you could also refers to [official website of Armdillo](http://arma.sourceforge.net/)
3939

@@ -87,7 +87,7 @@ for now, just choose `debug mode`.
8787
This program does not input from the raw files like .shand, .skdepth or skdepth.cropping.
8888
Instead this program takes a single '.csv' file as its input, which stores all the training examples.
8989

90-
An example input .csv file is at `HandPoseEstimation/ExampleInput/`
90+
The training Data in .csv format can be downloaded at: [this link](https://pan.baidu.com/s/1dFNui1j)
9191
where `value0, value1, ...` is the pixel value of our depth image, so there should be `90*60` values,and the `label0, label1, ...` is the hand joints postion value, so there should be `20*3` labels.
9292

9393
In both `debug` and `real-time` mode of this program at running time, the program will output two files

Tree.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ example averageLabelValueOfExamples(const vector<example> &E) {
114114
}
115115
// By Tony, Sep 20.
116116
vector<feature> randomChooseFeatures() {
117-
int num = int(sqrt(feaNum));
118-
//int num = 100;
117+
//int num = int(sqrt(feaNum));
118+
int num = feaNum;
119119
bool used[feaNum] = { 0 };
120120
vector<feature> feats;
121121
for (int i = 0; i < num; i++) {
@@ -152,7 +152,7 @@ double H(const vector<example> &E) {
152152
//Calculate the determinant of covS.
153153
double detCS = arma::det(covS);
154154
// FOR DEBUG ONLY:
155-
cout << "detcs = " << detCS << endl;
155+
//cout << "detcs = " << detCS << endl;
156156
// log() is the function 'ln()'
157157
// M_PI = 3.14159265358979323846
158158
double c = (labelNum / 2) * (1 + log(2 * M_PI));
@@ -178,8 +178,8 @@ inline double infoGain(const vector<example> &E, const vector<example> &upSet, c
178178
return INF - downSet.size() * H(downSet);
179179
if (H(downSet) == -1 * numeric_limits<double>::infinity())
180180
return INF - upSet.size() * H(upSet);
181-
cout << "size of UPset: " << upSet.size() << "size of DownSet: " << downSet.size() << endl;
182-
cout << "H(E) of UpSet: " << H(upSet) << " H(E) of DownSet: " << H(downSet) << endl;
181+
//cout << "size of UPset: " << upSet.size() << "size of DownSet: " << downSet.size() << endl;
182+
//cout << "H(E) of UpSet: " << H(upSet) << " H(E) of DownSet: " << H(downSet) << endl;
183183
return H(E) - ((upSet.size() / E.size()) * H(upSet) + (downSet.size() / E.size() * H(downSet)));
184184
}
185185
// By Tony. Sep 20.
@@ -193,8 +193,8 @@ feature chooseBestFeature(const vector<feature> &feats, vector<example> &E, vect
193193
if (E[j].x[i] > max) max = E[j].x[i];
194194
if (E[j].x[i] < min) min = E[j].x[i];
195195
}
196-
cout << " i = " << i << "max = " << max << "min = " << min << endl;
197-
if (0.01 > max - min || 0.01 > min - max) continue;
196+
//cout << " i = " << i << "max = " << max << "min = " << min << endl;
197+
if (0.01 > max - min && 0.01 > min - max) continue;
198198
// Try a number of split points.
199199
double split[splitPointsNum], step = (max - min) / (splitPointsNum + 1);
200200
for (int j = 0; j < splitPointsNum; j++) split[j] = min + step * (j + 1);
@@ -212,7 +212,7 @@ feature chooseBestFeature(const vector<feature> &feats, vector<example> &E, vect
212212
}
213213
double nu = infoGain(E, upSet, downSet);
214214
// For debug only.
215-
cout << "nu = " << nu << endl;
215+
//cout << "nu = " << nu << endl;
216216
// Get the best feature index. and the split point value.
217217
if (maxInfoGain < nu) {
218218
maxInfoGain = nu;
@@ -228,6 +228,7 @@ feature chooseBestFeature(const vector<feature> &feats, vector<example> &E, vect
228228
cout << "Exit program.." << endl;
229229
exit(0);
230230
}
231+
cout << "bestFeature = " << bestFeature << endl;
231232
for (int k = 0; k < E.size(); k++) {
232233
if (E[k].x[bestFeature] <= sP) {
233234
upSet.push_back(E[k]);

0 commit comments

Comments
 (0)