Search in sources :

Example 1 with TreeNodeNominalCondition

use of org.knime.base.node.mine.treeensemble.model.TreeNodeNominalCondition in project knime-core by knime.

the class TreeNominalColumnData method updateChildMemberships.

/**
 * {@inheritDoc}
 */
@Override
public void updateChildMemberships(final TreeNodeCondition childCondition, final double[] parentMemberships, final double[] childMembershipsToUpdate) {
    TreeNodeNominalCondition nomCondition = (TreeNodeNominalCondition) childCondition;
    String value = nomCondition.getValue();
    int att = -1;
    for (NominalValueRepresentation rep : getMetaData().getValues()) {
        if (rep.getNominalValue().equals(value)) {
            att = rep.getAssignedInteger();
            break;
        }
    }
    if (att == -1) {
        throw new IllegalStateException("Unknown value: " + value);
    }
    final int[] originalIndexInColumnList = m_orginalIndexInColumnList;
    int start = 0;
    for (int a = 0; a < att; a++) {
        start += m_nominalValueCounts[a];
    }
    int end = start + m_nominalValueCounts[att];
    Arrays.fill(childMembershipsToUpdate, 0.0);
    for (int index = start; index < end; index++) {
        final int indexInColumn = originalIndexInColumnList[index];
        final double weight = parentMemberships[indexInColumn];
        childMembershipsToUpdate[indexInColumn] = weight;
    }
}
Also used : TreeNodeNominalCondition(org.knime.base.node.mine.treeensemble.model.TreeNodeNominalCondition)

Example 2 with TreeNodeNominalCondition

use of org.knime.base.node.mine.treeensemble.model.TreeNodeNominalCondition in project knime-core by knime.

the class NominalSplitCandidate method getChildConditions.

/**
 * {@inheritDoc}
 */
@Override
public TreeNodeCondition[] getChildConditions() {
    TreeNominalColumnMetaData columnMeta = getColumnData().getMetaData();
    NominalValueRepresentation[] values = columnMeta.getValues();
    List<TreeNodeCondition> resultList = new ArrayList<TreeNodeCondition>(values.length);
    for (int i = 0; i < values.length; i++) {
        if (m_sumWeightsAttributes[i] >= TreeColumnData.EPSILON) {
            resultList.add(new TreeNodeNominalCondition(columnMeta, i));
        }
    }
    return resultList.toArray(new TreeNodeCondition[resultList.size()]);
}
Also used : TreeNominalColumnMetaData(org.knime.base.node.mine.treeensemble.data.TreeNominalColumnMetaData) TreeNodeNominalCondition(org.knime.base.node.mine.treeensemble.model.TreeNodeNominalCondition) ArrayList(java.util.ArrayList) NominalValueRepresentation(org.knime.base.node.mine.treeensemble.data.NominalValueRepresentation) TreeNodeCondition(org.knime.base.node.mine.treeensemble.model.TreeNodeCondition)

Aggregations

TreeNodeNominalCondition (org.knime.base.node.mine.treeensemble.model.TreeNodeNominalCondition)2 ArrayList (java.util.ArrayList)1 NominalValueRepresentation (org.knime.base.node.mine.treeensemble.data.NominalValueRepresentation)1 TreeNominalColumnMetaData (org.knime.base.node.mine.treeensemble.data.TreeNominalColumnMetaData)1 TreeNodeCondition (org.knime.base.node.mine.treeensemble.model.TreeNodeCondition)1