예제 #1
0
def LoadConcepts():
    from JsonParser import JsonParser
    jp = JsonParser()

    return jp.LoadFile(
        CONCEPTSFILE, debug=True
    )  # DEBUG - Not the entire line, only the "debug = True" part.
예제 #2
0
def TestSuiteSimilarityWeights():
    print("Loading libraries...")
    import numpy as np
    from CompoundHandler import CompoundHandler
    ch = CompoundHandler(settings, loadAll=True)
    from JsonParser import JsonParser
    jp = JsonParser()
    data = jp.LoadFile(COMPOUNDSFILE)

    lambdas = []
    mus = []
    results = []

    for _lambda in np.linspace(settings.MinLambda, settings.MaxLambda,
                               settings.LambdaSteps):
        mu = (settings.MaxLambda - _lambda)

        lambdas.append(_lambda)
        mus.append(mu)

        results.append(
            PerformTests(_lambda, mu, settings.Gamma, settings.Delta,
                         settings.Epsilon, ch, data))

    i = 0
    for value in results:
        print("l: %s m: %s result: %s" % (lambdas[i], mus[i], value))
        i += 1
예제 #3
0
def TestExternalCompoundsRandom():
    print("Loading libraries...")
    from numpy import random
    from scipy.stats.stats import pearsonr
    from JsonParser import JsonParser
    jp = JsonParser()
    data = jp.LoadFile(COMPOUNDSFILE)

    while True:
        expected = []
        results = []

        for value in data:
            print("== Comparing %s to %s. ==" % (value["one"], value["two"]))
            result = random.uniform(0.0, 1.0)
            print("Similarity expected - found: %s - %s\n" %
                  (value["sim"], result))

            expected.append(value["sim"])
            results.append(result)

        print("Pearson correlation, 2-tailed p-value:")
        print(pearsonr(expected, results))
        print("==============================")
        print()

        if not TryAgain():
            break
예제 #4
0
def TestExternalCompounds():
    print("Loading libraries...")
    from scipy.stats.stats import pearsonr
    from CompoundHandler import CompoundHandler
    ch = CompoundHandler(settings)
    from JsonParser import JsonParser
    jp = JsonParser()
    data = jp.LoadFile(COMPOUNDSFILE)

    while True:
        if settings.Reload is True:
            settings.LoadSettings()
            ch.ReloadSettings(settings)

        expected = []
        results = []

        for value in data:
            print("== Comparing %s to %s. ==" % (value["one"], value["two"]))
            result = ch.GetSimilarity(value["one"], value["two"])
            print("Similarity expected - found: %s - %s\n" %
                  (value["sim"], result))

            expected.append(value["sim"])
            results.append(result)

        print("Pearson correlation, 2-tailed p-value:")
        print(pearsonr(expected, results))
        print("==============================")
        print()

        if not TryAgain():
            break
예제 #5
0
    def LoadCollections(self, collections):
        from JsonParser import JsonParser
        jp = JsonParser()

        i = 1  # DEBUG
        for collection in collections:
            self.collections[collection] = jp.LoadFile(collections[collection])
            print("Collection %s loaded: %s" %
                  (i, self.collections[collection]))  # DEBUG
            i += 1  # DEBUG
예제 #6
0
def TestSuiteCompoundWeights():
    print("Loading libraries...")
    import numpy as np
    from CompoundHandler import CompoundHandler
    ch = CompoundHandler(settings)
    from JsonParser import JsonParser
    jp = JsonParser()
    data = jp.LoadFile(COMPOUNDSFILE)

    gammas = []
    deltas = []
    epsilons = []
    results = []

    gammanum = 0  # Counts at which gamma value we're at. Increases by one every time we finish a gamma pass, is used to ensure step size is identical for gamma and delta.
    for gamma in np.linspace(settings.MinGamma, settings.MaxGamma,
                             settings.GammaSteps):
        for delta in np.linspace(settings.MinGamma, settings.MaxGamma - gamma,
                                 settings.GammaSteps - gammanum):
            epsilon = (settings.MaxGamma - gamma - delta) / 2

            gammas.append(gamma)
            deltas.append(delta)
            epsilons.append(epsilon)

            results.append(
                PerformTests(settings.SpaCyWeight, settings.WordNetWeight,
                             gamma, delta, epsilon, ch, data))
        gammanum += 1

    i = 0
    pastgamma = gammas[i]
    for value in results:
        print("g: %s d: %s e: %s result: %s" %
              (gammas[i], deltas[i], epsilons[i], value))
        i += 1
        if i < len(gammas) and pastgamma != gammas[
                i]:  # Minor readability improvement.
            pastgamma = gammas[i]
            print()