summaryrefslogtreecommitdiff
path: root/dtrain/pairsampling.h
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2011-09-25 20:23:09 +0200
committerPatrick Simianer <p@simianer.de>2011-09-25 20:23:09 +0200
commitfe471bb707226052551d75b043295ca5f57261c0 (patch)
tree73ba37bf8d5c1de6de50f63888a49e918e4a8cd4 /dtrain/pairsampling.h
parent5e1ab3481551607f1c2a10027049044cd41f78ab (diff)
removed some quirks, less boost, prettier code, score_t
Diffstat (limited to 'dtrain/pairsampling.h')
-rw-r--r--dtrain/pairsampling.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/dtrain/pairsampling.h b/dtrain/pairsampling.h
index e06036ca..a8521485 100644
--- a/dtrain/pairsampling.h
+++ b/dtrain/pairsampling.h
@@ -8,21 +8,19 @@ namespace dtrain
{
-struct TPair
+struct Pair
{
SparseVector<double> first, second;
size_t first_rank, second_rank;
double first_score, second_score;
};
-typedef vector<TPair> TrainingInstances;
-
inline void
-sample_all_pairs(KBestList* kb, TrainingInstances &training)
+sample_all_pairs(Samples* kb, vector<Pair> &training)
{
for (size_t i = 0; i < kb->GetSize()-1; i++) {
for (size_t j = i+1; j < kb->GetSize(); j++) {
- TPair p;
+ Pair p;
p.first = kb->feats[i];
p.second = kb->feats[j];
p.first_rank = i;
@@ -35,12 +33,12 @@ sample_all_pairs(KBestList* kb, TrainingInstances &training)
}
inline void
-sample_rand_pairs(KBestList* kb, TrainingInstances &training, MT19937* prng)
+sample_rand_pairs(Samples* kb, vector<Pair> &training, MT19937* prng)
{
for (size_t i = 0; i < kb->GetSize()-1; i++) {
for (size_t j = i+1; j < kb->GetSize(); j++) {
if (prng->next() < .5) {
- TPair p;
+ Pair p;
p.first = kb->feats[i];
p.second = kb->feats[j];
p.first_rank = i;