(obj)
| 4729 | } |
| 4730 | } |
| 4731 | XGBoosterLoadModel(obj) { |
| 4732 | this.version = obj.version; |
| 4733 | const learner = obj.learner; |
| 4734 | const mparam = learner.learner_model_param || {}; |
| 4735 | this.base_score = mparam.base_score; |
| 4736 | this.num_feature = parseInt(mparam.num_feature || '0', 10); |
| 4737 | this.num_class = parseInt(mparam.num_class || '0', 10); |
| 4738 | this.num_target = parseInt(mparam.num_target || '1', 10); |
| 4739 | this.objective = learner.objective ? learner.objective.name : ''; |
| 4740 | this.feature_names = learner.feature_names || []; |
| 4741 | this.feature_types = learner.feature_types || []; |
| 4742 | this.attributes = learner.attributes || {}; |
| 4743 | const gb = learner.gradient_booster; |
| 4744 | if (gb) { |
| 4745 | this.booster_type = gb.name; |
| 4746 | if (gb.name === 'gbtree' || gb.name === 'dart') { |
| 4747 | const gbtree = gb.name === 'dart' && gb.gbtree ? gb.gbtree : gb; |
| 4748 | const model = gbtree.model; |
| 4749 | const param = model.gbtree_model_param || {}; |
| 4750 | this.num_trees = parseInt(param.num_trees || '0', 10); |
| 4751 | this.num_parallel_tree = parseInt(param.num_parallel_tree || '1', 10); |
| 4752 | this.trees = model.trees || []; |
| 4753 | this.tree_info = model.tree_info || []; |
| 4754 | if (gb.weight_drop) { |
| 4755 | this.weight_drop = gb.weight_drop; |
| 4756 | } |
| 4757 | } else if (gb.name === 'gblinear') { |
| 4758 | const model = gb.model; |
| 4759 | this.weights = model.weights || []; |
| 4760 | this.boosted_rounds = model.boosted_rounds || 0; |
| 4761 | } |
| 4762 | } |
| 4763 | } |
| 4764 | XGBoosterLoadModelFromBuffer(buffer) { |
| 4765 | if (buffer.length > 2 && buffer[0] === 0x7B && buffer[1] !== 0x22) { |
| 4766 | const obj = execution.invoke('ubjson.loadb', [buffer]); |
no outgoing calls
no test coverage detected