コード例 #1
0
ファイル: Bayesian.py プロジェクト: osigaud/ArmModelPython
    def trainAndCompare(self, K, noise):
        self.rs.deltaK = K
        for i in self.rs.sizeOfTarget:
            launchCMAESForAllPoint(self.rs, i, None, noise)

        resultPath = os.getcwd() + "../Data/CMAESK" + str(K) + "/"
        resultName = "geneForHits/finalX/x.last"

        nameTheta = "Best"
        name = "geneForHits"
        nbret = 50
        generateFromCMAESNController(nbret, self.rs, nameTheta, name, noise)

        result1 = np.loadtxt(resultPath + "0.005/" + resultName)
        result2 = np.loadtxt(resultPath + "0.01/" + resultName)
        result3 = np.loadtxt(resultPath + "0.02/" + resultName)
        result4 = np.loadtxt(resultPath + "0.04/" + resultName)

        return -(cp.kl(result1, self.experiment1, 0.0025) +
                 cp.kl(result2, self.experiment2, 0.005) +
                 cp.kl(result3, self.experiment3, 0.01) +
                 cp.kl(result4, self.experiment4, 0.02))
コード例 #2
0
ファイル: Bayesian.py プロジェクト: osigaud/ArmModelPython
    def trainAndCompare(self, K, noise):
        self.rs.deltaK = K
        for i in self.rs.sizeOfTarget:
            launchCMAESForAllPoint(self.rs, i, None, noise)

        resultPath = os.getcwd() + "../Data/CMAESK" + str(K) + "/"
        resultName = "geneForHits/finalX/x.last"

        nameTheta = "Best"
        name = "geneForHits"
        nbret = 50
        generateFromCMAESNController(nbret, self.rs, nameTheta, name, noise)

        result1 = np.loadtxt(resultPath + "0.005/" + resultName)
        result2 = np.loadtxt(resultPath + "0.01/" + resultName)
        result3 = np.loadtxt(resultPath + "0.02/" + resultName)
        result4 = np.loadtxt(resultPath + "0.04/" + resultName)

        return -(
            cp.kl(result1, self.experiment1, 0.0025)
            + cp.kl(result2, self.experiment2, 0.005)
            + cp.kl(result3, self.experiment3, 0.01)
            + cp.kl(result4, self.experiment4, 0.02)
        )
コード例 #3
0
ファイル: testCompare.py プロジェクト: osigaud/ArmModelPython
experimentalFolder = "~/ArmModelPython/Data/ExperimentalHits/"

experiment1 = np.loadtxt(experimentalFolder + "hits0.005")[:, 1]
experiment2 = np.loadtxt(experimentalFolder + "hits0.01")[:, 1]
experiment3 = np.loadtxt(experimentalFolder + "hits0.02")[:, 1]
experiment4 = np.loadtxt(experimentalFolder + "hits0.04")[:, 1]

print(experiment1.shape[0])

resultPath = "~/ArmModelPython/Data/CMAESK20/"
resultName = "50/finalX/x.last"

result1 = np.loadtxt(resultPath + "0.005/" + resultName)
result2 = np.loadtxt(resultPath + "0.01/" + resultName)
result3 = np.loadtxt(resultPath + "0.02/" + resultName)
result4 = np.loadtxt(resultPath + "0.04/" + resultName)

print("chi2, taille 0.005 : " + str(cp.chi2(result1, experiment1)))
print("KS, taille 0.005 : " + str(cp.ks(result1, experiment1)))
print("MWWRankSum, taille 0.005 : " + str(cp.MWWRankSum(result1, experiment1)))
print("KL, taille 0.005 : " + str(cp.kl(result1, experiment1)))

print cp.mw(np.random.normal(0, 0.005, 10000),
            np.random.normal(0, 0.005, 10000))
print cp.ks(np.random.normal(0, 0.005, 10000),
            np.random.normal(0, 0.005, 10000))
print(
    cp.kl(np.random.normal(0, 0.005, 10000), np.random.normal(0, 0.005,
                                                              10000)))
コード例 #4
0
ファイル: testCompare.py プロジェクト: osigaud/ArmModelPython
import Utils.Compare as cp
import numpy as np
import matplotlib.pyplot as plt

experimentalFolder="~/ArmModelPython/Data/ExperimentalHits/"

experiment1 = np.loadtxt(experimentalFolder+"hits0.005")[:,1]
experiment2 = np.loadtxt(experimentalFolder+"hits0.01")[:,1]
experiment3 = np.loadtxt(experimentalFolder+"hits0.02")[:,1]
experiment4 = np.loadtxt(experimentalFolder+"hits0.04")[:,1]

print(experiment1.shape[0])

resultPath="~/ArmModelPython/Data/CMAESK20/"
resultName="50/finalX/x.last"

result1= np.loadtxt(resultPath+"0.005/"+resultName)
result2= np.loadtxt(resultPath+"0.01/"+resultName)
result3= np.loadtxt(resultPath+"0.02/"+resultName)
result4= np.loadtxt(resultPath+"0.04/"+resultName)


print ("chi2, taille 0.005 : " + str(cp.chi2(result1, experiment1)))
print ("KS, taille 0.005 : " + str(cp.ks(result1, experiment1)))
print ("MWWRankSum, taille 0.005 : " + str(cp.MWWRankSum(result1, experiment1)))
print ("KL, taille 0.005 : " + str(cp.kl(result1, experiment1)))

print cp.mw(np.random.normal(0,0.005,10000),np.random.normal(0,0.005,10000))
print cp.ks(np.random.normal(0,0.005,10000),np.random.normal(0,0.005,10000))
print (cp.kl(np.random.normal(0,0.005,10000),np.random.normal(0,0.005,10000)))