def test_aggregate_average(self): a = np.array([1, 6, 3, 4, 4]) b = np.array([5, 7, 2, 5, 1]) c = np.array([6, 8, 4, 6, 1]) expect = np.array([4, 7, 3, 5, 2]) actual = aggregate([a, b, c], method=AVERAGE) assert(np.allclose(actual, expect))
def test_aggregate_or(self): a = np.array([1, 6, 3, 4, 4]) b = np.array([5, 7, 2, 5, 1]) c = np.array([6, 8, 4, 6, 1]) expect = np.array([6, 8, 4, 6, 4]) actual = aggregate([a, b, c], method=OR) assert(np.allclose(actual, expect))
def aggregate(self): """Aggregates all implicated membership functions into one resulting mf. """ variables = self.get_output_variables() for varname, variable in variables.items(): imfs = [] for rule in self.rules: imf = rule.consequent.result[varname] if imf is not None: imfs.append(rule.consequent.result[varname]) variable.aggrmf = helper.aggregate(imfs, self.aggregation)
def test_aggregate_or_single(self): a = np.array([1, 6, 3, 4, 4]) expect = np.array([1, 6, 3, 4, 4]) actual = aggregate([a], method=OR) assert(np.allclose(actual, expect))
def test_aggregate_average_single(self): a = np.array([1, 6, 3, 4, 4]) expect = np.array([1, 6, 3, 4, 4]) actual = aggregate([a], method=AVERAGE) assert(np.allclose(actual, expect))