コード例 #1
0
ファイル: Clusters.py プロジェクト: billdthompson/NorthWind
def makeInferenceForPlotting(N,cp,D):
	"grab MAP inferences under WANG"
	inference = sampleWang(D,cp)
	nCats = len(set(inference[1]))
	MAPMus, MAPSDs = [],[]
	for i in range(nCats):
		datasetCat = []
		for j in range(len(inference[0])):
			if inference[1][j] == i:
				datasetCat.append(inference[0][j])
		muCat, sigmaCat = DP.getMAP(datasetCat,paramsDict= modelParameters)
		MAPMus.append(muCat)
		MAPSDs.append(sigmaCat)
	return D, MAPMus, MAPSDs
コード例 #2
0
ファイル: Clusters.py プロジェクト: billdthompson/NorthWind
def IL(startMuA, startMuB, startSDA, startSDB, gens, N,cp=10.,parameters=modelParameters):
	D = sampleData(mus=[startMuA,startMuB],variances = [startSDA,startSDB],N=N)
	nCatData, musData, SDsData = [],[],[]
	for g in range(gens):
		inference = sampleWang(D,cp,parameters)
		#print "Inference:", inference
		nCats = len(set(inference[1]))
		nCatData.append(nCats)
		thisGenMus, thisGenSDs = [],[]
		for i in range(nCats):
			datasetCat = []
			for j in range(len(inference[0])):
				if inference[1][j] == i:
					datasetCat.append(inference[0][j])
			muCat, sigmaCat = DP.getMAP(datasetCat,parameters)
			thisGenMus.append(muCat)
			thisGenSDs.append(sigmaCat)
		musData.append(thisGenMus)
		SDsData.append(thisGenSDs)
		D = sampleData(mus=thisGenMus,variances = thisGenSDs,N=N)
	return nCatData,musData,SDsData