def generateSVGGridMolsByLabel(topicModel, label, idLabelToMatch=0, baseRad=0.5, molSize=(250, 150), svgsPerRow=4): result = generateMoleculeSVGsbyLabel(topicModel, label, idLabelToMatch=idLabelToMatch, baseRad=baseRad, molSize=molSize) if len(result) == 1: print(result) return svgs, namesSVGs, labelName = result svgGrid = utilsDrawing.SvgsToGrid(svgs, namesSVGs, svgsPerRow=svgsPerRow, molSize=molSize) return svgGrid
def generateSVGGridFragemntsForTopic(topicModel, topicIdx, n_top_frags=10, molSize=(100,100),\ svg=True, prior=-1.0, fontSize=0.9,svgsPerRow=4): svgs = generateTopicRelatedFragmentSVGs(topicModel, topicIdx, n_top_frags=n_top_frags, molSize=molSize,\ svg=svg, prior=prior, fontSize=fontSize) scores = topicModel.getTopicFragmentProbabilities() namesSVGs = list(map(lambda x: "p(k={0})={1:.2f}".format(topicIdx,x), \ filter(lambda y: y > prior, sorted(scores[topicIdx,:], reverse=True)[:n_top_frags]))) svgGrid = utilsDrawing.SvgsToGrid(svgs, namesSVGs, svgsPerRow=svgsPerRow, molSize=molSize) return svgGrid
def generateSVGGridMolsbyTopic(topicModel, topicIdx, idsLabelToShow=[0], topicProbThreshold = 0.5, baseRad=0.5, \ molSize=(250,150), svgsPerRow=4, color=(1.,1.,1.)): result = generateMoleculeSVGsbyTopicIdx(topicModel, topicIdx, idsLabelToShow=idsLabelToShow, \ topicProbThreshold = topicProbThreshold, baseRad=baseRad,\ molSize=molSize,color=color) if len(result) == 1: print(result) return svgs, namesSVGs = result svgGrid = utilsDrawing.SvgsToGrid(svgs, namesSVGs, svgsPerRow=svgsPerRow, molSize=molSize) return svgGrid