Skip to content
Permalink
Browse files

Fixed gradle build and updated gradle to v4.4.1

Fixed distributionForInstance in MCTreeNode
Added RandomUniformClassifier and MajorityClassifier
  • Loading branch information...
mwever committed Jan 19, 2018
1 parent dcc8d33 commit f4a7755d9a31147618ce7803e8c424d3441a1a4a
@@ -1,9 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="conf"/>
<classpathentry kind="src" output="bin/main" path="conf">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="test">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
@@ -1,2 +1,2 @@
#Thu Aug 17 08:34:46 CEST 2017
gradle.version=4.1
#Wed Jan 17 17:05:55 CET 2018
gradle.version=4.4.1
@@ -17,6 +17,7 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
@@ -0,0 +1,4 @@
#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
#Thu Jan 18 11:47:42 CET 2018
org.springsource.ide.eclipse.gradle.linkedresources=
org.springsource.ide.eclipse.gradle.rootprojectloc=../CrcTaskBasedConfigurator
@@ -3,7 +3,7 @@ connection.arguments=
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.java.home=null
connection.jvm.arguments=
connection.project.dir=.
connection.project.dir=../SSLrAId
derived.resources=.gradle,build
eclipse.preferences.version=1
natures=org.eclipse.jdt.core.javanature,org.eclipse.wst.common.project.facet.core.nature,org.eclipse.wst.common.modulecore.ModuleCoreNature,org.eclipse.buildship.core.gradleprojectnature
@@ -1,6 +1,6 @@
#Mon Jul 03 09:24:22 CEST 2017
#Wed Jan 17 17:05:48 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
BIN +161 KB lib/core.jar
Binary file not shown.
@@ -0,0 +1,3 @@
includeFlat 'weka'

rootProject.name = 'JAICore'
@@ -0,0 +1,47 @@
package jaicore.ml;

import weka.classifiers.Classifier;
import weka.core.Capabilities;
import weka.core.Instance;
import weka.core.Instances;

public class MajorityClassifier implements Classifier {

private int majorityClassIndex = 0;

@Override
public void buildClassifier(final Instances data) throws Exception {
int[] classCounter = new int[data.numClasses()];

for (Instance i : data) {
classCounter[(int) i.classValue()]++;
}

int classWithHighestCounter = 0;
for (int i = 1; i < classCounter.length; i++) {
if (classCounter[i] > classCounter[classWithHighestCounter]) {
classWithHighestCounter = i;
}
}

this.majorityClassIndex = classWithHighestCounter;
}

@Override
public double classifyInstance(final Instance instance) throws Exception {
return this.majorityClassIndex;
}

@Override
public double[] distributionForInstance(final Instance instance) throws Exception {
double[] distribution = new double[instance.numClasses()];
distribution[this.majorityClassIndex] = 1;
return distribution;
}

@Override
public Capabilities getCapabilities() {
return null;
}

}
@@ -0,0 +1,34 @@
package jaicore.ml;

import weka.classifiers.Classifier;
import weka.core.Capabilities;
import weka.core.Instance;
import weka.core.Instances;

public class RandomUniformClassifier implements Classifier {

@Override
public void buildClassifier(final Instances data) throws Exception {

}

@Override
public double classifyInstance(final Instance instance) throws Exception {
return 0;
}

@Override
public double[] distributionForInstance(final Instance instance) throws Exception {
double[] distribution = new double[instance.numClasses()];
for (int i = 0; i < distribution.length; i++) {
distribution[i] = (double) 1 / instance.numClasses();
}
return distribution;
}

@Override
public Capabilities getCapabilities() {
return null;
}

}

0 comments on commit f4a7755

Please sign in to comment.
You can’t perform that action at this time.