Example usage for weka.core Attribute getMetadata

List of usage examples for weka.core Attribute getMetadata

Introduction

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

Prototype

public finalProtectedProperties getMetadata() 

Source Link

Document

Returns the properties supplied for this attribute.

Usage

From source file:cn.ict.zyq.bestConf.bestConf.RBSoDDSOptimization.java

License:Open Source License

private void saveProps(ArrayList<Attribute> props, int round, int subround) {
    try {// www. ja  v  a 2  s.  com
        HashMap propMap = new HashMap();
        for (Attribute att : props) {
            propMap.put(att.name(), att.getMetadata().getProperty(propKey));
        }
        writeToYaml(resumeFolder + "/props_" + round + "_" + subround, propMap);

        File file = new File(resumeFolder + "/props_" + round + "_" + subround + "_OK");
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:moa.classifiers.novelClass.AbstractNovelClassClassifier.java

License:Apache License

final public static Instances augmentInstances(Instances datum) {
    ArrayList<Attribute> attInfo = new ArrayList<>(datum.numAttributes());
    for (int aIdx = 0; aIdx < datum.numAttributes(); aIdx++) {
        Attribute a = datum.attribute(aIdx).copy(datum.attribute(aIdx).name());
        if ((aIdx == datum.classIndex()) && (a.indexOfValue(NOVEL_LABEL_STR) < 0)) { // only if we don't already have these
            List<String> values = new ArrayList<>(a.numValues() + 2);
            for (int i = 0; i < a.numValues(); ++i) {
                values.add(a.value(i));//from   ww  w. ja va 2 s.c  o  m
            }
            values.add(OUTLIER_LABEL_STR);
            values.add(NOVEL_LABEL_STR);
            a = new Attribute(a.name(), values, a.getMetadata());
        }
        attInfo.add(a);
    }
    String relationshipName = NOVEL_CLASS_INSTANCE_RELATIONSHIP_TYPE + "-" + datum.relationName();
    Instances ret = new Instances(relationshipName, attInfo, 1);
    ret.setClassIndex(datum.classIndex());

    return ret;
}