def test_weighted_additive(self): self.m12 = DenseMatrix(np.mat([[3,1],[9,2]])) self.m22 = DenseMatrix(np.mat([[4,3],[2,1]])) self.ph2 = DenseMatrix(np.mat([[18,11],[24,7]])) self.row = ["a", "b"] self.ft = ["f1","f2"] self.space1 = Space(DenseMatrix(self.m12), self.row, self.ft) self.space2 = Space(DenseMatrix(self.ph2), ["a_a","a_b"], self.ft) m = WeightedAdditive() m.export(self.prefix + ".add1") m.train([("a","a","a_a")], self.space1, self.space2) m.export(self.prefix + ".add2")
def test_weighted_additive(self): self.m12 = DenseMatrix(np.mat([[3, 1], [9, 2]])) self.m22 = DenseMatrix(np.mat([[4, 3], [2, 1]])) self.ph2 = DenseMatrix(np.mat([[18, 11], [24, 7]])) self.row = ["a", "b"] self.ft = ["f1", "f2"] self.space1 = Space(DenseMatrix(self.m12), self.row, self.ft) self.space2 = Space(DenseMatrix(self.ph2), ["a_a", "a_b"], self.ft) m = WeightedAdditive() m.export(self.prefix + ".add1") m.train([("a", "a", "a_a")], self.space1, self.space2) m.export(self.prefix + ".add2")
#ex11.py #------- from composes.utils import io_utils from composes.composition.weighted_additive import WeightedAdditive # instantiate a weighted additive model my_comp = WeightedAdditive(alpha = 1, beta = 1) #save it to pickle io_utils.save(my_comp, "./data/out/model01.pkl") #print its parameters my_comp.export("./data/out/model01.params")