示例#1
0
def experiment3(delt=1.5, 
        numIter=30, 
        low=100, 
        high=600, 
        step=100, 
        numTrain=30000, 
        numTest=10000):
	print "experiment 3"
	dimDict = {}
	for numCovs in np.arange(low,high+step,step):
		print "  numCovs=", numCovs
		datgen = dc.DataSim(nCovariates=numCovs,
                nHeterogenous=1,
                delta=np.array([[delt]]))
		datmodel=mdl.simModel(generator=datgen)
		data=[]
		for i in np.arange(0,numIter):
			print "    iter=",i
			Xtrain, Ztrain, Ytrain = datmodel.generate(numTrain)
			datmodel.train(Xtrain, Ztrain, Ytrain)
			Xtest, Ztest, Ytest = datmodel.generate(numTest)
			accuracy, h1, h2 = datmodel.test(Xtest,Ztest,Ytest)
			errs,avgerrs,stderrs = datmodel.getMeansError()
			data.append((accuracy,avgerrs,h1,h2,datmodel))
			datmodel.regenerate() #re-generate the coefficients
		dimDict[numCovs]=data
	return dimDict
示例#2
0
文件: exps.py 项目: rkruser/causality
def experiment(args):
    nPatients = args[0]
    nDims = args[1]
    nSparse = args[2]
    nHeter = args[3]
    heterMeans = args[4] #delta
    nIters = args[5]
    nTest = args[6]
    Bayes = args[7]

    datgen = dc.DataSim(nCovariates=nDims,
                nHeterogenous=nHeter,
                delta=heterMeans) #needs sparsity
	datmodel = mdl.simModel(generator = datgen, BIC = Bayes)
示例#3
0
def experiment1(numIter=30, 
                numTrain=30000, 
                numTest=10000):
	print "experiment 1"
	deltaDict = {}
	for delt in np.arange(-3.0,3.5,0.5):
		print "  delta=",delt
		datgen = dc.DataSim(nCovariates=100,
                nHeterogenous=1,
                delta=np.array([[delt]]))
		datmodel = mdl.simModel(generator = datgen)
		data = []
		for i in np.arange(0,numIter):
			print "    iter=",i
			Xtrain, Ztrain, Ytrain = datmodel.generate(numTrain)
			datmodel.train(Xtrain, Ztrain, Ytrain)
			Xtest, Ztest, Ytest = datmodel.generate(numTest)
			accuracy, h1, h2 = datmodel.test(Xtest,Ztest,Ytest)
			errs,avgerrs,stderrs = datmodel.getMeansError()
			data.append((accuracy,avgerrs,h1,h2,datmodel))
			datmodel.regenerate() #re-generate the coefficients
		deltaDict[delt]=data

	return deltaDict