コード例 #1
0
    def onlyForFirstIncrement(self, local_min_sup):
        previous_threshold = UserDefined.min_sup
        previous_data_set = Variable.size_of_dataset

        # set the min_sup by given local min sup
        UserDefined.min_sup = local_min_sup
        Variable.size_of_dataset = len(ProgramVariable.uSDB)
        tmp_root_node, tot_candidates = FUWSequence().douWSequence()
        self.cur_ls_trie = Trie(tmp_root_node)

        # load and update upto threshold and the size of the dataset

        for i in range(0, len(ProgramVariable.uSDB)):
            self.fssfs_trie.update_support(self.fssfs_trie.root_node, None, 0.0, 0, i)

        previous_data_set += len(ProgramVariable.uSDB)
        ProgramVariable.uSDB = ProgramVariable.pre_uSDB
        for i in range(0, len(ProgramVariable.uSDB)):
            self.cur_ls_trie.update_support(self.cur_ls_trie.root_node, None, 0.0, 0, i)

        # Merging tries
        self.fssfs_trie.merge_ls_with_fssfs_trie(self.cur_ls_trie.root_node, self.fssfs_trie.root_node)
        self.cur_ls_trie = None

        # update tries
        self.fssfs_trie.traverse_trie(self.fssfs_trie.root_node)
        self.fssfs_trie.update_trie(self.fssfs_trie.root_node)

        UserDefined.min_sup = previous_threshold
        Variable.size_of_dataset = previous_data_set
        Variable.WAM = ProgramVariable.pre_upto_wSum/ProgramVariable.pre_upto_sum

        # writing tries to file
        self.fssfs_trie.trie_into_file(self.fssfs_trie.root_node, '')
        return
コード例 #2
0
    def uWSIncPlusMethod(self, local_min_sup):

        # store upto threshold and the size of the dataset
        previous_threshold = UserDefined.min_sup
        previous_data_set = Variable.size_of_dataset

        # set the min_sup by given local min sup
        UserDefined.min_sup = local_min_sup
        Variable.size_of_dataset = len(ProgramVariable.uSDB)
        tmp_root_node, tot_candidates = FUWSequence().douWSequence()

        self.cur_ls_trie = Trie(tmp_root_node)
        self.cur_ls_trie.printFSSFS(self.cur_ls_trie.root_node, '')

        for i in range(0, len(ProgramVariable.uSDB)):
            self.fssfs_trie.update_support(self.fssfs_trie.root_node, None, 0.0, 0, i)

        # Merging tries
        self.fssfs_trie.merge_ls_with_fssfs_trie(self.cur_ls_trie.root_node, self.fssfs_trie.root_node)
        self.cur_ls_trie = None

        # update tries
        self.fssfs_trie.traverse_trie(self.fssfs_trie.root_node)
        self.fssfs_trie.update_trie(self.fssfs_trie.root_node)

        current_threshold = ThresholdCalculation.get_semi_wgt_exp_sup()

        UserDefined.min_sup = previous_threshold
        Variable.size_of_dataset = previous_data_set
        Variable.size_of_dataset += len(ProgramVariable.uSDB)
        Variable.WAM = ProgramVariable.pre_upto_wSum / ProgramVariable.pre_upto_sum

        # writing tries to file
        self.fssfs_trie.printPFS(self.fssfs_trie.root_node, '', ThresholdCalculation.get_semi_wgt_exp_sup(), current_threshold)
        self.fssfs_trie.trie_into_file(self.fssfs_trie.root_node, '')

        return
コード例 #3
0
    #WAM calculation && DataBase size update
    WAMCalculation.update_WAM()

    Variable.size_of_dataset = len(ProgramVariable.uSDB)
    print(Variable.size_of_dataset, ' size of dataset')
    print('WAM Done')
    for mn_sup in min_sup_lst:
        UserDefined.min_sup = mn_sup
        for fct in wgt_fct_lst:
            UserDefined.wgt_factor = fct
            for mu in mu_lst:
                Variable.mu = mu

                start_time = time.time()
                root_node, total_candidates = FUWSequence().douWSequence()
                fssfs_trie = Trie(root_node)
                fssfs_trie.update_trie(fssfs_trie.root_node)
                total_patterns = fssfs_trie.trie_into_file(fssfs_trie.root_node, '')


                FileInfo.fs.close()
                FileInfo.sfs.close()
                end_time = time.time()

                print('FUWS: Total Candidates - ', total_candidates)
                print('FUWS: Total Patterns - ', total_patterns)
                print(start_time, end_time, end_time-start_time)

                FileInfo.fs = open('initialFS_UWS.txt', 'w')
                FileInfo.sfs = open('initialSFS_UWS.txt', 'w')
コード例 #4
0
        #WAM calculation && DataBase size update
        WAMCalculation.update_WAM()

        Variable.size_of_dataset += len(ProgramVariable.uSDB)
        print(Variable.size_of_dataset, ' : Size of dataset')
        ProgramVariable.uSDB += previous_usdb
        ProgramVariable.pSDB += previous_psdb
        print(len(ProgramVariable.pSDB),
              ' : check the value with previous one')
        # print()
        print('WAM: ', Variable.WAM)
        print('Threshold: ', ThresholdCalculation.get_wgt_exp_sup(),
              ThresholdCalculation.get_semi_wgt_exp_sup(), ' at uWSeq')
        root_node = FUWSequence().douWSequence()
        fssfs_trie = Trie(root_node)
        fssfs_trie.update_trie(fssfs_trie.root_node)
        fssfs_trie.trie_into_file(fssfs_trie.root_node, '')

        FileInfo.fs.close()
        FileInfo.sfs.close()

        end_time = time.time()
        FileInfo.time_info.write(str(end_time - previous_time))
        FileInfo.time_info.write('\n')
        previous_psdb = ProgramVariable.pSDB
        previous_usdb = ProgramVariable.uSDB
        print('Increment No', i)
        FileInfo.fs = open(prefix_all + '/fs_naive' + str(i) + '.txt', 'r')
        count_fs = 0
        for seq in FileInfo.fs:
コード例 #5
0
    # we provided a file named as 'manual_weights.txt' in 'Files' folder
    # In that file you can assign weight to each item manually. This is to inform you that
    # file contains an item and its weight separated by an space in each line
    # Don't forget to update accordingly if you wish

    # WAM will be calculated && DataBase size will be been updated

    WAMCalculation.update_WAM()
    Variable.size_of_dataset = len(ProgramVariable.uSDB)

    start_time = time.time()

    root_node, total_candidates = FUWSequence().douWSequence()      # To find the potential candidate patterns

    fssfs_trie = Trie(root_node)                                    # Patterns are stored into USeq-Trie

    fssfs_trie.update_trie(fssfs_trie.root_node)                    # calculate actual WES and remove false patterns

    fssfs_trie.trie_into_file(fssfs_trie.root_node, '')             # write the desired patterns (FS & SFS) into files

    FileInfo.fs.close()
    FileInfo.sfs.close()

    end_time = time.time()

    print('Total required time(in Seconds): ', end_time-start_time)



コード例 #6
0
    PreProcess().doProcess()
    # for seq in ProgramVariable.pSDB:
    #     print(seq, ' Print at Nothing')

    print('Preprocess Done!')

    # Weight Assigning
    WeightAssign.assign(ProgramVariable.itemList)
    # WeightAssign.manual_assign()
    print('Weight Assign Done')

    #WAM calculation && DataBase size update
    WAMCalculation.update_WAM()

    Variable.size_of_dataset = len(ProgramVariable.uSDB)
    print(Variable.size_of_dataset, ' size of dataset')
    print('WAM Done')
    start_time = time.time()
    root_node, total_candidates = UWSequence().douWSequence()
    fssfs_trie = Trie(root_node)
    # fssfs_trie.update_trie(fssfs_trie.root_node)
    total_num_patterns = fssfs_trie.trie_into_file(fssfs_trie.root_node, '')

    FileInfo.fs.close()
    FileInfo.sfs.close()
    end_time = time.time()

    print('Total Candidates: ', total_candidates)
    print('Total Patterns: ', total_num_patterns)
    print('Total Times: ', start_time, end_time, end_time - start_time)
コード例 #7
0
    # You can change the file but make sure that you name the file exactly same as the given name

    # wgt_assign_obj.manual_assign()            # this is for manual way to assign weight

    # we provided a file named as 'manual_weights.txt' in 'Files' folder
    # In that file you can assign weight to each item manually. This is to inform you that
    # file contains an item and its weight separated by an space in each line
    # Don't forget to update accordingly if you wish

    # WAM will be calculated && DataBase size will be initialized
    WAMCalculation.update_WAM()
    Variable.size_of_dataset = len(ProgramVariable.uSDB)

    # Run FUWS algorithm to get FS and SFS from initial datasets and store store them into USeq-Trie
    fsfss_trie_root_node, total_candidates = FUWSequence().douWSequence()
    fsfss_trie = Trie(fsfss_trie_root_node)
    fsfss_trie.update_trie(fsfss_trie.root_node)
    fsfss_trie.trie_into_file(fsfss_trie.root_node, '')

    cur_time = time.time()
    FileInfo.time_info.write(str(cur_time - previous_time))
    FileInfo.time_info.write('\n')

    ls_trie = Trie(TrieNode(False, None, None, 0.0,
                            False))  # Initialize the trie to store LFS

    FileInfo.fs.write('\n ----------- \n')
    FileInfo.sfs.write('\n ----------- \n')
    FileInfo.pfs.write('\n ----------- \n')
    FileInfo.ls.write('\n ----------- \n')
コード例 #8
0
                    # Dataset Preprocessing
                    PreProcess().doProcess()

                    WeightAssign.assign(ProgramVariable.itemList)
                    # WAM calculation && DataBase size update
                    WAMCalculation.upto_sum = 0
                    WAMCalculation.upto_wSum = 0
                    WAMCalculation.update_WAM()

                    Variable.size_of_dataset += len(ProgramVariable.uSDB)
                    ProgramVariable.uSDB += previous_usdb
                    ProgramVariable.pSDB += previous_psdb

                    root_node = UWSequence().douWSequence()
                    fssfs_trie = Trie(root_node)
                    fssfs_trie.update_trie(fssfs_trie.root_node)
                    fssfs_trie.trie_into_file(fssfs_trie.root_node, '')

                    FileInfo.fs.close()
                    FileInfo.sfs.close()

                    cnt = 0
                    f = open(
                        input_folder + '/result/fs_naive' + str(i) + '.txt',
                        'r')
                    for line in f:
                        if line == '\n' or line.strip() == '':
                            break
                        cnt += 1
                    patterns0.append(cnt)