Turi Create  4.0
xgboost_iterator.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_XGBOOST_ITERATOR_H_
7 #define TURI_XGBOOST_ITERATOR_H_
8 
9 #include <ml/ml_data/ml_data.hpp>
10 #include <xgboost/src/learner/dmatrix.h>
11 #include <toolkits/supervised_learning/xgboost.hpp>
12 
13 namespace turi {
14 namespace supervised {
15 namespace xgboost {
16 
17 class DMatrixMLData : public ::xgboost::learner::DMatrix {
18  public:
19  DMatrixMLData(const ml_data &data,
20  flexible_type class_weights = flex_undefined(),
21  storage_mode_enum storage_mode = storage_mode_enum::AUTO,
22  size_t max_row_per_batch = 0);
23 
24  virtual ~DMatrixMLData(void);
25  virtual ::xgboost::IFMatrix *fmat(void) const;
26  inline size_t num_classes(void) const { return num_classes_; }
27 
28  public:
29  bool use_extern_memory_ = false;
30 
31  private:
32  ::xgboost::IFMatrix *fmat_;
33  size_t num_classes_ = 0;
34 
35  // not important here
36  static const int kMagic = 0xffffab00;
37 };
38 
39 } // namespace xgboost
40 } // namespace supervised
41 } // namespace turi
42 #endif