_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q23100 | AbstractAMRules.debug | train | protected void debug(String string, int level) {
if (VerbosityOption.getValue()>=level){
System.out.println(string);
}
} | java | {
"resource": ""
} |
q23101 | AbstractAMRules.getVotes | train | public Vote getVotes(Instance instance) {
ErrorWeightedVote errorWeightedVote=newErrorWeightedVote();
//DoubleVector combinedVote = new DoubleVector();
debug("Test",3);
int numberOfRulesCovering = 0;
VerboseToConsole(instance); // Verbose to console Dataset name.
for (Rule rule : ruleSet) {
if (rule... | java | {
"resource": ""
} |
q23102 | SizeOf.isPresent | train | protected static synchronized boolean isPresent() {
if (m_Present == null) {
try {
SizeOfAgent.fullSizeOf(new Integer(1));
m_Present = true;
} catch (Throwable t) {
m_Present = false;
}
}
return m_Present;
} | java | {
"resource": ""
} |
q23103 | Plot.createScript | train | private String createScript(File resultFile) {
String newLine = System.getProperty("line.separator");
int sourceFileIdx = 0;
// terminal options;
String script = "set term "
+ terminalOptions(Terminal.valueOf(outputTypeOption
.getChosenLabel())) + newLine;
script += "set output '" + resultFile.getAbsolutePat... | java | {
"resource": ""
} |
q23104 | CMM_GTAnalysis.calculateGTPointQualities | train | private void calculateGTPointQualities(){
for (int p = 0; p < numPoints; p++) {
CMMPoint cmdp = cmmpoints.get(p);
if(!cmdp.isNoise()){
cmdp.connectivity = getConnectionValue(cmdp, cmdp.workclass());
cmdp.p.setMeasureValue("Connectivity", cmdp.connectivity)... | java | {
"resource": ""
} |
q23105 | CMM_GTAnalysis.calculateGTClusterConnections | train | private void calculateGTClusterConnections(){
for (int c0 = 0; c0 < gt0Clusters.size(); c0++) {
for (int c1 = 0; c1 < gt0Clusters.size(); c1++) {
gt0Clusters.get(c0).calculateClusterConnection(c1, true);
}
}
boolean changedConnection = true;
w... | java | {
"resource": ""
} |
q23106 | CMM_GTAnalysis.getNoiseSeparability | train | public double getNoiseSeparability(){
if(noise.isEmpty())
return 1;
double connectivity = 0;
for(int p : noise){
CMMPoint npoint = cmmpoints.get(p);
double maxConnection = 0;
//TODO: some kind of pruning possible. what about weighting?
... | java | {
"resource": ""
} |
q23107 | CMM_GTAnalysis.getModelQuality | train | public double getModelQuality(){
for(int p = 0; p < numPoints; p++){
CMMPoint cmdp = cmmpoints.get(p);
for(int hc = 0; hc < numGTClusters;hc++){
if(gtClustering.get(hc).getGroundTruth() != cmdp.trueClass){
if(gtClustering.get(hc).getInclusionProbabilit... | java | {
"resource": ""
} |
q23108 | CMM_GTAnalysis.distance | train | private double distance(Instance inst1, double[] inst2){
double distance = 0.0;
for (int i = 0; i < numDims; i++) {
double d = inst1.value(i) - inst2[i];
distance += d * d;
}
return Math.sqrt(distance);
} | java | {
"resource": ""
} |
q23109 | CMM_GTAnalysis.getParameterString | train | public String getParameterString(){
String para = "";
para+="k="+knnNeighbourhood+";";
if(useExpConnectivity){
para+="lambdaConnX="+lambdaConnX+";";
para+="lambdaConn="+lamdaConn+";";
para+="lambdaConnRef="+lambdaConnRefXValue+";";
}
para+="m="+clusterC... | java | {
"resource": ""
} |
q23110 | HSVColorGenerator.generateColors | train | @Override
public Color[] generateColors(int numColors) {
Color[] colors = new Color[numColors];
// fix the seed to always get the same colors for the same numColors parameter and ranges for hue, saturation and brightness
Random rand = new Random(0);
for(int i = 0; i < numColors; ++i)
{
float hueRatio = i/... | java | {
"resource": ""
} |
q23111 | HSTreeNode.updateMass | train | public void updateMass(Instance inst, boolean referenceWindow)
{
if(referenceWindow)
r++;
else
l++;
if(internalNode)
{
if(inst.value(this.splitAttribute) > this.splitValue)
right.updateMass(inst, referenceWindow);
else
left.updateMass(inst, referenceWindow);
}
} | java | {
"resource": ""
} |
q23112 | HSTreeNode.score | train | public double score(Instance inst, int sizeLimit)
{
double anomalyScore = 0.0;
if(this.internalNode && this.r > sizeLimit)
{
if(inst.value(this.splitAttribute) > this.splitValue)
anomalyScore = right.score(inst, sizeLimit);
else
anomalyScore = left.score(inst, sizeLimit);
}
else
{
anoma... | java | {
"resource": ""
} |
q23113 | HSTreeNode.printNode | train | protected void printNode()
{
System.out.println(this.depth+", "+this.splitAttribute+", "+this.splitValue+", "+this.r);
if(this.internalNode)
{
this.right.printNode();
this.left.printNode();
}
} | java | {
"resource": ""
} |
q23114 | Dstream.initialClustering | train | private void initialClustering() {
//System.out.println("INITIAL CLUSTERING CALLED");
//printDStreamState();
// 1. Update the density of all grids in grid_list
updateGridListDensity();
//printGridList();
// 2. Assign each dense grid to a distinct cluster
// and
// 3. Label all other grids as NO_CL... | java | {
"resource": ""
} |
q23115 | Dstream.adjustForSparseGrid | train | private HashMap<DensityGrid, CharacteristicVector> adjustForSparseGrid(DensityGrid dg, CharacteristicVector cv, int dgClass)
{
HashMap<DensityGrid, CharacteristicVector> glNew = new HashMap<DensityGrid, CharacteristicVector>();
//System.out.print("Density grid "+dg.toString()+" is adjusted as a sparse grid at time... | java | {
"resource": ""
} |
q23116 | Dstream.adjustForTransitionalGrid | train | private HashMap<DensityGrid, CharacteristicVector> adjustForTransitionalGrid(DensityGrid dg, CharacteristicVector cv, int dgClass)
{
//System.out.print("Density grid "+dg.toString()+" is adjusted as a transitional grid at time "+this.getCurrTime()+". ");
// Among all neighbours of dg, find the grid h whose clus... | java | {
"resource": ""
} |
q23117 | Dstream.cleanClusters | train | private void cleanClusters()
{
//System.out.println("Clean Clusters");
Iterator<GridCluster> clusIter = this.cluster_list.iterator();
ArrayList<GridCluster> toRem = new ArrayList<GridCluster>();
// Check to see if there are any empty clusters
while(clusIter.hasNext())
{
GridCluster c = clusIter.next();... | java | {
"resource": ""
} |
q23118 | Dstream.removeSporadic | train | private void removeSporadic() {
//System.out.println("REMOVE SPORADIC CALLED");
// 1. For each grid g in grid_list
// a. If g is sporadic
// i. If currTime - tg > gap, delete g from grid_list
// ii. Else if (S1 && S2), mark as sporadic
// iii. Else, mark as normal
// b. Else
// ... | java | {
"resource": ""
} |
q23119 | Dstream.checkIfSporadic | train | private boolean checkIfSporadic(CharacteristicVector cv)
{
// Check S1
if(cv.getCurrGridDensity(this.getCurrTime(), this.getDecayFactor()) < densityThresholdFunction(cv.getDensityTimeStamp(), this.cl, this.getDecayFactor(), this.N))
{
// Check S2
if(cv.getRemoveTime() == -1 || this.getCurrTime() >= ((1 + t... | java | {
"resource": ""
} |
q23120 | Dstream.densityThresholdFunction | train | private double densityThresholdFunction(int tg, double cl, double decayFactor, int N)
{
return (cl * (1.0 - Math.pow(decayFactor, (this.getCurrTime()-tg+1.0))))/(N * (1.0 - decayFactor));
} | java | {
"resource": ""
} |
q23121 | Dstream.mergeClusters | train | private void mergeClusters (int smallClus, int bigClus)
{
//System.out.println("Merge clusters "+smallClus+" and "+bigClus+".");
// Iterate through the density grids in grid_list to find those which are in highClass
for (Map.Entry<DensityGrid, CharacteristicVector> grid : grid_list.entrySet())
{
DensityGr... | java | {
"resource": ""
} |
q23122 | Dstream.updateGridListDensity | train | private void updateGridListDensity()
{
for (Map.Entry<DensityGrid, CharacteristicVector> grid : grid_list.entrySet())
{
DensityGrid dg = grid.getKey();
CharacteristicVector cvOfG = grid.getValue();
dg.setVisited(false);
cvOfG.updateGridDensity(this.getCurrTime(), this.getDecayFactor(), this.getDL(), t... | java | {
"resource": ""
} |
q23123 | Dstream.printGridList | train | public void printGridList()
{
System.out.println("Grid List. Size "+this.grid_list.size()+".");
for (Map.Entry<DensityGrid, CharacteristicVector> grid : grid_list.entrySet())
{
DensityGrid dg = grid.getKey();
CharacteristicVector cv = grid.getValue();
if (cv.getAttribute() != SPARSE)
{
double... | java | {
"resource": ""
} |
q23124 | Dstream.printGridClusters | train | public void printGridClusters()
{
System.out.println("List of Clusters. Total "+this.cluster_list.size()+".");
for(GridCluster gc : this.cluster_list)
{
System.out.println(gc.getClusterLabel()+": "+gc.getWeight()+" {"+gc.toString()+"}");
}
} | java | {
"resource": ""
} |
q23125 | DataSet.addObject | train | public void addObject(DataSet dataSet) throws Exception {
DataObject[] dataObjects = dataSet.getDataObjectArray();
for (int i = 0; i < dataObjects.length; i++) {
this.addObject(dataObjects[i]);
}
} | java | {
"resource": ""
} |
q23126 | DataSet.getNrOfClasses | train | public int getNrOfClasses() {
HashMap<Integer, Integer> classes = new HashMap<Integer, Integer>();
for (DataObject currentObject : dataList) {
if (!classes.containsKey(currentObject.getClassLabel()))
classes.put(currentObject.getClassLabel(), 1);
}
return classes.size();
} | java | {
"resource": ""
} |
q23127 | DataSet.getDataSetsPerClass | train | public DataSet[] getDataSetsPerClass() throws Exception {
DataSet[] dataSetsPerClass = new DataSet[this.getNrOfClasses()];
// create a new data set for each class
for (int i = 0; i < dataSetsPerClass.length; i++) {
dataSetsPerClass[i] = new DataSet(this.nrOfDimensions);
}
// fill the data... | java | {
"resource": ""
} |
q23128 | DataSet.getVariances | train | public double[] getVariances() {
double N = this.size();
double[] LS = new double[this.getNrOfDimensions()];
double[] SS = new double[this.getNrOfDimensions()];
double[] tmpFeatures;
double[] variances = new double[this.getNrOfDimensions()];
for (DataObject dataObject : dataList) {
tmpFeatures = d... | java | {
"resource": ""
} |
q23129 | SparseInstanceData.toDoubleArray | train | @Override
public double[] toDoubleArray() {
double[] array = new double[numAttributes()];
for (int i = 0; i < numValues(); i++) {
array[index(i)] = valueSparse(i);
}
return array;
} | java | {
"resource": ""
} |
q23130 | AnyOutCore.calcC1 | train | private double calcC1(int objectId) {
int nrOfPreviousResults = previousOScoreResultList.get(objectId).size();
if (nrOfPreviousResults == 0) {
return 0.0;
}
int count=1;
double difSum_k = Math.abs(lastOScoreResult.get(objectId)-previousOScoreResultList.get(objectId).get(nrOfPreviousResults-1));
... | java | {
"resource": ""
} |
q23131 | Summary.invertedSumariesPerMeasure | train | public void invertedSumariesPerMeasure( String path) {
int cont = 0;
int algorithmSize = this.streams.get(0).algorithm.size();
int streamSize = this.streams.size();
int measureSize = this.streams.get(0).algorithm.get(0).measures.size();
while (cont != measureSize) {
... | java | {
"resource": ""
} |
q23132 | Summary.generateCSV | train | public void generateCSV() {
int cont = 0;
int algorithmSize = this.streams.get(0).algorithm.size();
int streamSize = this.streams.size();
int measureSize = this.streams.get(0).algorithm.get(0).measures.size();
while (cont != measureSize) {
String out... | java | {
"resource": ""
} |
q23133 | DensityGrid.getNeighbours | train | public ArrayList<DensityGrid> getNeighbours()
{
ArrayList<DensityGrid> neighbours = new ArrayList<DensityGrid>();
DensityGrid h;
int[] hCoord = this.getCoordinates();
for (int i = 0 ; i < this.dimensions ; i++)
{
hCoord[i] = hCoord[i]-1;
h = new DensityGrid(hCoord);
neighbours.add(h);
hCoo... | java | {
"resource": ""
} |
q23134 | DensityGrid.getInclusionProbability | train | @Override
public double getInclusionProbability(Instance instance) {
for (int i = 0 ; i < this.dimensions ; i++)
{
if ((int) instance.value(i) != this.coordinates[i])
return 0.0;
}
return 1.0;
} | java | {
"resource": ""
} |
q23135 | Stream.readBuffer | train | public void readBuffer(List<String> algPath, List<String> algNames, List<Measure> measures) {
BufferedReader buffer = null;
for (int i = 0; i < algPath.size(); i++) {
try {
buffer = new BufferedReader(new FileReader(algPath.get(i)));
} catch (FileNotFoundException... | java | {
"resource": ""
} |
q23136 | RandomRBFGeneratorEvents.fireClusterChange | train | protected void fireClusterChange(long timestamp, String type, String message) {
// if we have no listeners, do nothing...
if (listeners != null && !listeners.isEmpty()) {
// create the event object to send
ClusterEvent event =
new ClusterEvent(this, timestamp, type , message);
// make... | java | {
"resource": ""
} |
q23137 | ClassOptionEditComponent.notifyChangeListeners | train | protected void notifyChangeListeners() {
ChangeEvent e = new ChangeEvent(this);
for (ChangeListener l : changeListeners) {
l.stateChanged(e);
}
} | java | {
"resource": ""
} |
q23138 | GraphScatter.setGraph | train | public void setGraph(MeasureCollection[] measures, MeasureCollection[] stds,
double[] variedParamValues, Color[] colors) {
this.variedParamValues = variedParamValues;
super.setGraph(measures, stds, colors);
} | java | {
"resource": ""
} |
q23139 | GraphScatter.scatter | train | private void scatter(Graphics g, int i) {
int height = getHeight();
int width = getWidth();
int x = (int)(((this.variedParamValues[i] - this.lower_x_value) / (this.upper_x_value - this.lower_x_value)) * width);
double value = this.measures[i].getLastValue(this.measureSelected);
if(Doub... | java | {
"resource": ""
} |
q23140 | AbstractMOAObject.copy | train | public static MOAObject copy(MOAObject obj) {
try {
return (MOAObject) SerializeUtils.copyObject(obj);
} catch (Exception e) {
throw new RuntimeException("Object copy failed.", e);
}
} | java | {
"resource": ""
} |
q23141 | GUIDefaults.get | train | public static String get(String property, String defaultValue) {
return PROPERTIES.getProperty(property, defaultValue);
} | java | {
"resource": ""
} |
q23142 | GUIDefaults.getTabs | train | public static String[] getTabs() {
String[] result;
String tabs;
// read and split on comma
tabs = get("Tabs", "moa.gui.ClassificationTabPanel,moa.gui.RegressionTabPanel,moa.gui.MultiLabelTabPanel,moa.gui.MultiTargetTabPanel,moa.gui.clustertab.ClusteringTabPanel,moa.gui.outliertab.Outli... | java | {
"resource": ""
} |
q23143 | GUIDefaults.getFrameWidth | train | public static int getFrameWidth() {
int result;
String str;
str = get("FrameWidth", "1200");
try {
result = Integer.parseInt(str);
}
catch (Exception e) {
result = 1200;
}
return result;
} | java | {
"resource": ""
} |
q23144 | GUIDefaults.main | train | public static void main(String[] args) {
Enumeration names;
String name;
Vector sorted;
System.out.println("\nMOA defaults:");
names = PROPERTIES.propertyNames();
// sort names
sorted = new Vector();
while (names.hasMoreElements()) {
sorted.a... | java | {
"resource": ""
} |
q23145 | ClustreamKernel.inverseError | train | public static double inverseError(double x) {
double z = Math.sqrt(Math.PI) * x;
double res = (z) / 2;
double z2 = z * z;
double zProd = z * z2; // z^3
res += (1.0 / 24) * zProd;
zProd *= z2; // z^5
res += (7.0 / 960) * zProd;
zProd *= z2; // z^7
... | java | {
"resource": ""
} |
q23146 | BICO.bicoUpdate | train | protected void bicoUpdate(double[] x) {
assert (!this.bufferPhase && this.numDimensions == x.length);
// Starts with the global root node as the current root node
ClusteringTreeNode r = this.root;
int i = 1;
while (true) {
ClusteringTreeNode y = r.nearestChild(x);
// Checks if the point can not be added... | java | {
"resource": ""
} |
q23147 | BICO.rebuild | train | protected void rebuild() {
// Checks if the number of nodes in the tree exceeds the maximum number
while (this.rootCount > this.maxNumClusterFeatures) {
// Doubles the global threshold
this.T *= 2.0;
this.root.setThreshold(calcRSquared(1));
// Adds all nodes to the ClusteringFeature tree again
Queue<... | java | {
"resource": ""
} |
q23148 | BICO.bicoCFUpdate | train | protected void bicoCFUpdate(ClusteringTreeNode x) {
// Starts with the global root node as the current root node
ClusteringTreeNode r = this.root;
int i = 1;
while (true) {
ClusteringTreeNode y = r.nearestChild(x.getCenter());
// Checks if the node can not be merged to the current level
if (r.hasNoChil... | java | {
"resource": ""
} |
q23149 | NearestNeighbourSearch.combSort11 | train | public static void combSort11(double arrayToSort[], int linkedArray[]) {
int switches, j, top, gap;
double hold1; int hold2;
gap = arrayToSort.length;
do {
gap=(int)(gap/1.3);
switch(gap) {
case 0:
gap = 1;
break;
case 9:
case 10:
gap=11;... | java | {
"resource": ""
} |
q23150 | NearestNeighbourSearch.quickSort | train | public static void quickSort(double[] arrayToSort, double[] linkedArray, int left, int right) {
if (left < right) {
int middle = partition(arrayToSort, linkedArray, left, right);
quickSort(arrayToSort, linkedArray, left, middle);
quickSort(arrayToSort, linkedArray, middle + 1, right);
}
} | java | {
"resource": ""
} |
q23151 | KDTree.kNearestNeighbours | train | public Instances kNearestNeighbours(Instance target, int k) throws Exception {
checkMissing(target);
MyHeap heap = new MyHeap(k);
findNearestNeighbours(target, m_Root, k, heap, 0.0);
Instances neighbours = new Instances(m_Instances, (heap.size() + heap
.noOfKthNearest()));
m_DistanceLi... | java | {
"resource": ""
} |
q23152 | KDTree.update | train | public void update(Instance instance) throws Exception { // better to change
// to addInstance
if (m_Instances == null)
throw new Exception("No instances supplied yet. Have to call "
+ "setInstances(instances) with a set of Instances " + "f... | java | {
"resource": ""
} |
q23153 | KDTree.checkMissing | train | protected void checkMissing(Instances instances) throws Exception {
for (int i = 0; i < instances.numInstances(); i++) {
Instance ins = instances.instance(i);
for (int j = 0; j < ins.numValues(); j++) {
if (ins.index(j) != ins.classIndex())
if (ins.isMissingSparse(j)) {
thr... | java | {
"resource": ""
} |
q23154 | KDTree.checkMissing | train | protected void checkMissing(Instance ins) throws Exception {
for (int j = 0; j < ins.numValues(); j++) {
if (ins.index(j) != ins.classIndex())
if (ins.isMissingSparse(j)) {
throw new Exception("ERROR: KDTree can not deal with missing "
+ "values. Please run ReplaceMissingValues... | java | {
"resource": ""
} |
q23155 | KDTree.enumerateMeasures | train | public Enumeration enumerateMeasures() {
Vector<String> newVector = new Vector<String>();
newVector.addElement("measureTreeSize");
newVector.addElement("measureNumLeaves");
newVector.addElement("measureMaxDepth");
return newVector.elements();
} | java | {
"resource": ""
} |
q23156 | KDTree.getMeasure | train | public double getMeasure(String additionalMeasureName) {
if (additionalMeasureName.compareToIgnoreCase("measureMaxDepth") == 0) {
return measureMaxDepth();
} else if (additionalMeasureName.compareToIgnoreCase("measureTreeSize") == 0) {
return measureTreeSize();
} else if (additionalMeasureName.c... | java | {
"resource": ""
} |
q23157 | KDTree.centerInstances | train | public void centerInstances(Instances centers, int[] assignments, double pc)
throws Exception {
int[] centList = new int[centers.numInstances()];
for (int i = 0; i < centers.numInstances(); i++)
centList[i] = i;
determineAssignments(m_Root, centers, centList, assignments, pc);
} | java | {
"resource": ""
} |
q23158 | KDTree.determineAssignments | train | protected void determineAssignments(KDTreeNode node, Instances centers,
int[] candidates, int[] assignments, double pc) throws Exception {
// reduce number of owners for current hyper rectangle
int[] owners = refineOwners(node, centers, candidates);
// only one owner
if (owners.length == 1) {
... | java | {
"resource": ""
} |
q23159 | KDTree.refineOwners | train | protected int[] refineOwners(KDTreeNode node, Instances centers,
int[] candidates) throws Exception {
int[] owners = new int[candidates.length];
double minDistance = Double.POSITIVE_INFINITY;
int ownerIndex = -1;
Instance owner;
int numCand = candidates.length;
double[] distance = new dou... | java | {
"resource": ""
} |
q23160 | KDTree.distanceToHrect | train | protected double distanceToHrect(KDTreeNode node, Instance x) throws Exception {
double distance = 0.0;
Instance closestPoint = (Instance)x.copy();
boolean inside;
inside = clipToInsideHrect(node, closestPoint);
if (!inside)
distance = m_EuclideanDistance.distance(closestPoint, x);
return... | java | {
"resource": ""
} |
q23161 | KDTree.clipToInsideHrect | train | protected boolean clipToInsideHrect(KDTreeNode node, Instance x) {
boolean inside = true;
for (int i = 0; i < m_Instances.numAttributes(); i++) {
// TODO treat nominals differently!??
if (x.value(i) < node.m_NodeRanges[i][MIN]) {
x.setValue(i, node.m_NodeRanges[i][MIN]);
inside = fa... | java | {
"resource": ""
} |
q23162 | KDTree.assignSubToCenters | train | public void assignSubToCenters(KDTreeNode node, Instances centers,
int[] centList, int[] assignments) throws Exception {
// todo: undecided situations
int numCent = centList.length;
// WARNING: assignments is "input/output-parameter"
// should not be null and the following should not happen
i... | java | {
"resource": ""
} |
q23163 | KDTree.setDistanceFunction | train | public void setDistanceFunction(DistanceFunction df) throws Exception {
if (!(df instanceof EuclideanDistance))
throw new Exception("KDTree currently only works with "
+ "EuclideanDistanceFunction.");
m_DistanceFunction = m_EuclideanDistance = (EuclideanDistance) df;
} | java | {
"resource": ""
} |
q23164 | ClusteringTreeNode.count | train | @Deprecated
public int count() {
int count = (clusteringFeature != null) ? 1 : 0;
for (ClusteringTreeNode child : children) {
count += child.count();
}
return count;
} | java | {
"resource": ""
} |
q23165 | ClusteringTreeNode.addToClustering | train | public Clustering addToClustering(Clustering clustering) {
if (center != null && getClusteringFeature() != null) {
clustering.add(getClusteringFeature().toCluster());
}
for (ClusteringTreeNode child : children) {
child.addToClustering(clustering);
}
return clustering;
} | java | {
"resource": ""
} |
q23166 | ClusteringTreeNode.addToClusteringCenters | train | public List<double[]> addToClusteringCenters(List<double[]> clustering) {
if (center != null && getClusteringFeature() != null) {
clustering.add(getClusteringFeature().toClusterCenter());
}
for (ClusteringTreeNode child : children) {
child.addToClusteringCenters(clustering);
}
return clustering;
} | java | {
"resource": ""
} |
q23167 | ClusteringTreeNode.printClusteringCenters | train | public void printClusteringCenters(Writer stream) throws IOException {
if (center != null && getClusteringFeature() != null) {
getClusteringFeature().printClusterCenter(stream);
}
for (ClusteringTreeNode child : children) {
child.printClusteringCenters(stream);
}
} | java | {
"resource": ""
} |
q23168 | ClusteringTreeNode.nearestChild | train | public ClusteringTreeNode nearestChild(double[] pointA) {
assert (this.center.length == pointA.length);
double minDistance = Double.POSITIVE_INFINITY;
ClusteringTreeNode min = null;
for (ClusteringTreeNode node : this.getChildren()) {
double d = Metric.distance(pointA, node.getCenter());
if (d < minDistan... | java | {
"resource": ""
} |
q23169 | ClusteringTreeNode.addChild | train | public boolean addChild(ClusteringTreeNode e) {
assert (this.center.length == e.center.length);
return this.children.add(e);
} | java | {
"resource": ""
} |
q23170 | RCD.getPreviousClassifier | train | private ClassifierKS getPreviousClassifier(Classifier classifier,
List<Instance> instances) {
ExecutorService threadPool = Executors.newFixedThreadPool(this.threadSizeOption.getValue());
int SIZE = this.classifiers.size();
Map<Integer, Future<Double>> futures = new HashMap<>();
... | java | {
"resource": ""
} |
q23171 | ClusKernel.makeOlder | train | protected void makeOlder(long timeDifference, double negLambda) {
if (timeDifference == 0) {
return;
}
//double weightFactor = AuxiliaryFunctions.weight(negLambda, timeDifference);
assert (negLambda < 0);
assert (timeDifference > 0);
double weightFactor = Mat... | java | {
"resource": ""
} |
q23172 | ClusKernel.overwriteOldCluster | train | protected void overwriteOldCluster(ClusKernel other) {
this.totalN = other.totalN;
this.N = other.N;
//AuxiliaryFunctions.overwriteDoubleArray(this.LS, other.LS);
//AuxiliaryFunctions.overwriteDoubleArray(this.SS, other.SS);
assert (LS.length == other.LS.length);
System.a... | java | {
"resource": ""
} |
q23173 | SAMkNN.getVotesForInstance | train | @Override
public double[] getVotesForInstance(Instance inst) {
double vSTM[];
double vLTM[];
double vCM[];
double v[];
double distancesSTM[];
double distancesLTM[];
int predClassSTM = 0;
int predClassLTM = 0;
int predClassCM = 0;
try {
if (this.stm.numInstances()>0) {
d... | java | {
"resource": ""
} |
q23174 | SAMkNN.clusterDown | train | private void clusterDown(){
int classIndex = this.ltm.classIndex();
for (int c = 0; c <= this.maxClassValue; c++){
List<double[]> classSamples = new ArrayList<>();
for (int i = this.ltm.numInstances()-1; i >-1 ; i--) {
if (this.ltm.get(i).classValue() == c) {
classSamples.add(this.ltm.get(i).toDouble... | java | {
"resource": ""
} |
q23175 | SAMkNN.memorySizeCheck | train | private void memorySizeCheck(){
if (this.stm.numInstances() + this.ltm.numInstances() > this.maxSTMSize + this.maxLTMSize){
if (this.ltm.numInstances() > this.maxLTMSize){
this.clusterDown();
}else{ //shift values from STM directly to LTM since STM is full
int numShifts = this.maxLTMSize - this.ltm.numI... | java | {
"resource": ""
} |
q23176 | SAMkNN.clean | train | private void clean(Instances cleanAgainst, Instances toClean, boolean onlyLast) {
if (cleanAgainst.numInstances() > this.kOption.getValue() && toClean.numInstances() > 0){
if (onlyLast){
cleanSingle(cleanAgainst, (cleanAgainst.numInstances()-1), toClean);
}else{
for (int i=0; i < cleanAgainst.numInstanc... | java | {
"resource": ""
} |
q23177 | SAMkNN.getDistanceWeightedVotes | train | private double [] getDistanceWeightedVotes(double distances[], int[] nnIndices, Instances instances){
double v[] = new double[this.maxClassValue +1];
for (int nnIdx : nnIndices) {
v[(int)instances.instance(nnIdx).classValue()] += 1./Math.max(distances[nnIdx], 0.000000001);
}
return v;
... | java | {
"resource": ""
} |
q23178 | SAMkNN.getClassFromVotes | train | private int getClassFromVotes(double votes[]){
double maxVote = -1;
int maxVoteClass = -1;
for (int i = 0; i < votes.length; i++){
if (votes[i] > maxVote){
maxVote = votes[i];
maxVoteClass = i;
}
}
return maxVoteClass;
} | java | {
"resource": ""
} |
q23179 | SAMkNN.getDistance | train | private double getDistance(Instance sample, Instance sample2)
{
double sum=0;
for (int i=0; i<sample.numInputAttributes(); i++)
{
double diff = sample.valueInputAttribute(i)-sample2.valueInputAttribute(i);
sum += diff*diff;
}
return Math.sqrt(sum);
... | java | {
"resource": ""
} |
q23180 | SAMkNN.get1ToNDistances | train | private double[] get1ToNDistances(Instance sample, Instances samples){
double distances[] = new double[samples.numInstances()];
for (int i=0; i<samples.numInstances(); i++){
distances[i] = this.getDistance(sample, samples.get(i));
}
return distances;
} | java | {
"resource": ""
} |
q23181 | SAMkNN.adaptHistories | train | private void adaptHistories(int numberOfDeletions){
for (int i = 0; i < numberOfDeletions; i++){
SortedSet<Integer> keys = new TreeSet<>(this.predictionHistories.keySet());
this.predictionHistories.remove(keys.first());
keys = new TreeSet<>(this.predictionHistories.keySet());
for (Integer key : keys){
... | java | {
"resource": ""
} |
q23182 | SAMkNN.getHistoryErrorRate | train | private double getHistoryErrorRate(List<Integer> predHistory){
double sumCorrect = 0;
for (Integer e : predHistory) {
sumCorrect += e;
}
return 1. - (sumCorrect / predHistory.size());
} | java | {
"resource": ""
} |
q23183 | Metric.distanceSquared | train | public static double distanceSquared(double[] pointA) {
double distance = 0.0;
for (int i = 0; i < pointA.length; i++) {
distance += pointA[i] * pointA[i];
}
return distance;
} | java | {
"resource": ""
} |
q23184 | Metric.distanceSquared | train | public static double distanceSquared(double[] pointA, double[] pointB,
int offsetB) {
assert (pointA.length == pointB.length + offsetB);
double distance = 0.0;
for (int i = 0; i < pointA.length; i++) {
double d = pointA[i] - pointB[i + offsetB];
distance += d * d;
}
return distance;
} | java | {
"resource": ""
} |
q23185 | Metric.distance | train | public static double distance(double[] pointA, double[] pointB, int offsetB) {
return Math.sqrt(distanceSquared(pointA, pointB, offsetB));
} | java | {
"resource": ""
} |
q23186 | Metric.distanceWithDivisionSquared | train | public static double distanceWithDivisionSquared(double[] pointA, double dA) {
double distance = 0.0;
for (int i = 0; i < pointA.length; i++) {
double d = pointA[i] / dA;
distance += d * d;
}
return distance;
} | java | {
"resource": ""
} |
q23187 | Metric.distanceWithDivision | train | public static double distanceWithDivision(double[] pointA, double dA,
double[] pointB) {
return Math.sqrt(distanceWithDivisionSquared(pointA, dA, pointB));
} | java | {
"resource": ""
} |
q23188 | Metric.dotProduct | train | public static double dotProduct(double[] pointA) {
double product = 0.0;
for (int i = 0; i < pointA.length; i++) {
product += pointA[i] * pointA[i];
}
return product;
} | java | {
"resource": ""
} |
q23189 | Metric.dotProductWithAddition | train | public static double dotProductWithAddition(double[] pointA1,
double[] pointA2, double[] pointB) {
assert (pointA1.length == pointA2.length && pointA1.length == pointB.length);
double product = 0.0;
for (int i = 0; i < pointA1.length; i++) {
product += (pointA1[i] + pointA2[i]) * pointB[i];
}
return pro... | java | {
"resource": ""
} |
q23190 | Metric.dotProductWithAddition | train | public static double dotProductWithAddition(double[] pointA1,
double[] pointA2, double[] pointB1, double[] pointB2) {
assert (pointA1.length == pointA2.length
&& pointB1.length == pointB2.length && pointA1.length == pointB1.length);
double product = 0.0;
for (int i = 0; i < pointA1.length; i++) {
produc... | java | {
"resource": ""
} |
q23191 | WekaToSamoaInstanceConverter.samoaInstance | train | public Instance samoaInstance(weka.core.Instance inst) {
Instance samoaInstance;
if (inst instanceof weka.core.SparseInstance) {
double[] attributeValues = new double[inst.numValues()];
int[] indexValues = new int[inst.numValues()];
for (int i = 0; i < inst.numValues(... | java | {
"resource": ""
} |
q23192 | WekaToSamoaInstanceConverter.samoaInstances | train | public Instances samoaInstances(weka.core.Instances instances) {
Instances samoaInstances = samoaInstancesInformation(instances);
//We assume that we have only one samoaInstanceInformation for WekaToSamoaInstanceConverter
this.samoaInstanceInformation = samoaInstances;
for (int i = 0; i ... | java | {
"resource": ""
} |
q23193 | WekaToSamoaInstanceConverter.samoaInstancesInformation | train | public Instances samoaInstancesInformation(weka.core.Instances instances) {
Instances samoaInstances;
List<Attribute> attInfo = new ArrayList<Attribute>();
for (int i = 0; i < instances.numAttributes(); i++) {
attInfo.add(samoaAttribute(i, instances.attribute(i)));
}
... | java | {
"resource": ""
} |
q23194 | WekaToSamoaInstanceConverter.samoaAttribute | train | protected Attribute samoaAttribute(int index, weka.core.Attribute attribute) {
Attribute samoaAttribute;
if (attribute.isNominal()) {
Enumeration enu = attribute.enumerateValues();
List<String> attributeValues = new ArrayList<String>();
while (enu.hasMoreElements()) {... | java | {
"resource": ""
} |
q23195 | ImagePanel.doSaveAs | train | @Override
public void doSaveAs() throws IOException {
JFileChooser fileChooser = new JFileChooser();
ExtensionFileFilter filterPNG = new ExtensionFileFilter("PNG Image Files", ".png");
fileChooser.addChoosableFileFilter(filterPNG);
ExtensionFileFilter filterJPG = new ExtensionFileF... | java | {
"resource": ""
} |
q23196 | RuleClassifier.round | train | protected BigDecimal round(double val){
BigDecimal value = new BigDecimal(val);
if(val!=0.0){
value = value.setScale(3, BigDecimal.ROUND_DOWN);
}
return value;
} | java | {
"resource": ""
} |
q23197 | RuleClassifier.initializeRuleStatistics | train | public void initializeRuleStatistics(RuleClassification rl, Predicates pred, Instance inst) {
rl.predicateSet.add(pred);
rl.obserClassDistrib=new DoubleVector();
rl.observers=new AutoExpandVector<AttributeClassObserver>();
rl.observersGauss=new AutoExpandVector<AttributeClassObserver>();
rl.instancesSeen = 0;... | java | {
"resource": ""
} |
q23198 | RuleClassifier.updateRuleAttribStatistics | train | public void updateRuleAttribStatistics(Instance inst, RuleClassification rl, int ruleIndex){
rl.instancesSeen++;
if(rl.squaredAttributeStatisticsSupervised.size() == 0 && rl.attributeStatisticsSupervised.size() == 0){
for (int s = 0; s < inst.numAttributes() -1; s++) {
ArrayList<Double> temp1 = new ArrayLis... | java | {
"resource": ""
} |
q23199 | RuleClassifier.createRule | train | public void createRule(Instance inst) {
int remainder = (int)Double.MAX_VALUE;
int numInstanciaObservers = (int)this.observedClassDistribution.sumOfValues();
if (numInstanciaObservers != 0 && this.gracePeriodOption.getValue() != 0) {
remainder = (numInstanciaObservers) % (this.gracePeriodOption.getValue());
... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.