Example usage for weka.core Attribute weight

List of usage examples for weka.core Attribute weight

Introduction

In this page you can find the example usage for weka.core Attribute weight.

Prototype

public finaldouble weight() 

Source Link

Document

Returns the attribute's weight.

Usage

From source file:cn.edu.xjtu.dbmine.source.NaiveBayes.java

License:Open Source License

/**
 * Returns a description of the classifier in the old format.
 *
 * @return a description of the classifier as a string.
 *//*from  ww  w.jav a2 s.c  o m*/
protected String toStringOriginal() {

    StringBuffer text = new StringBuffer();

    text.append("Naive Bayes Classifier");
    if (m_Instances == null) {
        text.append(": No model built yet.");
    } else {
        try {
            for (int i = 0; i < m_Distributions[0].length; i++) {
                text.append("\n\nClass " + m_Instances.classAttribute().value(i) + ": Prior probability = "
                        + Utils.doubleToString(m_ClassDistribution.getProbability(i), 4, 2) + "\n\n");
                Enumeration enumAtts = m_Instances.enumerateAttributes();
                int attIndex = 0;
                while (enumAtts.hasMoreElements()) {
                    Attribute attribute = (Attribute) enumAtts.nextElement();
                    if (attribute.weight() > 0) {
                        text.append(attribute.name() + ":  " + m_Distributions[attIndex][i]);
                    }
                    attIndex++;
                }
            }
        } catch (Exception ex) {
            text.append(ex.getMessage());
        }
    }

    return text.toString();
}

From source file:de.uni_potsdam.hpi.bpt.promnicat.processEvolution.clustering.ProcessEvolutionClusterer.java

License:Open Source License

/**
 * add the attributes to the header of the resultString
 * @param clusterResultStringBuilder /*from   ww w  .j ava  2s.co m*/
 * @param numericAttributes
 * @param linkType
 * @param numberOfClusters
 */
private static void addAttributesToResult(StringBuilder clusterResultStringBuilder,
        FastVector numericAttributes, String linkType, int numberOfClusters) {
    for (Object attribute : numericAttributes.toArray())
        if (attribute != null && attribute instanceof Attribute) {
            Attribute realAttribute = (Attribute) attribute;
            clusterResultStringBuilder.append(realAttribute.name() + "(" + realAttribute.weight() + "),");
        }

    clusterResultStringBuilder.append("]" + "," + linkType).append("," + numberOfClusters).append(LINEBREAK);
}

From source file:main.NaiveBayes.java

License:Open Source License

/**
 * Returns a description of the classifier in the old format.
 * /*  w  ww  . j a v a2s  .c  o m*/
 * @return a description of the classifier as a string.
 */
protected String toStringOriginal() {

    StringBuffer text = new StringBuffer();

    text.append("Naive Bayes Classifier");
    if (m_Instances == null) {
        text.append(": No model built yet.");
    } else {
        try {
            for (int i = 0; i < m_Distributions[0].length; i++) {
                text.append("\n\nClass " + m_Instances.classAttribute().value(i) + ": Prior probability = "
                        + Utils.doubleToString(m_ClassDistribution.getProbability(i), 4, 2) + "\n\n");
                Enumeration<Attribute> enumAtts = m_Instances.enumerateAttributes();
                int attIndex = 0;
                while (enumAtts.hasMoreElements()) {
                    Attribute attribute = enumAtts.nextElement();
                    if (attribute.weight() > 0) {
                        text.append(attribute.name() + ":  " + m_Distributions[attIndex][i]);
                    }
                    attIndex++;
                }
            }
        } catch (Exception ex) {
            text.append(ex.getMessage());
        }
    }

    return text.toString();
}