Search in sources :

Example 6 with RandomDataImpl

use of org.apache.commons.math.random.RandomDataImpl 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

RandomDataImpl (org.apache.commons.math.random.RandomDataImpl)6 JDKRandomGenerator (org.apache.commons.math.random.JDKRandomGenerator)5 RandomData (org.apache.commons.math.random.RandomData)2 BigInteger (java.math.BigInteger)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 FullBinarySplitEnumeration (org.knime.base.node.mine.treeensemble2.data.TreeNominalColumnData.FullBinarySplitEnumeration)1 RandomBinarySplitEnumeration (org.knime.base.node.mine.treeensemble2.data.TreeNominalColumnData.RandomBinarySplitEnumeration)1