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 #include <vector>
12 
13 namespace treelite {
14 
16 struct DMatrix {
18  std::vector<float> data;
20  std::vector<uint32_t> col_ind;
22  std::vector<size_t> row_ptr;
24  size_t num_row;
26  size_t num_col;
28  size_t nelem;
29 
33  inline void Clear() {
34  data.clear();
35  row_ptr.clear();
36  col_ind.clear();
37  row_ptr.resize(1, 0);
38  num_row = num_col = nelem = 0;
39  }
48  static DMatrix* Create(const char* filename, const char* format,
49  int nthread, int verbose);
59  static DMatrix* Create(dmlc::Parser<uint32_t>* parser,
60  int nthread, int verbose);
61 };
62 
63 } // namespace treelite
64 
65 #endif // TREELITE_DATA_H_
std::vector< float > data
feature values
Definition: data.h:18
std::vector< uint32_t > col_ind
feature indices
Definition: data.h:20
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:24
a simple data matrix in CSR (Compressed Sparse Row) storage
Definition: data.h:16
void Clear()
clear all data fields
Definition: data.h:33
size_t num_col
number of columns
Definition: data.h:26
size_t nelem
number of nonzero entries
Definition: data.h:28
std::vector< size_t > row_ptr
pointer to row headers; length of [num_row] + 1
Definition: data.h:22