def predict(self, data_inst, predict_param=None):
        LOGGER.info("start predict")
        cache_dataset_key = self.predict_data_cache.get_data_key(data_inst)
        if cache_dataset_key in self.data_alignment_map:
            data_inst = self.data_alignment_map[cache_dataset_key]
        else:
            data_inst = self.data_alignment(data_inst)
            header = [None] * len(self.feature_name_fid_mapping)
            for idx, col in self.feature_name_fid_mapping.items():
                header[idx] = col
            data_inst = data_overview.header_alignment(data_inst, header)
            self.data_alignment_map[cache_dataset_key] = data_inst

        rounds = len(self.trees_) // self.tree_dim
        predict_start_round = self.sync_predict_start_round()
        for i in range(predict_start_round, rounds):
            # n_tree = self.trees_[i]
            for tidx in range(self.tree_dim):
                LOGGER.info(
                    "start to predict, boost round: {}, tree index: {}".format(
                        i, tidx))
                tree_inst = HeteroDecisionTreeHost(self.tree_param)
                tree_inst.load_model(self.tree_meta,
                                     self.trees_[i * self.tree_dim + tidx])
                # tree_inst.set_tree_model(self.trees_[i * self.tree_dim + tidx])
                tree_inst.set_flowid(self.generate_flowid(i, tidx))
                tree_inst.set_runtime_idx(
                    self.component_properties.local_partyid)

                tree_inst.predict(data_inst)

        LOGGER.info("end predict")
Пример #2
0
    def predict(self, data_inst, predict_param=None):
        LOGGER.info("start predict")
        for i in range(len(self.trees_)):
            n_tree = self.trees_[i]
            for tidx in range(len(n_tree)):
                tree_inst = HeteroDecisionTreeHost(self.tree_param)
                tree_inst.set_tree_model(n_tree[tidx])
                tree_inst.set_flowid(self.generate_flowid(i, tidx))

                tree_inst.predict(data_inst)

        LOGGER.info("end predict")
    def predict_f_value(self, data_inst, predict_start_round, rounds):
        for i in range(predict_start_round, rounds):
            # n_tree = self.trees_[i]
            for tidx in range(self.tree_dim):
                tree_inst = HeteroDecisionTreeHost(self.tree_param)
                tree_inst.load_model(self.tree_meta,
                                     self.trees_[i * self.tree_dim + tidx])
                # tree_inst.set_tree_model(self.trees_[i * self.tree_dim + tidx])
                tree_inst.set_flowid(self.generate_flowid(i, tidx))
                tree_inst.set_runtime_idx(
                    self.component_properties.local_partyid)

                tree_inst.predict(data_inst)
    def predict(self, data_inst, predict_param=None):
        LOGGER.info("start predict")
        data_inst = self.data_alignment(data_inst)
        rounds = len(self.trees_) // self.tree_dim
        for i in range(rounds):
            for tidx in range(self.tree_dim):
                tree_inst = HeteroDecisionTreeHost(self.tree_param)
                tree_inst.load_model(self.tree_meta, self.trees_[i * self.tree_dim + tidx])
                tree_inst.set_flowid(self.generate_flowid(i, tidx))
                tree_inst.set_runtime_idx(self.runtime_idx)

                tree_inst.predict(data_inst)

        LOGGER.info("end predict")
Пример #5
0
    def predict(self, data_inst, predict_param=None):
        LOGGER.info("start predict")
        data_inst = self.data_alignment(data_inst)
        rounds = len(self.trees_) // self.tree_dim
        predict_start_round = self.sync_predict_start_round()
        for i in range(predict_start_round, rounds):
            # n_tree = self.trees_[i]
            for tidx in range(self.tree_dim):
                tree_inst = HeteroDecisionTreeHost(self.tree_param)
                tree_inst.load_model(self.tree_meta,
                                     self.trees_[i * self.tree_dim + tidx])
                # tree_inst.set_tree_model(self.trees_[i * self.tree_dim + tidx])
                tree_inst.set_flowid(self.generate_flowid(i, tidx))
                tree_inst.set_runtime_idx(
                    self.component_properties.local_partyid)

                tree_inst.predict(data_inst)

        LOGGER.info("end predict")