def testCheckNames(self): pnts = array([[1, 1, 1], [5, 5, 5]]) fcm1 = FCMdata('test_fcm1', pnts, ['fsc', 'ssc', 'cd3'], [0, 1]) fcm2 = FCMdata('test_fcm2', pnts, ['fsc', 'ssc', 'cd3'], [0, 1]) fcm3 = FCMdata('test_fcm3', pnts, ['fsc', 'ssc', 'cd4'], [0, 1]) fcms1 = FCMcollection('fcms1', [fcm1, fcm2]) fcms2 = FCMcollection('fcms2', [fcm1, fcm2, fcm3, fcms1]) check1 = fcms1.check_names() assert check1[fcms1.name] == [True, True, True] check2 = fcms2.check_names() assert check2[fcms2.name] == [check1, True, True, False]
def testListFitting(self): true1, data1 = self.generate_data() true2, data2 = self.generate_data() model = DPMixtureModel(3,2000,100,1, type='BEM') rs = model.fit([data1,data2]) assert(len(rs) == 2) for r in rs: print 'mu ',r.mus diffs = {} for i in gen_mean: diffs[i] = np.min(np.abs(r.mus-gen_mean[i]),0) #print i, gen_mean[i], diffs[i], np.vdot(diffs[i],diffs[i]) assert( np.vdot(diffs[i],diffs[i]) < 1) fcm1 = FCMdata('test_fcm1', data1, ['fsc','ssc'], [0,1]) fcm2 = FCMdata('test_fcm2', data2, ['fsc','ssc'], [0,1]) c = FCMcollection('fcms', [fcm1, fcm2]) rs = model.fit(c) assert(len(rs) == 2) for r in rs: print 'mu ',r.mus diffs = {} for i in gen_mean: diffs[i] = np.min(np.abs(r.mus-gen_mean[i]),0) #print i, gen_mean[i], diffs[i], np.vdot(diffs[i],diffs[i]) assert( np.vdot(diffs[i],diffs[i]) < 1)
def setUp(self): pnts = array([[1, 1, 1], [5, 5, 5]]) fcm1 = FCMdata('test_fcm1', pnts, ['fsc', 'ssc', 'cd3'], [0, 1]) fcm2 = FCMdata('test_fcm2', pnts, ['fsc', 'ssc', 'cd3'], [0, 1]) self.fcms = FCMcollection('fcms', [fcm1, fcm2])