summaryrefslogtreecommitdiff
path: root/dtrain/pairsampling.h
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2011-09-24 04:45:22 +0200
committerPatrick Simianer <p@simianer.de>2011-09-24 04:45:22 +0200
commit5584f300821e20369c25343222cd0e8faa393523 (patch)
treec81705b78fdafc226a7b86dba84eb55b48398634 /dtrain/pairsampling.h
parente8f1795f6aa14ca4a936d675d446894f5c721190 (diff)
get rid of boost str split, more tweaks
Diffstat (limited to 'dtrain/pairsampling.h')
-rw-r--r--dtrain/pairsampling.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/dtrain/pairsampling.h b/dtrain/pairsampling.h
index 9774ba4a..e06036ca 100644
--- a/dtrain/pairsampling.h
+++ b/dtrain/pairsampling.h
@@ -2,7 +2,7 @@
#define _DTRAIN_PAIRSAMPLING_H_
#include "kbestget.h"
-#include "sampler.h" // cdec MT19937
+#include "sampler.h" // cdec, MT19937
namespace dtrain
{
@@ -17,7 +17,7 @@ struct TPair
typedef vector<TPair> TrainingInstances;
-void
+inline void
sample_all_pairs(KBestList* kb, TrainingInstances &training)
{
for (size_t i = 0; i < kb->GetSize()-1; i++) {
@@ -30,14 +30,13 @@ sample_all_pairs(KBestList* kb, TrainingInstances &training)
p.first_score = kb->scores[i];
p.second_score = kb->scores[j];
training.push_back(p);
- }
- }
+ } // j
+ } // i
}
-void
+inline void
sample_rand_pairs(KBestList* kb, TrainingInstances &training, MT19937* prng)
{
- srand(time(NULL));
for (size_t i = 0; i < kb->GetSize()-1; i++) {
for (size_t j = i+1; j < kb->GetSize(); j++) {
if (prng->next() < .5) {
@@ -50,14 +49,12 @@ sample_rand_pairs(KBestList* kb, TrainingInstances &training, MT19937* prng)
p.second_score = kb->scores[j];
training.push_back(p);
}
- }
- }
- cout << training.size() << " sampled" << endl;
+ } // j
+ } // i
}
} // namespace
-
#endif