def test_factor_too_big(): "Factor is between 0 and 1." Blend([t1, t2], factor=1.5)
def test_bare_blend(): ''' A matrix blended with nothing else changes nothing. ''' b = Blend([t1], weights=[1]) assertSetEquals(set(t1.label_list(0)), set(b.label_list(0)))
def test_specifying_factor(): ''' When a factor is supplied, use it as the weight of the second matrix. ''' eq_(Blend([t1, t2], factor=.25).weights, (0.75, 0.25))
def predicted_by_overlap(factors, mat1, mat2, row_overlap, col_overlap): blend = Blend(overlap_matrices(mat1, mat2, row_overlap, col_overlap), factor=0) return [ blend.predicted_svals_at_factor(factor, num=15) for factor in factors ]
def veering_by_overlap(mat1, mat2, row_overlap, col_overlap): t1, t2 = overlap_matrices(mat1, mat2, row_overlap, col_overlap) blend = Blend([t1, t2], factor=0) return [ blend.total_veering_at_factor(factor, num=15) for factor in factors ]
def svals_by_overlap(factors, mat1, mat2, row_overlap, col_overlap): blend = Blend(overlap_matrices(mat1, mat2, row_overlap, col_overlap), factor=0) return [blend.svals_at_factor(factor, k=15) for factor in factors]
def _get_color_blend(): colors = get_picklecached_thing(FILEPATH+os.sep+'colormatrix.pickle.gz', _make_color_matrix) cnet = get_picklecached_thing(FILEPATH+os.sep+'cnet.pickle.gz', lambda: conceptnet_2d_from_db('en')) colorblend = Blend([colors, cnet]).normalized(mode=[0,1]).bake() return colorblend
def make_blend(other): return Blend([cnet, other])
def test_blend_mean_subtracted(): from csc.divisi.blend import Blend Blend([tensor.mean_subtracted()])
from csc.conceptnet4.analogyspace import conceptnet_by_relations, identities_for_all_relations from csc.divisi.blend import Blend from csc.divisi import export_svdview byrel = conceptnet_by_relations('en') t = identities_for_all_relations(byrel) b = Blend(byrel.values() + [t]) s = b.svd() export_svdview.write_packed(s.u, 'littleblend', lambda x: x) s.summarize()