public float readFloat() throws IOException { return asDataInput().readFloat(); }
public Map<String, String> readStringMap() throws IOException { int length = (int)readLong(); Map<String, String> result = new LinkedHashMap<>(); for(int i = 0; i < length; i++){ result.put(readString(), readString()); } return result; }
public void load(XGBoostDataInput input) throws IOException { this.base_score = input.readFloat(); this.num_features = input.readInt(); this.num_class = input.readInt(); this.contain_extra_attrs = input.readInt(); this.contain_eval_metrics = input.readInt(); input.readReserved(29); String name_obj = input.readString(); switch(name_obj){ case "reg:linear": String name_gbm = input.readString(); switch(name_gbm){ case "gbtree": this.attributes = input.readStringMap(); max_delta_step = input.readString(); } catch(EOFException eof){ this.metrics = input.readStringList();
public void load(XGBoostDataInput input) throws IOException { this.num_trees = input.readInt(); this.num_roots = input.readInt(); this.num_feature = input.readInt(); input.readReserved(3); this.num_output_group = input.readInt(); this.size_leaf_vector = input.readInt(); input.readReserved(32); this.trees = new ArrayList<>(); for(int i = 0; i < this.num_trees; i++){ RegTree tree = new RegTree(); tree.load(input); this.trees.add(tree); } this.tree_info = new int[this.num_trees]; for(int i = 0; i < this.num_trees; i++){ this.tree_info[i] = input.readInt(); } }
static public Learner loadLearner(InputStream is, ByteOrder byteOrder, String charset) throws IOException { XGBoostDataInput input = new XGBoostDataInput(is, byteOrder, charset); Learner learner = new Learner(); learner.load(input); int eof = is.read(); if(eof != -1){ throw new IOException(); } return learner; }
public String readString() throws IOException { int length = (int)readLong(); byte[] buffer = new byte[length]; ByteStreams.readFully(this.is, buffer); if(this.charset != null){ return new String(buffer, this.charset); } return new String(buffer); }
public void load(XGBoostDataInput input) throws IOException { this.base_score = input.readFloat(); this.num_features = input.readInt(); this.num_class = input.readInt(); this.contain_extra_attrs = input.readInt(); this.contain_eval_metrics = input.readInt(); input.readReserved(29); String name_obj = input.readString(); switch(name_obj){ case "reg:linear": String name_gbm = input.readString(); switch(name_gbm){ case "gbtree": this.attributes = input.readStringMap(); max_delta_step = input.readString(); } catch(EOFException eof){ this.metrics = input.readStringList();
public void load(XGBoostDataInput input) throws IOException { this.num_trees = input.readInt(); this.num_roots = input.readInt(); this.num_feature = input.readInt(); input.readReserved(3); this.num_output_group = input.readInt(); this.size_leaf_vector = input.readInt(); input.readReserved(32); this.trees = new ArrayList<>(); for(int i = 0; i < this.num_trees; i++){ RegTree tree = new RegTree(); tree.load(input); this.trees.add(tree); } this.tree_info = new int[this.num_trees]; for(int i = 0; i < this.num_trees; i++){ this.tree_info[i] = input.readInt(); } }
static public Learner loadLearner(InputStream is, ByteOrder byteOrder, String charset) throws IOException { XGBoostDataInput input = new XGBoostDataInput(is, byteOrder, charset); Learner learner = new Learner(); learner.load(input); int eof = is.read(); if(eof != -1){ throw new IOException(); } return learner; }
public String readString() throws IOException { int length = (int)readLong(); byte[] buffer = new byte[length]; ByteStreams.readFully(this.is, buffer); if(this.charset != null){ return new String(buffer, this.charset); } return new String(buffer); }
public Map<String, String> readStringMap() throws IOException { int length = (int)readLong(); Map<String, String> result = new LinkedHashMap<>(); for(int i = 0; i < length; i++){ result.put(readString(), readString()); } return result; }
public void load(XGBoostDataInput input) throws IOException { this.num_roots = input.readInt(); this.num_nodes = input.readInt(); this.num_deleted = input.readInt(); this.max_depth = input.readInt(); this.num_feature = input.readInt(); this.size_leaf_vector = input.readInt(); input.readReserved(31); this.nodes = new ArrayList<>(); for(int i = 0; i < this.num_nodes; i++){ Node node = new Node(); node.load(input); this.nodes.add(node); } this.stats = new ArrayList<>(); for(int i = 0; i < this.num_nodes; i++){ NodeStat stat = new NodeStat(); stat.load(input); this.stats.add(stat); } }
public float readFloat() throws IOException { return asDataInput().readFloat(); }
public void readReserved(int length) throws IOException { int[] buffer = new int[length]; boolean empty = true; for(int i = 0; i < length; i++){ int value = readInt(); buffer[i] = value; empty &= (value == 0); } if(!empty){ throw new IOException("Expected " + length + "-element array of zeroes, got " + Arrays.toString(buffer)); } }
public List<String> readStringList() throws IOException { int length = (int)readLong(); List<String> result = new ArrayList<>(); for(int i = 0; i < length; i++){ result.add(readString()); } return result; }
public void load(XGBoostDataInput input) throws IOException { this.num_roots = input.readInt(); this.num_nodes = input.readInt(); this.num_deleted = input.readInt(); this.max_depth = input.readInt(); this.num_feature = input.readInt(); this.size_leaf_vector = input.readInt(); input.readReserved(31); this.nodes = new ArrayList<>(); for(int i = 0; i < this.num_nodes; i++){ Node node = new Node(); node.load(input); this.nodes.add(node); } this.stats = new ArrayList<>(); for(int i = 0; i < this.num_nodes; i++){ NodeStat stat = new NodeStat(); stat.load(input); this.stats.add(stat); } }