title: xgboost load model in c++ (python -> c++ prediction scores mismatch)
body: <p>I'm reaching out to all SO c++ geniuses.</p>
  
  <p>I've trained (and successfully tested) an xgboost model in python like so: </p>
  
  <pre><code>dtrain 
  =xgb.DMatrix(np.asmatrix(X_train),label=np.asarray(y_train,dtype=np.int), feature_names=feat_names)
  
  optimal_model = xgb.train(plst, dtrain)
  
  dtest = xgb.DMatrix(np.asmatrix(X_test),feature_names=feat_names)
  
  optimal_model.save_model('sigdet.model')
  </code></pre>
  
  <p>I've followed a post on the XgBoost (<a href="https://groups.google.com/forum/#!searchin/xgboost-user/c$2B$2B$20load$20model%7Csort:relevance/xgboost-user/1tV2lJOlrcc/ir6yYo0iBgAJ" rel="noreferrer">see link</a>) which  explains the correct way to load and apply prediction in c++:</p>
  
  <pre><code>// Load Model
  g_learner = std::make_unique&lt;Learner&gt;(Learner::Create({}));
          std::unique_ptr&lt;dmlc::Stream&gt; fi(
              dmlc::Stream::Create(filename, "r"));
          g_learner-&gt;Load(fi.get());
  
  // Predict
      DMatrixHandle h_test;
          XGDMatrixCreateFromMat((float *)features, 1, numFeatures , -999.9f, &amp;h_test);
          xgboost::bst_ulong out_len;
  
  
          std::vector&lt;float&gt; preds;
          g_learner-&gt;Predict((DMatrix*)h_test,true, &amp;preds); 
  </code></pre>
  
  <p><strong>My problem (1):</strong> I need to create a DMatrix*, however I only have a DMatrixHandle. How do I properly create a DMatrix with my data?</p>
  
  <p><strong>My problem (2):</strong> When I tried the following prediction method:</p>
  
  <pre><code>DMatrixHandle h_test;
  XGDMatrixCreateFromMat((float *)features, 1, numFeatures , -999.9f, &amp;h_test);
  xgboost::bst_ulong out_len;
  
  
  int res = XGBoosterPredict(g_modelHandle, h_test, 1, 0, &amp;out_len, (const float**)&amp;scores);
  </code></pre>
  
  <p>I'm getting completely different scores than by loading the <strong>exact same model</strong> and using it for prediction (in python).</p>
  
  <p>Whoever helps me achieve consistent results across c++ and python will probably go to heaven. BTW, I need to apply prediction in c++ for a real-time application, otherwise I would use a different language.</p>