def predict(self, tree_input): # get tree_feature and input to LR, output LR score. # input format: # [(idx, value), ..] tf = map(lambda x:(x + self.__feature_offset, 1), PyFly.tree_features(self.__gbdt, tree_input)) total_feature = tree_input + tf return PyFly.predict(self.__lr, total_feature)
def predict(self, tree_input): # get tree_feature and input to LR, output LR score. # input format: # [(idx, value), ..] tf = map(lambda x: (x + self.__feature_offset, 1), PyFly.tree_features(self.__gbdt, tree_input)) total_feature = tree_input + tf return PyFly.predict(self.__lr, total_feature)
def __init__(self, tree_model_file, lr_model_file, tree_feature_offset): self.__gbdt = PyFly.load_gbdt(tree_model_file) self.__lr = PyFly.load_lr(lr_model_file) self.__feature_offset = tree_feature_offset