{"action":"created","issue":{"url":"https://api.github.com/repos/dmlc/xgboost/issues/721","repository_url":"https://api.github.com/repos/dmlc/xgboost","labels_url":"https://api.github.com/repos/dmlc/xgboost/issues/721/labels{/name}","comments_url":"https://api.github.com/repos/dmlc/xgboost/issues/721/comments","events_url":"https://api.github.com/repos/dmlc/xgboost/issues/721/events","html_url":"https://github.com/dmlc/xgboost/issues/721","id":124962865,"number":721,"title":"error in model dump","user":{"login":"sdgroeve","id":12020055,"avatar_url":"https://avatars.githubusercontent.com/u/12020055?v=3","gravatar_id":"","url":"https://api.github.com/users/sdgroeve","html_url":"https://github.com/sdgroeve","followers_url":"https://api.github.com/users/sdgroeve/followers","following_url":"https://api.github.com/users/sdgroeve/following{/other_user}","gists_url":"https://api.github.com/users/sdgroeve/gists{/gist_id}","starred_url":"https://api.github.com/users/sdgroeve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdgroeve/subscriptions","organizations_url":"https://api.github.com/users/sdgroeve/orgs","repos_url":"https://api.github.com/users/sdgroeve/repos","events_url":"https://api.github.com/users/sdgroeve/events{/privacy}","received_events_url":"https://api.github.com/users/sdgroeve/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dmlc/xgboost/labels/Python-Package","name":"Python-Package","color":"0052cc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-05T13:03:42Z","updated_at":"2016-02-02T17:14:26Z","closed_at":"2016-02-02T17:14:26Z","body":"[debug.xgboost.zip](https://github.com/dmlc/xgboost/files/78417/debug.xgboost.zip)\r\n\r\nHi\r\n\r\nI noticed an error when dumping the model to text. To show the error I apply a trained model to a test point v. If I run the following code (model is attached):\r\n\r\n```\r\nimport xgboost as xgb\r\n\r\nxgmodel = xgb.Booster({'nthread':23})\r\nxgmodel.load_model(\"debug.xgboost\") \r\nprint xgmodel.get_dump()[0]\r\n\r\nv = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 264, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\r\n\r\nfor i in range(len(v)):\r\n\tprint \"%i %f\" % (i,v[i])\r\n\r\nr = xgmodel.predict(xgb.DMatrix(v))\r\n\r\nprint r\t\r\n```\r\n\r\nthen the output is r=0.348039.\r\n\r\nHowever, if you follow the dumped tree for test point v I end up in node 21 that tests feature 329. As this feature has value 0 we should end up in leaf 43 (so r=-0.273981). However I seem to end up in leaf 44 as the output is r=0.348039. \r\n\r\nSo, either there is something wrong in the dump, or in the tree model. Or I'm doing something wrong.\r\n\r\nThe test point v looks like this:\r\n\r\n```\r\nfeature value\r\n0 0.000000\r\n1 0.000000\r\n2 0.000000\r\n3 0.000000\r\n4 1.000000\r\n5 0.000000\r\n6 0.000000\r\n7 0.000000\r\n8 0.000000\r\n9 0.000000\r\n10 0.000000\r\n11 0.000000\r\n12 0.000000\r\n13 0.000000\r\n14 0.000000\r\n15 0.000000\r\n16 0.000000\r\n17 0.000000\r\n18 0.000000\r\n19 0.000000\r\n20 0.000000\r\n21 0.000000\r\n22 0.000000\r\n23 0.000000\r\n24 0.000000\r\n25 0.000000\r\n26 0.000000\r\n27 0.000000\r\n28 0.000000\r\n29 1.000000\r\n30 0.000000\r\n31 0.000000\r\n32 0.000000\r\n33 0.000000\r\n34 0.000000\r\n35 0.000000\r\n36 0.000000\r\n37 0.000000\r\n38 0.000000\r\n39 0.000000\r\n40 0.000000\r\n41 0.000000\r\n42 0.000000\r\n43 0.000000\r\n44 0.000000\r\n45 0.000000\r\n46 0.000000\r\n47 0.000000\r\n48 0.000000\r\n49 0.000000\r\n50 0.000000\r\n51 0.000000\r\n52 1.000000\r\n53 0.000000\r\n54 0.000000\r\n55 0.000000\r\n56 0.000000\r\n57 0.000000\r\n58 0.000000\r\n59 0.000000\r\n60 0.000000\r\n61 1.000000\r\n62 0.000000\r\n63 0.000000\r\n64 0.000000\r\n65 0.000000\r\n66 0.000000\r\n67 0.000000\r\n68 0.000000\r\n69 0.000000\r\n70 0.000000\r\n71 0.000000\r\n72 0.000000\r\n73 0.000000\r\n74 0.000000\r\n75 0.000000\r\n76 0.000000\r\n77 0.000000\r\n78 0.000000\r\n79 0.000000\r\n80 0.000000\r\n81 0.000000\r\n82 0.000000\r\n83 0.000000\r\n84 0.000000\r\n85 0.000000\r\n86 0.000000\r\n87 0.000000\r\n88 0.000000\r\n89 0.000000\r\n90 0.000000\r\n91 0.000000\r\n92 0.000000\r\n93 0.000000\r\n94 0.000000\r\n95 0.000000\r\n96 0.000000\r\n97 0.000000\r\n98 0.000000\r\n99 0.000000\r\n100 0.000000\r\n101 0.000000\r\n102 0.000000\r\n103 0.000000\r\n104 0.000000\r\n105 0.000000\r\n106 0.000000\r\n107 0.000000\r\n108 0.000000\r\n109 0.000000\r\n110 0.000000\r\n111 0.000000\r\n112 0.000000\r\n113 0.000000\r\n114 0.000000\r\n115 0.000000\r\n116 0.000000\r\n117 0.000000\r\n118 0.000000\r\n119 0.000000\r\n120 0.000000\r\n121 0.000000\r\n122 0.000000\r\n123 0.000000\r\n124 0.000000\r\n125 0.000000\r\n126 0.000000\r\n127 0.000000\r\n128 0.000000\r\n129 0.000000\r\n130 0.000000\r\n131 0.000000\r\n132 0.000000\r\n133 0.000000\r\n134 0.000000\r\n135 0.000000\r\n136 0.000000\r\n137 0.000000\r\n138 0.000000\r\n139 0.000000\r\n140 0.000000\r\n141 0.000000\r\n142 0.000000\r\n143 0.000000\r\n144 0.000000\r\n145 0.000000\r\n146 0.000000\r\n147 0.000000\r\n148 0.000000\r\n149 0.000000\r\n150 0.000000\r\n151 0.000000\r\n152 0.000000\r\n153 0.000000\r\n154 0.000000\r\n155 0.000000\r\n156 0.000000\r\n157 0.000000\r\n158 0.000000\r\n159 0.000000\r\n160 0.000000\r\n161 0.000000\r\n162 0.000000\r\n163 0.000000\r\n164 0.000000\r\n165 0.000000\r\n166 0.000000\r\n167 0.000000\r\n168 0.000000\r\n169 0.000000\r\n170 0.000000\r\n171 0.000000\r\n172 0.000000\r\n173 0.000000\r\n174 0.000000\r\n175 0.000000\r\n176 0.000000\r\n177 0.000000\r\n178 0.000000\r\n179 634.000000\r\n180 0.000000\r\n181 0.000000\r\n182 0.000000\r\n183 0.000000\r\n184 0.000000\r\n185 0.000000\r\n186 0.000000\r\n187 0.000000\r\n188 0.000000\r\n189 0.000000\r\n190 0.000000\r\n191 0.000000\r\n192 0.000000\r\n193 0.000000\r\n194 205.000000\r\n195 0.000000\r\n196 0.000000\r\n197 0.000000\r\n198 0.000000\r\n199 0.000000\r\n200 897.000000\r\n201 0.000000\r\n202 0.000000\r\n203 0.000000\r\n204 0.000000\r\n205 0.000000\r\n206 0.000000\r\n207 0.000000\r\n208 0.000000\r\n209 0.000000\r\n210 0.000000\r\n211 0.000000\r\n212 0.000000\r\n213 0.000000\r\n214 0.000000\r\n215 0.000000\r\n216 0.000000\r\n217 0.000000\r\n218 0.000000\r\n219 0.000000\r\n220 0.000000\r\n221 4206.000000\r\n222 0.000000\r\n223 0.000000\r\n224 0.000000\r\n225 0.000000\r\n226 0.000000\r\n227 0.000000\r\n228 0.000000\r\n229 0.000000\r\n230 0.000000\r\n231 0.000000\r\n232 0.000000\r\n233 0.000000\r\n234 0.000000\r\n235 0.000000\r\n236 0.000000\r\n237 0.000000\r\n238 0.000000\r\n239 0.000000\r\n240 0.000000\r\n241 0.000000\r\n242 0.000000\r\n243 0.000000\r\n244 0.000000\r\n245 0.000000\r\n246 0.000000\r\n247 0.000000\r\n248 0.000000\r\n249 0.000000\r\n250 0.000000\r\n251 0.000000\r\n252 0.000000\r\n253 0.000000\r\n254 0.000000\r\n255 0.000000\r\n256 0.000000\r\n257 0.000000\r\n258 0.000000\r\n259 0.000000\r\n260 0.000000\r\n261 0.000000\r\n262 0.000000\r\n263 0.000000\r\n264 0.000000\r\n265 0.000000\r\n266 0.000000\r\n267 0.000000\r\n268 0.000000\r\n269 0.000000\r\n270 0.000000\r\n271 0.000000\r\n272 0.000000\r\n273 0.000000\r\n274 0.000000\r\n275 0.000000\r\n276 0.000000\r\n277 0.000000\r\n278 250.000000\r\n279 0.000000\r\n280 0.000000\r\n281 0.000000\r\n282 0.000000\r\n283 0.000000\r\n284 0.000000\r\n285 0.000000\r\n286 0.000000\r\n287 0.000000\r\n288 0.000000\r\n289 0.000000\r\n290 0.000000\r\n291 0.000000\r\n292 0.000000\r\n293 0.000000\r\n294 0.000000\r\n295 0.000000\r\n296 0.000000\r\n297 0.000000\r\n298 0.000000\r\n299 0.000000\r\n300 0.000000\r\n301 0.000000\r\n302 0.000000\r\n303 0.000000\r\n304 0.000000\r\n305 0.000000\r\n306 0.000000\r\n307 0.000000\r\n308 264.000000\r\n309 0.000000\r\n310 0.000000\r\n311 2362.000000\r\n312 0.000000\r\n313 0.000000\r\n314 0.000000\r\n315 0.000000\r\n316 0.000000\r\n317 0.000000\r\n318 0.000000\r\n319 0.000000\r\n320 638.000000\r\n321 0.000000\r\n322 0.000000\r\n323 0.000000\r\n324 0.000000\r\n325 0.000000\r\n326 0.000000\r\n327 0.000000\r\n328 0.000000\r\n329 0.000000\r\n330 0.000000\r\n331 0.000000\r\n332 0.000000\r\n333 0.000000\r\n334 0.000000\r\n335 0.000000\r\n336 0.000000\r\n337 0.000000\r\n338 0.000000\r\n339 0.000000\r\n340 0.000000\r\n341 0.000000\r\n342 0.000000\r\n343 0.000000\r\n344 0.000000\r\n345 0.000000\r\n346 0.000000\r\n347 0.000000\r\n348 0.000000\r\n349 0.000000\r\n350 0.000000\r\n351 0.000000\r\n352 0.000000\r\n353 0.000000\r\n354 0.000000\r\n355 0.000000\r\n356 0.000000\r\n357 0.000000\r\n358 0.000000\r\n359 0.000000\r\n360 0.000000\r\n361 0.000000\r\n362 0.000000\r\n363 0.000000\r\n364 0.000000\r\n365 0.000000\r\n366 0.000000\r\n367 0.000000\r\n368 264.000000\r\n369 0.000000\r\n370 0.000000\r\n371 0.000000\r\n372 0.000000\r\n373 0.000000\r\n374 0.000000\r\n375 0.000000\r\n376 0.000000\r\n377 0.000000\r\n378 0.000000\r\n379 0.000000\r\n380 248.000000\r\n381 0.000000\r\n382 0.000000\r\n383 0.000000\r\n384 0.000000\r\n385 0.000000\r\n386 0.000000\r\n387 0.000000\r\n388 0.000000\r\n389 0.000000\r\n390 0.000000\r\n391 0.000000\r\n392 0.000000\r\n393 0.000000\r\n394 0.000000\r\n395 0.000000\r\n396 0.000000\r\n397 0.000000\r\n398 0.000000\r\n399 0.000000\r\n400 0.000000\r\n401 0.000000\r\n402 0.000000\r\n403 0.000000\r\n404 0.000000\r\n405 0.000000\r\n406 0.000000\r\n```\r\n\r\nThe tree model consists of one tree only:\r\n\r\n```\r\n0:[f293<50.5] yes=1,no=2,missing=1\r\n\t1:[f311<118.5] yes=3,no=4,missing=3\r\n\t\t3:[f200<731.5] yes=7,no=8,missing=7\r\n\t\t\t7:[f179<94.5] yes=15,no=16,missing=15\r\n\t\t\t\t15:[f61<-1.00136e-05] yes=31,no=32,missing=31\r\n\t\t\t\t\t31:leaf=-0.627388\r\n\t\t\t\t\t32:leaf=-0.745324\r\n\t\t\t\t16:[f52<-1.00136e-05] yes=33,no=34,missing=33\r\n\t\t\t\t\t33:leaf=-0.540893\r\n\t\t\t\t\t34:leaf=0.209816\r\n\t\t\t8:[f52<-1.00136e-05] yes=17,no=18,missing=17\r\n\t\t\t\t17:[f236<43.5] yes=35,no=36,missing=35\r\n\t\t\t\t\t35:leaf=-0.1943\r\n\t\t\t\t\t36:leaf=-0.484402\r\n\t\t\t\t18:[f179<1544.5] yes=37,no=38,missing=37\r\n\t\t\t\t\t37:leaf=0.497445\r\n\t\t\t\t\t38:leaf=-0.0303891\r\n\t\t4:[f200<160.5] yes=9,no=10,missing=9\r\n\t\t\t9:[f179<131.5] yes=19,no=20,missing=19\r\n\t\t\t\t19:[f35<-1.00136e-05] yes=39,no=40,missing=39\r\n\t\t\t\t\t39:leaf=-0.457483\r\n\t\t\t\t\t40:leaf=0.199861\r\n\t\t\t\t20:[f347<91.5] yes=41,no=42,missing=41\r\n\t\t\t\t\t41:leaf=0.406296\r\n\t\t\t\t\t42:leaf=-0.614796\r\n\t\t\t10:[f197<158.5] yes=21,no=22,missing=21\r\n\t\t\t\t21:[f329<1065.5] yes=43,no=44,missing=44\r\n\t\t\t\t\t43:leaf=-0.273981\r\n\t\t\t\t\t44:leaf=0.348039\r\n\t\t\t\t22:[f347<616.5] yes=45,no=46,missing=45\r\n\t\t\t\t\t45:leaf=0.699017\r\n\t\t\t\t\t46:leaf=-0.44\r\n\t2:[f179<142.5] yes=5,no=6,missing=5\r\n\t\t5:[f293<220.5] yes=11,no=12,missing=12\r\n\t\t\t11:[f61<-1.00136e-05] yes=23,no=24,missing=23\r\n\t\t\t\t23:[f293<97.5] yes=47,no=48,missing=48\r\n\t\t\t\t\t47:leaf=0.0344068\r\n\t\t\t\t\t48:leaf=0.298352\r\n\t\t\t\t24:[f179<71.5] yes=49,no=50,missing=49\r\n\t\t\t\t\t49:leaf=-0.320033\r\n\t\t\t\t\t50:leaf=0.181036\r\n\t\t\t12:[f293<673.5] yes=25,no=26,missing=26\r\n\t\t\t\t25:[f61<-1.00136e-05] yes=51,no=52,missing=51\r\n\t\t\t\t\t51:leaf=0.538482\r\n\t\t\t\t\t52:leaf=0.258055\r\n\t\t\t\t26:[f344<384] yes=53,no=54,missing=53\r\n\t\t\t\t\t53:leaf=0.667479\r\n\t\t\t\t\t54:leaf=0.0162084\r\n\t\t6:[f293<162.5] yes=13,no=14,missing=14\r\n\t\t\t13:[f311<204.5] yes=27,no=28,missing=27\r\n\t\t\t\t27:[f200<2512.5] yes=55,no=56,missing=55\r\n\t\t\t\t\t55:leaf=0.411916\r\n\t\t\t\t\t56:leaf=0.618464\r\n\t\t\t\t28:[f347<275.5] yes=57,no=58,missing=57\r\n\t\t\t\t\t57:leaf=0.740687\r\n\t\t\t\t\t58:leaf=-0.0272827\r\n\t\t\t14:[f293<387.5] yes=29,no=30,missing=30\r\n\t\t\t\t29:[f200<376.5] yes=59,no=60,missing=59\r\n\t\t\t\t\t59:leaf=0.661981\r\n\t\t\t\t\t60:leaf=0.735293\r\n\t\t\t\t30:[f179<550.5] yes=61,no=62,missing=62\r\n\t\t\t\t\t61:leaf=0.726539\r\n\t\t\t\t\t62:leaf=0.782332\r\n```\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dmlc/xgboost/issues/comments/178694941","html_url":"https://github.com/dmlc/xgboost/issues/721#issuecomment-178694941","issue_url":"https://api.github.com/repos/dmlc/xgboost/issues/721","id":178694941,"user":{"login":"tqchen","id":2577440,"avatar_url":"https://avatars.githubusercontent.com/u/2577440?v=3","gravatar_id":"","url":"https://api.github.com/users/tqchen","html_url":"https://github.com/tqchen","followers_url":"https://api.github.com/users/tqchen/followers","following_url":"https://api.github.com/users/tqchen/following{/other_user}","gists_url":"https://api.github.com/users/tqchen/gists{/gist_id}","starred_url":"https://api.github.com/users/tqchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tqchen/subscriptions","organizations_url":"https://api.github.com/users/tqchen/orgs","repos_url":"https://api.github.com/users/tqchen/repos","events_url":"https://api.github.com/users/tqchen/events{/privacy}","received_events_url":"https://api.github.com/users/tqchen/received_events","type":"User","site_admin":false},"created_at":"2016-02-02T17:14:26Z","updated_at":"2016-02-02T17:14:26Z","body":"The problem was the gap between the missing value vs. the zeros. Previously in python packages zeros are treated as missing and goes into the missing path. \r\n\r\nThis is now only true for sparse matrices, and for dense matrices, zero is now treated as zero"}}