Example #1
0
readLocation = "../../runs/clean/models/"

if __name__ == "__main__":
    files = os.listdir(readLocation)

    suppress.suppress(2)
    for f in files:
        print f
        #It is a data file.
        if f.split('.')[-1] == 'dat':

            #Open files
            fn = dataio.loadData(readLocation + str(f))
            fn.matrixToModel(fn.modelList)

            sigma = IntegerRange(0, fn.obs)

            alldata = []
            for i in fn.assignedData:
                alldata += i

            print "hmm silhouette:" + str(
                hmmextra.hmmSilhoutte(alldata, fn.models, sigma))
            print "inter-model dist:" + str(
                markov_anneal._fitness(fn.models, fn.assignedData, sigma))
            print "Outliers:" + str(len(fn.out))
            print "Clusters per models:" + str(
                [len(i) for i in fn.assignedData])
            print ""
    suppress.restore(2)
Example #2
0
                trainData = markov_anneal.train(sData.values()[0:700], \
                                                numModels, \
                                                states, obs, \
                                                iterations = 20, \
                                                printBest = False,  \
                                                clustering = "kmeans", \
                                                verbose = False)
                """
                
                sigma = IntegerRange(0, obs)
                bd2 = []

                for j in bd:
                    bd2 += j
                s = hmmextra.hmmSilhoutte(bd2, bm, sigma)
                f = markov_anneal._fitness(bm, bd, sigma)
            
                print "models: " + str(n) + "  states:" + str(o) + \
                    "   Silhouette:" + str(s) + "     inter-distance:" + str(f)
                
                if s > bestSil:
                    bestSil = s
                    bestModels = bm
                    bestData = bd
                    bestOut = out
                    bestStates = states
                    bestInter = f

        
        sigma = IntegerRange(0, obs)
        bd2 = []
Example #3
0
suppress.suppress(2)
from ghmm import *
suppress.restore(2)

readLocation = "../../runs/clean/models/"

if __name__ == "__main__":
    files = os.listdir(readLocation)

    suppress.suppress(2)
    for f in files:
        print f
        #It is a data file.
        if f.split('.')[-1] == 'dat':
        
            #Open files
            fn = dataio.loadData(readLocation + str(f))
            fn.matrixToModel(fn.modelList)
            
            sigma = IntegerRange(0, fn.obs)
            
            alldata = []
            for i in fn.assignedData:
                alldata += i
            
            print "hmm silhouette:" + str(hmmextra.hmmSilhoutte(alldata, fn.models, sigma))
            print "inter-model dist:" + str(markov_anneal._fitness(fn.models, fn.assignedData, sigma))
            print "Outliers:" + str(len(fn.out))
            print "Clusters per models:" + str([len(i) for i in fn.assignedData])
            print ""
    suppress.restore(2)
Example #4
0
                trainData = markov_anneal.train(sData.values()[0:700], \
                                                numModels, \
                                                states, obs, \
                                                iterations = 20, \
                                                printBest = False,  \
                                                clustering = "kmeans", \
                                                verbose = False)
                """

                sigma = IntegerRange(0, obs)
                bd2 = []

                for j in bd:
                    bd2 += j
                s = hmmextra.hmmSilhoutte(bd2, bm, sigma)
                f = markov_anneal._fitness(bm, bd, sigma)

                print "models: " + str(n) + "  states:" + str(o) + \
                    "   Silhouette:" + str(s) + "     inter-distance:" + str(f)

                if s > bestSil:
                    bestSil = s
                    bestModels = bm
                    bestData = bd
                    bestOut = out
                    bestStates = states
                    bestInter = f

        sigma = IntegerRange(0, obs)
        bd2 = []
        for j in bestData: