8000 beginning of GUI redesign; JMX client stub for eventual JMX stream input by automenta · Pull Request #20 · Waikato/moa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

beginning of GUI redesign; JMX client stub for eventual JMX stream input #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.iml
.idea/

8 changes: 4 additions & 4 deletions moa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>nz.ac.waikato.cms.moa</groupId>
<artifactId>moa-pom</artifactId>
<version>2015.05-SNAPSHOT</version>
<version>2012.09-SNAPSHOT</version>
</parent>

<artifactId>moa</artifactId>
Expand Down Expand Up @@ -62,7 +62,7 @@
<dependency>
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
<version>1.2.1</version>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -73,8 +73,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,12 @@ public String toString() {

StringBuffer text = new StringBuffer();

text.append(ARFF_RELATION).append(" ").
text.append(ARFF_RELATION).append(' ').
append(Utils.quote( this.instanceInformation.getRelationName())).append("\n\n");
for (int i = 0; i < numAttributes(); i++) {
text.append(attribute(i).toString()).append("\n");
text.append(attribute(i).toString()).append('\n');
}
text.append("\n").append(ARFF_DATA).append("\n");
text.append('\n').append(ARFF_DATA).append('\n');

text.append(stringWithoutHeader());
return text.toString();
Expand Down
4 changes: 2 additions & 2 deletions moa/src/main/java/moa/DoTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static void main(String[] args) {
// build a single string by concatenating cli options
StringBuilder cliString = new StringBuilder();
for (int i = 0; i < args.length; i++) {
cliString.append(" ").append(args[i]);
cliString.append(' ').append(args[i]);
}
// parse options
Task task = (Task) ClassOption.cliStringToObject(cliString.toString(), Task.class, extraOptions);
Expand Down Expand Up @@ -160,7 +160,7 @@ public static void main(String[] args) {
}
progressLine.append(taskThread.getCurrentActivityString());
while (progressLine.length() < MAX_STATUS_STRING_LENGTH) {
progressLine.append(" ");
progressLine.append(' ');
}
if (progressLine.length() > MAX_STATUS_STRING_LENGTH) {
progressLine.setLength(MAX_STATUS_STRING_LENGTH);
Expand Down
2 changes: 1 addition & 1 deletion moa/src/main/java/moa/MakeObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void main(String[] args) {
// build a single string by concatenating cli options
StringBuilder cliString = new StringBuilder();
for (int i = 1; i < args.length; i++) {
cliString.append(" " + args[i]);
cliString.append(' ').append(args[i]);
}
// parse options
System.err.println("Making object...");
Expand Down
3D11 5 changes: 2 additions & 3 deletions moa/src/main/java/moa/classifiers/active/ActiveClassifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package moa.classifiers.active;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import moa.classifiers.AbstractClassifier;
Expand Down Expand Up @@ -251,9 +252,7 @@ protected Measurement[] getModelMeasurementsImpl() {
measurementList.add(new Measurement("accuracyBaseLearner (percent)", 100 * this.accuracyBaseLearner / this.costLabeling));
Measurement[] modelMeasurements = ((AbstractClassifier) this.classifier).getModelMeasurements();
if (modelMeasurements != null) {
for (Measurement measurement : modelMeasurements) {
measurementList.add(measurement);
}
Collections.addAll(measurementList, modelMeasurements);
}
return measurementList.toArray(new Measurement[measurementList.size()]);
}
Expand Down
2 changes: 1 addition & 1 deletion moa/src/main/java/moa/classifiers/bayes/NaiveBayes.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void getModelDescription(StringBuilder out, int indent) {
out.append(getClassNameString());
out.append(" = ");
out.append(getClassLabelString(i));
out.append(":");
out.append(':');
StringUtils.appendNewlineIndented(out, indent + 1,
"Total observed weight = ");
out.append(this.observedClassDistribution.getValue(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,32 +218,32 @@ public void getModelDescription(StringBuilder result, int indent) {
result.append("--------------------------------------\n");

for (int c = 0; c < m_numClasses; c++) {
result.append(m_headerInfo.classAttribute().value(c)).append("\t").
append(Double.toString(m_probOfClass[c])).append("\n");
result.append(m_headerInfo.classAttribute().value(c)).append('\t').
append(Double.toString(m_probOfClass[c])).append('\n');
}

result.append("\nThe probability of a word given the class\n");
result.append("-----------------------------------------\n\t");

for (int c = 0; c < m_numClasses; c++) {
result.append(m_headerInfo.classAttribute().value(c)).append("\t");
result.append(m_headerInfo.classAttribute().value(c)).append('\t');
}

result.append("\n");
result.append('\n');

for (int w = 0; w < m_headerInfo.numAttributes(); w++) {
if (w == m_headerInfo.classIndex()) {
continue;
}
result.append(m_headerInfo.attribute(w).name()).append("\t");
result.append(m_headerInfo.attribute(w).name()).append('\t');
for (int c = 0; c < m_numClasses; c++) {
double value = m_wordTotalForClass[c].getValue(w);
if (value == 0){
value = this.laplaceCorrectionOption.getValue();
}
result.append(value / m_classTotals[c]).append("\t");
result.append(value / m_classTotals[c]).append('\t');
}
result.append("\n");
result.append('\n');
}
StringUtils.appendNewline(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package moa.classifiers.drift;

import com.yahoo.labs.samoa.instances.Instance;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import moa.classifiers.AbstractClassifier;
Expand Down Expand Up @@ -175,9 +177,7 @@ protected Measurement[] getModelMeasurementsImpl() {
measurementList.add(new Measurement("Warning detected", this.warningDetected));
Measurement[] modelMeasurements = ((AbstractClassifier) this.classifier).getModelMeasurements();
if (modelMeasurements != null) {
for (Measurement measurement : modelMeasurements) {
measurementList.add(measurement);
}
Collections.addAll(measurementList, modelMeasurements);
}
this.changeDetected = 0;
this.warningDetected = 0;
Expand Down
8 changes: 3 additions & 5 deletions moa/src/main/java/moa/classifiers/functions/SGD.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,16 @@ public String toString() {
buff.append(" ");
}

buff.append(Utils.doubleToString(m_weights.getValue(i), 12, 4) + " "
// + m_data.attribute(i).name()
+ "\n");
buff.append(Utils.doubleToString(m_weights.getValue(i), 12, 4)).append(' ').append('\n');

printed++;
//}
}

if (m_bias > 0) {
buff.append(" + " + Utils.doubleToString(m_bias, 12, 4));
buff.append(" + ").append(Utils.doubleToString(m_bias, 12, 4));
} else {
buff.append(" - " + Utils.doubleToString(-m_bias, 12, 4));
buff.append(" - ").append(Utils.doubleToString(-m_bias, 12, 4));
}

return buff.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,18 +373,16 @@ public String toString() {
buff.append(" ");
}

buff.append(Utils.doubleToString(m_weights[0].getValue(i), 12, 4) + " "
// + m_data.attribute(i).name()
+ "\n");
buff.append(Utils.doubleToString(m_weights[0].getValue(i), 12, 4)).append(' ').append('\n');

printed++;
//}
}

if (m_bias[0] > 0) {
buff.append(" + " + Utils.doubleToString(m_bias[0], 12, 4));
buff.append(" + ").append(Utils.doubleToString(m_bias[0], 12, 4));
} else {
buff.append(" - " + Utils.doubleToString(-m_bias[0], 12, 4));
buff.append(" - ").append(Utils.doubleToString(-m_bias[0], 12, 4));
}

return buff.toString();
Expand Down
8 changes: 3 additions & 5 deletions moa/src/main/java/moa/classifiers/functions/SPegasos.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,16 @@ public String toString() {
buff.append(" ");
}

buff.append(Utils.doubleToString(m_weights[i], 12, 4) + " "
//+ m_data.attribute(i).name()
+ "\n");
buff.append(Utils.doubleToString(m_weights[i], 12, 4)).append(' ').append('\n');

printed++;
}
//}

if (m_weights[m_weights.length - 1] > 0) {
buff.append(" + " + Utils.doubleToString(m_weights[m_weights.length - 1], 12, 4));
buff.append(" + ").append(Utils.doubleToString(m_weights[m_weights.length - 1], 12, 4));
} else {
buff.append(" - " + Utils.doubleToString(-m_weights[m_weights.length - 1], 12, 4));
buff.append(" - ").append(Utils.doubleToString(-m_weights[m_weights.length - 1], 12, 4));
}

return buff.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,7 @@ protected int[] refineOwners(KDTreeNode node, Instances centers,
}
}
int[] result = new int[index];
for (int i = 0; i < index; i++)
result[i] = owners[i];
System.arraycopy(owners, 0, result, 0, index);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,30 @@ protected int partition(int attIdx, int[] index, int l, int r) {
* Implements computation of the kth-smallest element according
* to Manber's "Introduction to Algorithms".
*
* @param attIdx The dimension/attribute of the instances in
* which to find the kth-smallest element.
* @param indices The master index array containing indices of
* the instances.
* @param left The begining index of the portion of the master
* index array in which to find the kth-smallest element.
* @param right The end index of the portion of the master index
* array in which to find the kth-smallest element.
* @param k The value of k
* @param attIdx The dimension/attribute of the instances in
* which to find the kth-smallest element.
* @param indices The master index array containing indices of
* the instances.
* @param left The begining index of the portion of the master
* index array in which to find the kth-smallest element.
* @param right The end index of the portion of the master index
* array in which to find the kth-smallest element.
* @param k The value of k
* @return The index of the kth-smallest element
*/
public int select(int attIdx, int[] indices, int left, int right, int k) {

if (left == right) {
629A return left;
} else {
int middle = partition(attIdx, indices, left, right);
if ((middle - left + 1) >= k) {
return select(attIdx, indices, left, middle, k);
while (true) {

if (left == right) {
return left;
} else {
return select(attIdx, indices, middle + 1, right, k - (middle - left + 1));
int middle = partition(attIdx, indices, left, right);
if ((middle - left + 1) >= k) {
right = middle;
} else {
left = middle + 1;
k = k - (middle - left + 1);
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions moa/src/main/java/moa/classifiers/meta/ADACC.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ private Classifier getBestAdaptiveClassifier(){

//take a copy of the ensemble weights (excluding snapshots)
Pair[] newEnsembleWeights = new Pair[ensembleWeights.length-MAXPERMANENT];
for (int i = 0 ; i < newEnsembleWeights.length; i++)
newEnsembleWeights[i]=ensembleWeights[i];
System.arraycopy(ensembleWeights, 0, newEnsembleWeights, 0, newEnsembleWeights.length);

//sort the weight values
Arrays.sort(newEnsembleWeights,Collections.reverseOrder());
Expand Down
8 changes: 2 additions & 6 deletions moa/src/main/java/moa/classifiers/meta/LimAttClassifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ public int[] getNext() {
if (numLeft.equals(total)) {
numLeft = numLeft.subtract(BigInteger.ONE);
int[] b = new int[a.length];
for (int k = 0; k < a.length; k++) {
b[k] = a[k];
}
System.arraycopy(a, 0, b, 0, a.length);
return b;
}
int i = r - 1;
Expand All @@ -190,9 +188,7 @@ public int[] getNext() {
}
numLeft = numLeft.subtract(BigInteger.ONE);
int[] b = new int[a.length];
for (int k = 0; k < a.length; k++) {
b[k] = a[k];
}
System.arraycopy(a, 0, b, 0, a.length);
return b;
}
}
Expand Down
6 changes: 3 additions & 3 deletions moa/src/main/java/moa/classifiers/meta/RandomRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public double[] getVotesForInstance(Instance inst) {
for (int i = 0; i < this.ensemble.length; i++) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(transformInstance(inst,i)));
if (VerbosityOption.getValue()>1)
sb.append(vote.getValue(0) + ", ");
sb.append(vote.getValue(0)).append(", ");
if (this.isRegression == false && vote.sumOfValues() != 0.0){
vote.normalize();
}
Expand All @@ -114,7 +114,7 @@ public double[] getVotesForInstance(Instance inst) {
combinedVote.scaleValues(1.0/this.ensemble.length);
}
if (VerbosityOption.getValue()>1){
sb.append(combinedVote.getValue(0) + ", ").append(inst.classValue());
sb.append(combinedVote.getValue(0)).append(", ").append(inst.classValue());
System.out.println(sb.toString());
}
return combinedVote.getArrayRef();
Expand Down Expand Up @@ -172,7 +172,7 @@ protected Instance transformInstance(Instance inst, int classifierIndex) {
System.out.print(this.listAttributes[attributeIndex][ensembleIndex]);
}
//System.out.println("Number of attributes: "+this.numAttributes+ ","+inst.numAttributes()); //JD
System.out.println("Number of attributes: "+this.numAttributes+ ","+(inst.numAttributes()-1));
System.out.println("Number of attributes: "+this.numAttributes+ ',' +(inst.numAttributes()-1));
attributes.addElement(inst.classAttribute());
this.dataset[ensembleIndex] = new InstancesHeader(new Instances(
getCLICreationString(InstanceStream.class), attributes, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@

import com.github.javacliparser.FlagOption;
import com.github.javacliparser.IntOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

import java.util.*;

import moa.classifiers.AbstractClassifier;
import moa.classifie B98A rs.Classifier;
import moa.core.Measurement;
Expand Down Expand Up @@ -90,9 +89,7 @@ public void trainOnInstanceImpl(Instance instance) {
public void addOldLabel(double newPrediction) {
int numLabels = this.oldLabels.length;
if (numLabels > 0) {
for (int i = 1; i < numLabels; i++) {
this.oldLabels[i - 1] = this.oldLabels[i];
}
System.arraycopy(this.oldLabels, 1, this.oldLabels, 0, numLabels - 1);
this.oldLabels[ numLabels - 1] = newPrediction;
}
}
Expand All @@ -109,7 +106,7 @@ public void initHeader(Instances dataset) {

ArrayList<Attribute> attrs = new ArrayList<Attribute>(numLabels + dataset.numAttributes());
for (int i = 0; i < numLabels; i++) {
attrs.add(new Attribute(target.name() + "_" + i, possibleValues));
attrs.add(new Attribute(target.name() + '_' + i, possibleValues));
}
for (int i = 0; i < dataset.numAttributes(); i++) {
Attribute attr = dataset.attribute(i);
Expand Down Expand Up @@ -165,9 +162,7 @@ protected Measurement[] getModelMeasurementsImpl() {
List<Measurement> measurementList = new LinkedList<Measurement>();
Measurement[] modelMeasurements = ((AbstractClassifier) this.baseLearner).getModelMeasurements();
if (modelMeasurements != null) {
for (Measurement measurement : modelMeasurements) {
measurementList.add(measurement);
}
Collections.addAll(measurementList, modelMeasurements);
}
return measurementList.toArray(new Measurement[measurementList.size()]);
}
Expand Down
Loading
0