add xgcombine_buffer with weights
This commit is contained in:
parent
a59969cd52
commit
3960ac9cb4
@ -82,13 +82,13 @@ public:
|
|||||||
int rescale;
|
int rescale;
|
||||||
int linelimit;
|
int linelimit;
|
||||||
public:
|
public:
|
||||||
FILE *fp, *fwlist, *fgroup;
|
FILE *fp, *fwlist, *fgroup, *fweight;
|
||||||
std::vector<Header> fheader;
|
std::vector<Header> fheader;
|
||||||
std::vector<FMatrixS::REntry> entry;
|
std::vector<FMatrixS::REntry> entry;
|
||||||
DataLoader( void ){
|
DataLoader( void ){
|
||||||
rescale = 0;
|
rescale = 0;
|
||||||
linelimit = -1;
|
linelimit = -1;
|
||||||
fp = NULL; fwlist = NULL; fgroup = NULL;
|
fp = NULL; fwlist = NULL; fgroup = NULL; fweight = NULL;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
inline void Load( std::vector<unsigned> &findex, std::vector<float> &fvalue, std::vector<Header> &vec ){
|
inline void Load( std::vector<unsigned> &findex, std::vector<float> &fvalue, std::vector<Header> &vec ){
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
// basically we are loading all the data inside
|
// basically we are loading all the data inside
|
||||||
inline void Load( void ){
|
inline void Load( void ){
|
||||||
this->data.Clear();
|
this->data.Clear();
|
||||||
float label;
|
float label, weight = 0.0f;
|
||||||
|
|
||||||
unsigned ngleft = 0, ngacc = 0;
|
unsigned ngleft = 0, ngacc = 0;
|
||||||
if( fgroup != NULL ){
|
if( fgroup != NULL ){
|
||||||
@ -132,8 +132,12 @@ public:
|
|||||||
|
|
||||||
while( fscanf( fp, "%f", &label ) == 1 ){
|
while( fscanf( fp, "%f", &label ) == 1 ){
|
||||||
if( ngleft == 0 && fgroup != NULL ){
|
if( ngleft == 0 && fgroup != NULL ){
|
||||||
utils::Assert( fscanf( fgroup, "%u", &ngleft ) == 1 );
|
utils::Assert( fscanf( fgroup, "%u", &ngleft ) == 1 );
|
||||||
}
|
}
|
||||||
|
if( fweight != NULL ){
|
||||||
|
utils::Assert( fscanf( fweight, "%f", &weight ) == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
ngleft -= 1; ngacc += 1;
|
ngleft -= 1; ngacc += 1;
|
||||||
|
|
||||||
int pass = 1;
|
int pass = 1;
|
||||||
@ -152,6 +156,10 @@ public:
|
|||||||
if( rescale != 0 ) this->DoRescale( fvalue );
|
if( rescale != 0 ) this->DoRescale( fvalue );
|
||||||
// push back data :)
|
// push back data :)
|
||||||
this->info.labels.push_back( label );
|
this->info.labels.push_back( label );
|
||||||
|
// push back weight if any
|
||||||
|
if( fweight != NULL ){
|
||||||
|
this->info.labels.push_back( weight );
|
||||||
|
}
|
||||||
this->data.AddRow( findex, fvalue );
|
this->data.AddRow( findex, fvalue );
|
||||||
}
|
}
|
||||||
if( ngleft == 0 && fgroup != NULL && ngacc != 0 ){
|
if( ngleft == 0 && fgroup != NULL && ngacc != 0 ){
|
||||||
@ -201,6 +209,9 @@ int main( int argc, char *argv[] ){
|
|||||||
if( !strcmp( argv[i], "-fgroup") ){
|
if( !strcmp( argv[i], "-fgroup") ){
|
||||||
loader.fgroup = utils::FopenCheck( argv[ ++i ], "r" ); continue;
|
loader.fgroup = utils::FopenCheck( argv[ ++i ], "r" ); continue;
|
||||||
}
|
}
|
||||||
|
if( !strcmp( argv[i], "-fweight") ){
|
||||||
|
loader.fweight = utils::FopenCheck( argv[ ++i ], "r" ); continue;
|
||||||
|
}
|
||||||
if( !strcmp( argv[i], "-linelimit") ){
|
if( !strcmp( argv[i], "-linelimit") ){
|
||||||
loader.linelimit = atoi( argv[ ++i ] ); continue;
|
loader.linelimit = atoi( argv[ ++i ] ); continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user