Search in sources :

Example 1 with JDKRandomGenerator

use of org.apache.commons.math.random.JDKRandomGenerator in project knime-core by knime.

the class RFSubsetColumnSampleStrategy method getColumnSampleForTreeNode.

/**
 * {@inheritDoc}
 */
@Override
public ColumnSample getColumnSampleForTreeNode(final TreeNodeSignature treeNodeSignature) {
    byte[] signature = treeNodeSignature.getSignaturePath();
    JDKRandomGenerator generator = new JDKRandomGenerator();
    generator.setSeed(m_seed);
    int[] newSeed = new int[signature.length];
    for (int i = 0; i < signature.length; i++) {
        for (int p = 0; p <= signature[i]; p++) {
            newSeed[i] = generator.nextInt();
        }
    }
    generator.setSeed(newSeed);
    int totalColCount = m_data.getColumns().length;
    RandomData rd = new RandomDataImpl(generator);
    int[] includes = rd.nextPermutation(totalColCount, m_subsetSize);
    Arrays.sort(includes);
    return new SubsetColumnSample(m_data, includes);
}
Also used : RandomData(org.apache.commons.math.random.RandomData) RandomDataImpl(org.apache.commons.math.random.RandomDataImpl) JDKRandomGenerator(org.apache.commons.math.random.JDKRandomGenerator)

Example 2 with JDKRandomGenerator

use of org.apache.commons.math.random.JDKRandomGenerator in project knime-core by knime.

the class TestDataGenerator method createRandomData.

public static RandomData createRandomData() {
    JDKRandomGenerator randomGenerator = new JDKRandomGenerator();
    randomGenerator.setSeed(System.currentTimeMillis());
    return new RandomDataImpl(randomGenerator);
}
Also used : RandomDataImpl(org.apache.commons.math.random.RandomDataImpl) JDKRandomGenerator(org.apache.commons.math.random.JDKRandomGenerator)

Example 3 with JDKRandomGenerator

use of org.apache.commons.math.random.JDKRandomGenerator in project knime-core by knime.

the class TreeEnsembleLearnerConfiguration method createRandomData.

/**
 * @param seed
 * @return RandomData created from <b>seed</b>
 */
public static RandomData createRandomData(final long seed) {
    JDKRandomGenerator randomGenerator = new JDKRandomGenerator();
    randomGenerator.setSeed(seed);
    return new RandomDataImpl(randomGenerator);
}
Also used : RandomDataImpl(org.apache.commons.math.random.RandomDataImpl) JDKRandomGenerator(org.apache.commons.math.random.JDKRandomGenerator)

Example 4 with JDKRandomGenerator

use of org.apache.commons.math.random.JDKRandomGenerator in project knime-core by knime.

the class TreeEnsembleLearnerConfiguration method createRandomData.

/**
 * @param seed
 * @return RandomData created from <b>seed</b>
 */
public static RandomData createRandomData(final long seed) {
    JDKRandomGenerator randomGenerator = new JDKRandomGenerator();
    randomGenerator.setSeed(seed);
    return new RandomDataImpl(randomGenerator);
}
Also used : RandomDataImpl(org.apache.commons.math.random.RandomDataImpl) JDKRandomGenerator(org.apache.commons.math.random.JDKRandomGenerator)

Example 5 with JDKRandomGenerator

use of org.apache.commons.math.random.JDKRandomGenerator in project knime-core by knime.

the class RFSubsetColumnSampleStrategy method getColumnSampleForTreeNode.

/**
 * {@inheritDoc}
 */
@Override
public ColumnSample getColumnSampleForTreeNode(final TreeNodeSignature treeNodeSignature) {
    short[] signature = treeNodeSignature.getSignaturePath();
    JDKRandomGenerator generator = new JDKRandomGenerator();
    generator.setSeed(m_seed);
    int[] newSeed = new int[signature.length];
    for (int i = 0; i < signature.length; i++) {
        for (int p = 0; p <= signature[i]; p++) {
            newSeed[i] = generator.nextInt();
        }
    }
    generator.setSeed(newSeed);
    int totalColCount = m_data.getColumns().length;
    RandomData rd = new RandomDataImpl(generator);
    int[] includes = rd.nextPermutation(totalColCount, m_subsetSize);
    Arrays.sort(includes);
    return new SubsetColumnSample(m_data, includes);
}
Also used : RandomData(org.apache.commons.math.random.RandomData) RandomDataImpl(org.apache.commons.math.random.RandomDataImpl) JDKRandomGenerator(org.apache.commons.math.random.JDKRandomGenerator)

Aggregations

JDKRandomGenerator (org.apache.commons.math.random.JDKRandomGenerator)5 RandomDataImpl (org.apache.commons.math.random.RandomDataImpl)5 RandomData (org.apache.commons.math.random.RandomData)2