Search in sources :

Example 1 with ChainsIndex

use of algorithms.isomorphism.chains.ChainLearning.ChainsIndex in project Smiles2Monomers by yoann-dufresne.

the class ChainLearningTests method generateGreedyTest.

/**/
@Test
public void generateGreedyTest() {
    // Computing
    ChainLearning learning = new ChainLearning(this.learningBase);
    learning.setMarkovianSize(3);
    learning.learn(this.families);
    ChainsIndex chains = learning.getFinalChains();
    // Verification
    for (String idx : chains.keySet()) {
        Chain chain = chains.get(idx);
        if (!this.greedyPatterns.containsKey(idx) || !this.greedyPatterns.get(idx).equals(chain.getSerial()))
            fail(idx + " not found");
    /**/
    }
    Assert.assertTrue(chains.size() == 3);
}
Also used : Chain(algorithms.isomorphism.chains.Chain) ChainLearning(algorithms.isomorphism.chains.ChainLearning) ChainsIndex(algorithms.isomorphism.chains.ChainLearning.ChainsIndex) Test(org.junit.Test)

Example 2 with ChainsIndex

use of algorithms.isomorphism.chains.ChainLearning.ChainsIndex in project Smiles2Monomers by yoann-dufresne.

the class ChainLearningTests method generateMarkov6Test.

/**/
@Test
public void generateMarkov6Test() {
    // Computing
    ChainLearning learning = new ChainLearning(this.learningBase);
    learning.setMarkovianSize(6);
    learning.learn(this.families);
    ChainsIndex chains = learning.getFinalChains();
    // Verification
    for (String pattern : chains.keySet()) {
        Chain chain = chains.get(pattern);
        if (!this.markovPatterns.containsKey(pattern) || !this.markovPatterns.get(pattern).equals(chain.getSerial()))
            fail(pattern + " not found");
    /**/
    }
    Assert.assertTrue(chains.size() == 3);
}
Also used : Chain(algorithms.isomorphism.chains.Chain) ChainLearning(algorithms.isomorphism.chains.ChainLearning) ChainsIndex(algorithms.isomorphism.chains.ChainLearning.ChainsIndex) Test(org.junit.Test)

Example 3 with ChainsIndex

use of algorithms.isomorphism.chains.ChainLearning.ChainsIndex in project Smiles2Monomers by yoann-dufresne.

the class ChainLearningTests method generateSize3Test.

@Test
public void generateSize3Test() {
    // Computing
    ChainLearning learning = new ChainLearning(this.learningBase);
    learning.setMarkovianSize(3);
    learning.learn(this.families);
    FrequencesIndex frequences = learning.getFrequence();
    ChainsIndex chains = learning.getAllChains();
    // Verification
    for (String pattern : chains.keySet()) {
        Chain chain = chains.get(pattern);
        if (chain.getSize() != 3)
            continue;
        if (!this.size3Frequencies.containsKey(pattern) || this.size3Frequencies.get(pattern) != frequences.get(pattern) || !this.size3Blocs.get(pattern).equals(chain.getSerial())) {
            System.out.println(pattern);
            System.out.println(chain.getSerial());
            fail(pattern + " : " + frequences.get(pattern) + " -> " + this.size3Blocs.get(pattern));
        }
    }
    Assert.assertTrue(frequences.size() == 19);
}
Also used : Chain(algorithms.isomorphism.chains.Chain) FrequencesIndex(algorithms.isomorphism.chains.ChainLearning.FrequencesIndex) ChainLearning(algorithms.isomorphism.chains.ChainLearning) ChainsIndex(algorithms.isomorphism.chains.ChainLearning.ChainsIndex) Test(org.junit.Test)

Aggregations

Chain (algorithms.isomorphism.chains.Chain)3 ChainLearning (algorithms.isomorphism.chains.ChainLearning)3 ChainsIndex (algorithms.isomorphism.chains.ChainLearning.ChainsIndex)3 Test (org.junit.Test)3 FrequencesIndex (algorithms.isomorphism.chains.ChainLearning.FrequencesIndex)1