public static String quote(String string) { boolean quote = false; // backquote the following characters if ((string.indexOf('\n') != -1) || (string.indexOf('\r') != -1) || (string.indexOf('\'') != -1) || (string.indexOf('"') != -1) || (string.indexOf('\\') != -1) || (string.indexOf('\t') != -1) || (string.indexOf('%') != -1) || (string.indexOf('\u001E') != -1)) { string = backQuoteChars(string); quote = true; } // Enclose the string in 's if the string contains a recently added // backquote or contains one of the following characters. if ((quote == true) || (string.indexOf('{') != -1) || (string.indexOf('}') != -1) || (string.indexOf(',') != -1) || (string.equals("?")) || (string.indexOf(' ') != -1) || (string.equals(""))) { string = ("'".concat(string)).concat("'"); } return string; }
@Override public String toString() { StringBuffer text = new StringBuffer(); text.append(ARFF_ATTRIBUTE).append(" ").append(Utils.quote(this.name)).append(" "); text.append(ARFF_ATTRIBUTE_NUMERIC); return text.toString(); } }
@Override public void addResult(Instance inst, double[] classVotes) { double weight = inst.weight(); int trueClass = (int) inst.classValue(); if (weight > 0.0) { if (this.weightObserved == 0) { reset(inst.numClasses()); } this.weightObserved += weight; int predictedClass = Utils.maxIndex(classVotes); if (predictedClass == trueClass) { this.weightCorrect += weight; } if(rowKappa.length > 0){ this.rowKappa[predictedClass] += weight; } if (columnKappa.length > 0) { this.columnKappa[trueClass] += weight; } } if (this.lastSeenClass == trueClass) { this.weightCorrectNoChangeClassifier += weight; } this.lastSeenClass = trueClass; }
@Override public void addResult(Instance inst, double[] classVotes) { double weight = inst.weight(); int trueClass = (int) inst.classValue(); if (weight > 0.0) { if (this.weightObserved == 0) { reset(inst.numClasses()); } this.weightObserved += weight; int predictedClass = Utils.maxIndex(classVotes); if (predictedClass == trueClass) { this.weightCorrect += weight; } if(rowKappa.length > 0){ this.rowKappa[predictedClass] += weight; } if (columnKappa.length > 0) { this.columnKappa[trueClass] += weight; } } if (this.lastSeenClass == trueClass) { this.weightCorrectNoChangeClassifier += weight; } this.lastSeenClass = trueClass; }
@Override public void addResult(Instance inst, double[] classVotes) { double weight = inst.weight(); int trueClass = (int) inst.classValue(); if (weight > 0.0) { if (TotalweightObserved == 0) { reset(inst.numClasses()); } this.TotalweightObserved += weight; this.weightObserved.add(weight); int predictedClass = Utils.maxIndex(classVotes); if (predictedClass == trueClass) { this.weightCorrect.add(weight); } else { this.weightCorrect.add(0); } //Add Kappa statistic information for (int i = 0; i < this.numClasses; i++) { this.rowKappa[i].add(i == predictedClass ? weight : 0); this.columnKappa[i].add(i == trueClass ? weight : 0); } if (this.lastSeenClass == trueClass) { this.weightCorrectNoChangeClassifier.add(weight); } else { this.weightCorrectNoChangeClassifier.add(0); } this.classAccuracy[trueClass].add(predictedClass == trueClass ? weight : 0.0); this.lastSeenClass = trueClass; } }
public String toStringArff() { StringBuilder text = new StringBuilder(); text.append(ARFF_RELATION).append(" ") .append(Utils.quote(getRelationName())).append("\n\n"); for (int i = 0; i < numAttributes(); i++) { text.append(attribute(i).toString()).append("\n"); } text.append("\n").append(ARFF_DATA).append("\n"); text.append(toString()); return text.toString(); } }
@Override public void addResult(Instance inst, double[] classVotes) { double weight = inst.weight(); int trueClass = (int) inst.classValue(); if (weight > 0.0) { if (TotalweightObserved == 0) { reset(inst.numClasses()); } this.TotalweightObserved += weight; this.weightObserved.add(weight); int predictedClass = Utils.maxIndex(classVotes); if (predictedClass == trueClass) { this.weightCorrect.add(weight); } else { this.weightCorrect.add(0); } //Add Kappa statistic information for (int i = 0; i < this.numClasses; i++) { this.rowKappa[i].add(i == predictedClass ? weight : 0); this.columnKappa[i].add(i == trueClass ? weight : 0); } if (this.lastSeenClass == trueClass) { this.weightCorrectNoChangeClassifier.add(weight); } else { this.weightCorrectNoChangeClassifier.add(0); } this.classAccuracy[trueClass].add(predictedClass == trueClass ? weight : 0.0); this.lastSeenClass = trueClass; } }