Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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')
Ejemplo n.º 4
0
        WeightAssign.assign(ProgramVariable.itemList)

        #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
Ejemplo n.º 5
0
    WeightAssign.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 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)