Пример #1
0
 def train(self, ndata, **kwargs):
     tmpdata = FuzzySet.fuzzyfy(ndata,
                                partitioner=self.partitioner,
                                method='maximum',
                                mode='sets')
     flrs = FLR.generate_recurrent_flrs(tmpdata)
     self.generate_FLRG(flrs)
Пример #2
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 = ProbabilisticWeightedFLRG(self.order)
            path = list(reversed(list(filter(None.__ne__, p))))

            for lhs in path:
                flrg.append_lhs(lhs)

            flrgs.append(flrg)

        return flrgs
Пример #3
0
def fuzzyfy_instance(data_point, var):
    fsets = FuzzySet.fuzzyfy(data_point,
                             var.partitioner,
                             mode='sets',
                             method='fuzzy',
                             alpha_cut=var.alpha_cut)
    return [(var.name, fs) for fs in fsets]
Пример #4
0
    def train(self, data, **kwargs):

        tmpdata = FuzzySet.fuzzyfy(data,
                                   partitioner=self.partitioner,
                                   method='maximum',
                                   mode='sets')
        flrs = FLR.generate_non_recurrent_flrs(tmpdata)
        self.operation_matrix(flrs)
Пример #5
0
    def generate_flrg(self, data):
        l = len(data)
        for k in np.arange(self.max_lag, l):
            lags = {}

            if self.dump: print("FLR: " + str(k))

            sample = data[k - self.max_lag: k]

            rhs = FuzzySet.fuzzyfy(data[k], partitioner=self.partitioner, mode="sets", alpha_cut=self.alpha_cut)

            flrgs = self.generate_lhs_flrg(sample)

            for flrg in flrgs:
                if flrg.get_key() not in self.flrgs:
                    self.flrgs[flrg.get_key()] = flrg;

                for st in rhs:
                    self.flrgs[flrg.get_key()].append_rhs(st)
Пример #6
0
    def generate_lhs_flrg(self, sample, explain=False):

        nsample = [FuzzySet.fuzzyfy(k, partitioner=self.partitioner, mode="sets", alpha_cut=self.alpha_cut)
                   for k in sample]

        return self.generate_lhs_flrg_fuzzyfied(nsample, explain)
Пример #7
0
def fuzzyfy_instance(data_point, var):
    return FuzzySet.fuzzyfy(data_point,
                            var.partitioner,
                            mode='sets',
                            method='fuzzy',
                            alpha_cut=var.alpha_cut)