Example #1
0
    def generate_lhs_flrg(self, sample):
        lags = {}

        flrgs = []

        for ct, o in enumerate(self.lags):
            lhs = [
                key for key in self.partitioner.ordered_sets
                if self.sets[key].membership(sample[o - 1]) > self.alpha_cut
            ]
            lags[ct] = lhs

        root = tree.FLRGTreeNode(None)

        tree.build_tree_without_order(root, lags, 0)

        # Trace the possible paths
        for p in root.paths():
            flrg = HighOrderFLRG(self.order)
            path = list(reversed(list(filter(None.__ne__, p))))

            for lhs in path:
                flrg.append_lhs(lhs)

            flrgs.append(flrg)

        return flrgs
Example #2
0
    def generate_lhs_flrg_fuzzyfied(self, sample, explain=False):
        lags = {}

        flrgs = []

        for ct, o in enumerate(self.lags):
            lags[ct] = sample[o-1]

            if explain:
                print("\t (Lag {}) {} -> {} \n".format(o, sample[o-1], lhs))

        root = tree.FLRGTreeNode(None)

        tree.build_tree_without_order(root, lags, 0)

        # Trace the possible paths
        for p in root.paths():
            flrg = WeightedHighOrderFLRG(self.order)
            path = list(reversed(list(filter(None.__ne__, p))))

            for lhs in path:
                flrg.append_lhs(lhs)

            flrgs.append(flrg)

        return flrgs
Example #3
0
    def generate_lhs_flrg(self, sample):
        lags = {}

        flrgs = []

        for ct, o in enumerate(self.lags):
            lhs = FuzzySet.fuzzyfy(sample[o - 1],
                                   partitioner=self.partitioner,
                                   mode="sets",
                                   alpha_cut=self.alpha_cut)
            lags[ct] = lhs

        root = tree.FLRGTreeNode(None)

        tree.build_tree_without_order(root, lags, 0)

        # Trace the possible paths
        for p in root.paths():
            flrg = HighOrderFLRG(self.order)
            path = list(reversed(list(filter(None.__ne__, p))))

            for lhs in path:
                flrg.append_lhs(lhs)

            flrgs.append(flrg)

        return flrgs
Example #4
0
    def generate_lhs_flrg_fuzzyfied(self, sample, explain=False):
        lags = []
        flrgs = []

        for ct, o in enumerate(self.lags):
            lags.append(sample[o - 1])

            if explain:
                print("\t (Lag {}) {} \n".format(o, sample[o - 1]))

        # Trace the possible paths
        for path in product(*lags):
            flrg = WeightedHighOrderFLRG(self.order)

            for lhs in path:
                flrg.append_lhs(lhs)

            flrgs.append(flrg)

        return flrgs
Example #5
0
    def generate_lhs_flrg_fuzzyfied(self, sample, explain=False):
        lags = []
        flrgs = []

        for ct, o in enumerate(self.lags):
            lhs = sample[o - 1]
            lags.append(lhs)

            if explain:
                self.append_log("Ordering Lags",
                                "Lag {} Value {}".format(o, lhs))

        # Trace the possible paths
        for path in product(*lags):
            flrg = HighOrderFLRG(self.order)

            for lhs in path:
                flrg.append_lhs(lhs)

            flrgs.append(flrg)

        return flrgs
Example #6
0
    def generate_lhs_flrg(self, sample):
        lags = {}

        flrgs = []

        for o in np.arange(0, self.order):
            lhs = self.fuzzyfication(sample[o])
            lags[o] = lhs

        root = tree.FLRGTreeNode(None)

        tree.build_tree_without_order(root, lags, 0)

        # Trace the possible paths
        for p in root.paths():
            flrg = ClusteredMultivariateHighOrderFLRG(self.order)
            path = list(reversed(list(filter(None.__ne__, p))))

            for lhs in path:
                flrg.append_lhs(lhs)

            flrgs.append(flrg)

        return flrgs