blob: b9bc44615e5d38f3eb4867f5039ab2efc618eb71 (
plain)
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
51
52
|
#include "kbestget.h"
namespace dtrain
{
struct TPair
{
double type;
SparseVector<double> first;
SparseVector<double> second;
};
typedef vector<TPair> TrainingInstances;
void
sample_all( KBestList* kb, TrainingInstances &training )
{
double type;
for ( size_t i = 0; i < kb->GetSize()-1; i++ ) {
for ( size_t j = i+1; j < kb->GetSize(); j++ ) {
if ( kb->scores[i] - kb->scores[j] < 0 ) {
type = -1;
} else {
type = 1;
}
TPair p;
p.type = type;
p.first = kb->feats[i];
p.second = kb->feats[j];
training.push_back( p );
}
}
}
/*void
sample_all_only_neg(, vector<pair<SparSparseVector<double> > pairs)
{
}
void
sample_random_pos()
{
if ( rand() % 2 ) { // sample it?
}*/
} // namespace
|