make basic combine buf
This commit is contained in:
parent
fe9e89cadd
commit
87cc53f0cd
@ -11,6 +11,7 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "../src/io/simple_dmatrix-inl.hpp"
|
#include "../src/io/simple_dmatrix-inl.hpp"
|
||||||
|
#include "../src/io/io.cpp"
|
||||||
#include "../src/utils/utils.h"
|
#include "../src/utils/utils.h"
|
||||||
|
|
||||||
using namespace xgboost;
|
using namespace xgboost;
|
||||||
@ -94,14 +95,14 @@ class DataLoader: public DMatrixSimple {
|
|||||||
for( size_t i = 0; i < vec.size(); i ++ ){
|
for( size_t i = 0; i < vec.size(); i ++ ){
|
||||||
if( !vec[i].is_dense ) {
|
if( !vec[i].is_dense ) {
|
||||||
for( int j = 0; j < vec[i].tmp_num; j ++ ){
|
for( int j = 0; j < vec[i].tmp_num; j ++ ){
|
||||||
utils::Assert( fscanf ( vec[i].fi, "%u:%f", &e.findex, &e.fvalue ) == 2, "Error when load feat" );
|
utils::Assert( fscanf ( vec[i].fi, "%u:%f", &e.index, &e.fvalue ) == 2, "Error when load feat" );
|
||||||
vec[i].CheckBase( e.findex );
|
vec[i].CheckBase( e.index );
|
||||||
e.findex += vec[i].base;
|
e.index += vec[i].base;
|
||||||
feats.push_back(e);
|
feats.push_back(e);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
utils::Assert( fscanf ( vec[i].fi, "%f", &e.fvalue ) == 1, "load feat" );
|
utils::Assert( fscanf ( vec[i].fi, "%f", &e.fvalue ) == 1, "load feat" );
|
||||||
e.findex = vec[i].base;
|
e.index = vec[i].base;
|
||||||
feats.push_back(e);
|
feats.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +164,7 @@ class DataLoader: public DMatrixSimple {
|
|||||||
}
|
}
|
||||||
if( ngleft == 0 && fgroup != NULL && ngacc != 0 ){
|
if( ngleft == 0 && fgroup != NULL && ngacc != 0 ){
|
||||||
info.group_ptr.push_back( info.group_ptr.back() + ngacc );
|
info.group_ptr.push_back( info.group_ptr.back() + ngacc );
|
||||||
utils::Assert( info.group_ptr.back() == info.num_row, "group size must match num rows" );
|
utils::Assert( info.group_ptr.back() == info.num_row(), "group size must match num rows" );
|
||||||
ngacc = 0;
|
ngacc = 0;
|
||||||
}
|
}
|
||||||
// linelimit
|
// linelimit
|
||||||
@ -173,7 +174,7 @@ class DataLoader: public DMatrixSimple {
|
|||||||
}
|
}
|
||||||
if( ngleft == 0 && fgroup != NULL && ngacc != 0 ){
|
if( ngleft == 0 && fgroup != NULL && ngacc != 0 ){
|
||||||
info.group_ptr.push_back( info.group_ptr.back() + ngacc );
|
info.group_ptr.push_back( info.group_ptr.back() + ngacc );
|
||||||
utils::Assert( info.group_ptr.back() == info.num_row, "group size must match num rows" );
|
utils::Assert( info.group_ptr.back() == info.num_row(), "group size must match num rows" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +237,7 @@ int main( int argc, char *argv[] ){
|
|||||||
printf("num_features=%d\n", norm( loader.fheader ) );
|
printf("num_features=%d\n", norm( loader.fheader ) );
|
||||||
printf("start creating buffer...\n");
|
printf("start creating buffer...\n");
|
||||||
loader.Load();
|
loader.Load();
|
||||||
loader.SaveBinary( argv[2] );
|
io::SaveDataMatrix(loader, argv[2]);
|
||||||
// close files
|
// close files
|
||||||
fclose( loader.fp );
|
fclose( loader.fp );
|
||||||
if( loader.fwlist != NULL ) fclose( loader.fwlist );
|
if( loader.fwlist != NULL ) fclose( loader.fwlist );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user