treelite
data.h
Go to the documentation of this file.
1 
7 #ifndef TREELITE_DATA_H_
8 #define TREELITE_DATA_H_
9 
10 #include <dmlc/data.h>
11 
12 namespace treelite {
13 
15 struct DMatrix {
17  std::vector<float> data;
19  std::vector<uint32_t> col_ind;
21  std::vector<size_t> row_ptr;
23  size_t num_row;
25  size_t num_col;
27  size_t nelem;
28 
32  inline void Clear() {
33  data.clear();
34  row_ptr.clear();
35  col_ind.clear();
36  row_ptr.resize(1, 0);
37  num_row = num_col = nelem = 0;
38  }
47  static DMatrix* Create(const char* filename, const char* format,
48  int nthread, int verbose);
58  static DMatrix* Create(dmlc::Parser<uint32_t>* parser,
59  int nthread, int verbose);
60 };
61 
62 } // namespace treelite
63 
64 #endif // TREELITE_DATA_H_
std::vector< float > data
feature values
Definition: data.h:17
std::vector< uint32_t > col_ind
feature indices
Definition: data.h:19
static DMatrix * Create(const char *filename, const char *format, int nthread, int verbose)
construct a new DMatrix from a file
Definition: data.cc:17
size_t num_row
number of rows
Definition: data.h:23
a simple data matrix in CSR (Compressed Sparse Row) storage
Definition: data.h:15
void Clear()
clear all data fields
Definition: data.h:32
size_t num_col
number of columns
Definition: data.h:25
size_t nelem
number of nonzero entries
Definition: data.h:27
std::vector< size_t > row_ptr
pointer to row headers; length of [num_row] + 1
Definition: data.h:21