def data_encode_TF(anonymized_dataset, target, paths_to_leaves, is_cat):
    """
    Implement TF encoding, that is:
    - For continuous attributes: if the target value is inside an interval, then set the related entry to 1. Otherwise, to 0.  
    - For categorical attributes: if the target value is in the path from a category to an leaf, then set the related entry to 1. Otherwise, to 0.  
    """
    qi_num = len(anonymized_dataset[0]) - 1
    encoded_data = []
    for i in range(len(anonymized_dataset)):
        record = []
        index = 0
        for j in range(qi_num):
            if is_cat[j]:
                if anonymized_dataset[i][j] in paths_to_leaves[index][target[j]]:
                    record.append(1)
                else:
                    record.append(0)
                index += 1
            else:
                temp = anonymized_dataset[i][j].split(',')
                if len(temp) == 1:
                    low = high = temp[0]
                else:
                    low = temp[0]
                    high = temp[1]
                if low <= target[j] <= high:
                    record.append(1)
                else:
                    record.append(0)                
        record.append(anonymized_dataset[i][-1])
        encoded_data.append(record)
    return encoded_data