Example usage for weka.core Range isInRange

List of usage examples for weka.core Range isInRange

Introduction

In this page you can find the example usage for weka.core Range isInRange.

Prototype



publicboolean isInRange(int index) 

Source Link

Document

Gets whether the supplied cardinal number is included in the current range.

Usage

From source file:bme.mace.logicdomain.Evaluation.java

License:Open Source License

/**
 * Prints the header for the predictions output into a supplied StringBuffer
 * //  w w  w.ja va  2 s  .  c o m
 * @param test structure of the test set to print predictions for
 * @param attributesToOutput indices of the attributes to output
 * @param printDistribution prints the complete distribution for nominal
 *          attributes, not just the predicted value
 * @param text the StringBuffer to print to
 */
protected static void printClassificationsHeader(Instances test, Range attributesToOutput,
        boolean printDistribution, StringBuffer text) {
    // print header
    if (test.classAttribute().isNominal()) {
        if (printDistribution) {
            text.append(" inst#     actual  predicted error distribution");
        } else {
            text.append(" inst#     actual  predicted error prediction");
        }
    } else {
        text.append(" inst#     actual  predicted      error");
    }
    if (attributesToOutput != null) {
        attributesToOutput.setUpper(test.numAttributes() - 1);
        text.append(" (");
        boolean first = true;
        for (int i = 0; i < test.numAttributes(); i++) {
            if (i == test.classIndex()) {
                continue;
            }

            if (attributesToOutput.isInRange(i)) {
                if (!first) {
                    text.append(",");
                }
                text.append(test.attribute(i).name());
                first = false;
            }
        }
        text.append(")");
    }
    text.append("\n");
}

From source file:bme.mace.logicdomain.Evaluation.java

License:Open Source License

/**
 * Builds a string listing the attribute values in a specified range of
 * indices, separated by commas and enclosed in brackets.
 * //  w w w. j  a  v a  2s  .c  o m
 * @param instance the instance to print the values from
 * @param attRange the range of the attributes to list
 * @return a string listing values of the attributes in the range
 */
protected static String attributeValuesString(Instance instance, Range attRange) {
    StringBuffer text = new StringBuffer();
    if (attRange != null) {
        boolean firstOutput = true;
        attRange.setUpper(instance.numAttributes() - 1);
        for (int i = 0; i < instance.numAttributes(); i++) {
            if (attRange.isInRange(i) && i != instance.classIndex()) {
                if (firstOutput) {
                    text.append("(");
                } else {
                    text.append(",");
                }
                text.append(instance.toString(i));
                firstOutput = false;
            }
        }
        if (!firstOutput) {
            text.append(")");
        }
    }
    return text.toString();
}

From source file:core.ClusterEvaluationEX.java

License:Open Source License

/**
 * Builds a string listing the attribute values in a specified range of indices,
 * separated by commas and enclosed in brackets.
 *
 * @param instance the instance to print the values from
 * @param attRange the range of the attributes to list
 * @return a string listing values of the attributes in the range
 *//*from  w  ww. java2s.c  o  m*/
private static String attributeValuesString(Instance instance, Range attRange) {
    StringBuffer text = new StringBuffer();
    if (attRange != null) {
        boolean firstOutput = true;
        attRange.setUpper(instance.numAttributes() - 1);
        for (int i = 0; i < instance.numAttributes(); i++)
            if (attRange.isInRange(i)) {
                if (firstOutput)
                    text.append("(");
                else
                    text.append(",");
                text.append(instance.toString(i));
                firstOutput = false;
            }
        if (!firstOutput)
            text.append(")");
    }
    return text.toString();
}

From source file:cotraining.copy.Evaluation_D.java

License:Open Source License

/**
 * Prints the header for the predictions output into a supplied StringBuffer
 *
 * @param test structure of the test set to print predictions for
 * @param attributesToOutput indices of the attributes to output
 * @param printDistribution prints the complete distribution for nominal
 * attributes, not just the predicted value
 * @param text the StringBuffer to print to
 *//*  w  w  w  . j  a v  a 2s.c om*/
protected static void printClassificationsHeader(Instances test, Range attributesToOutput,
        boolean printDistribution, StringBuffer text) {
    // print header
    if (test.classAttribute().isNominal())
        if (printDistribution)
            text.append(" inst#     actual  predicted error distribution");
        else
            text.append(" inst#     actual  predicted error prediction");
    else
        text.append(" inst#     actual  predicted      error");
    if (attributesToOutput != null) {
        attributesToOutput.setUpper(test.numAttributes() - 1);
        text.append(" (");
        boolean first = true;
        for (int i = 0; i < test.numAttributes(); i++) {
            if (i == test.classIndex())
                continue;

            if (attributesToOutput.isInRange(i)) {
                if (!first)
                    text.append(",");
                text.append(test.attribute(i).name());
                first = false;
            }
        }
        text.append(")");
    }
    text.append("\n");
}

From source file:cotraining.copy.Evaluation_D.java

License:Open Source License

/**
 * Builds a string listing the attribute values in a specified range of indices,
 * separated by commas and enclosed in brackets.
 *
 * @param instance the instance to print the values from
 * @param attRange the range of the attributes to list
 * @return a string listing values of the attributes in the range
 *///from w w w  .java 2s .  c  o m
protected static String attributeValuesString(Instance instance, Range attRange) {
    StringBuffer text = new StringBuffer();
    if (attRange != null) {
        boolean firstOutput = true;
        attRange.setUpper(instance.numAttributes() - 1);
        for (int i = 0; i < instance.numAttributes(); i++)
            if (attRange.isInRange(i) && i != instance.classIndex()) {
                if (firstOutput)
                    text.append("(");
                else
                    text.append(",");
                text.append(instance.toString(i));
                firstOutput = false;
            }
        if (!firstOutput)
            text.append(")");
    }
    return text.toString();
}