Beispiel #1
0
    def generate_flrs(self, data):
        flrs = []
        for ct in range(1, len(data.index)):
            ix = data.index[ct-1]
            data_point = data.loc[ix]

            tmp_flrs = self.generate_lhs_flrs(data_point)

            target_ix = data.index[ct]
            target_point = data[self.target_variable.data_label][target_ix]
            target = common.fuzzyfy_instance(target_point, self.target_variable)

            for flr in tmp_flrs:
                for v, s in target:
                    flr.set_rhs(s)
                    flrs.append(flr)

        return flrs
Beispiel #2
0
    def generate_lhs_flrs(self, data):
        flrs = []
        lags = {}
        for vc, var in enumerate(self.explanatory_variables):
            data_point = data[var.name]
            lags[var.name] = common.fuzzyfy_instance(data_point, var, tuples=False)

        for path in product_dict(**lags):
            flr = MVFLR.FLR()

            for var, fset in path.items():
                flr.set_lhs(var, fset)

            if len(flr.LHS.keys()) == len(self.explanatory_variables):
                flrs.append(flr)
            else:
                print(flr)

        return flrs
Beispiel #3
0
    def generate_lhs_flrs(self, data):
        flrs = []
        lags = {}
        for vc, var in enumerate(self.explanatory_variables):
            data_point = data[var.data_label]
            lags[vc] = common.fuzzyfy_instance(data_point, var)

        root = tree.FLRGTreeNode(None)

        tree.build_tree_without_order(root, lags, 0)

        for p in root.paths():
            path = list(reversed(list(filter(None.__ne__, p))))

            flr = MVFLR.FLR()

            for v, s in path:
                flr.set_lhs(v, s)

            if len(flr.LHS.keys()) == len(self.explanatory_variables):
                flrs.append(flr)

        return flrs