_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q23000
ALTaskTextViewerPanel.setText
train
public void setText(Preview preview) { Point p = this.scrollPaneTable.getViewport().getViewPosition(); previewTableModel.setPreview(preview); SwingUtilities.invokeLater( new Runnable(){ boolean structureChanged = previewTableModel.structureChanged(); public void run(){ if(!scrollPaneTable.isVisib...
java
{ "resource": "" }
q23001
ALTaskTextViewerPanel.readCollection
train
public ParsedPreview readCollection(PreviewCollection<Preview> pc) { ParsedPreview pp = new ParsedPreview(); List<Preview> sps = pc.getPreviews(); if (sps.size() > 0 && sps.get(0) instanceof PreviewCollection) { // members are PreviewCollections again // NOTE: this assumes that all elements in sps are of ...
java
{ "resource": "" }
q23002
ALTaskTextViewerPanel.read
train
private ParsedPreview read(Preview p) { // find measure columns String[] measureNames = p.getMeasurementNames(); int numMeasures = p.getMeasurementNameCount(); int processFrequencyColumn = -1; int accuracyColumn = -1; int kappaColumn = -1; int kappaTempColumn = -1; int ramColumn = -1; int timeColumn...
java
{ "resource": "" }
q23003
DoTask.isJavaVersionOK
train
public static boolean isJavaVersionOK() { boolean isJavaVersionOK = true; String versionStr = System.getProperty("java.version"); String[] parts; double version; if (versionStr.contains(".")) { parts = versionStr.split("\\."); } else { parts = new String[]{v...
java
{ "resource": "" }
q23004
AccuracyWeightedEnsemble.computeCandidateWeight
train
protected double computeCandidateWeight(Classifier candidate, Instances chunk, int numFolds) { double candidateWeight = 0.0; Random random = new Random(1); Instances randData = new Instances(chunk); randData.randomize(random); if (randData.classAttribute().isNominal()) { ...
java
{ "resource": "" }
q23005
AccuracyWeightedEnsemble.computeWeight
train
protected double computeWeight(Classifier learner, Instances chunk) { double mse_i = 0; double mse_r = 0; double f_ci; double voteSum; for (int i = 0; i < chunk.numInstances(); i++) { try { voteSum = 0; for (double element : learner.g...
java
{ "resource": "" }
q23006
AccuracyWeightedEnsemble.getVotesForInstance
train
public double[] getVotesForInstance(Instance inst) { DoubleVector combinedVote = new DoubleVector(); if (this.trainingWeightSeenByModel > 0.0) { for (int i = 0; i < this.ensemble.length; i++) { if (this.ensembleWeights[i] > 0.0) { DoubleVector vote = new ...
java
{ "resource": "" }
q23007
AccuracyWeightedEnsemble.removePoorestModelBytes
train
protected int removePoorestModelBytes() { int poorestIndex = Utils.minIndex(this.ensembleWeights); int byteSize = this.ensemble[poorestIndex].measureByteSize(); discardModel(poorestIndex); return byteSize; }
java
{ "resource": "" }
q23008
EMTopDownTreeBuilder.splitDataSetUsingEM
train
private DataSet[] splitDataSetUsingEM(DataSet dataSet, int nrOfPartitions) throws Exception { if (dataSet.size() <= 1) throw new Exception("EMsplit needs at least 2 objects!"); EMProjectedClustering myEM = new EMProjectedClustering(); // iterate several times and take best solution int nrOfIterations = 1; ...
java
{ "resource": "" }
q23009
MTRandom.setSeed
train
private final void setSeed(int seed) { // Annoying runtime check for initialisation of internal data // caused by java.util.Random invoking setSeed() during init. // This is unavoidable because no fields in our instance will // have been initialised at this point, not even if the code // were placed at the d...
java
{ "resource": "" }
q23010
MTRandom.setSeed
train
public final synchronized void setSeed(int[] buf) { int length = buf.length; if (length == 0) throw new IllegalArgumentException("Seed buffer may not be empty"); // ---- Begin Mersenne Twister Algorithm ---- int i = 1, j = 0, k = (N > length ? N : length); setSeed(MAGIC_SEED); for (; k > 0; k--) { mt[i] ...
java
{ "resource": "" }
q23011
AutoClassDiscovery.initCache
train
protected static synchronized void initCache() { if (m_Cache == null) { m_Cache = new ClassCache(); // failed to locate any classes on the classpath, maybe inside Weka? // try loading fixed list of classes if (m_Cache.isEmpty()) { InputStream input...
java
{ "resource": "" }
q23012
AutoClassDiscovery.getAllClassNames
train
public static List<String> getAllClassNames() { List<String> result = new ArrayList<>(); Iterator<String> pkgs = m_Cache.packages(); while (pkgs.hasNext()) { String pkg = pkgs.next(); if (pkg.startsWith("moa")) { Set<String> classnames = m_Cache.getClassna...
java
{ "resource": "" }
q23013
AutoClassDiscovery.main
train
public static void main(String[] args) throws Exception { initCache(); List<String> allClassnames = getAllClassNames(); PrintStream out = System.out; if (args.length > 0) out = new PrintStream(new File(args[0])); Collections.sort(allClassnames); for (String cl...
java
{ "resource": "" }
q23014
MTree.add
train
public void add(DATA data) { if(root == null) { root = new RootLeafNode(data); try { root.addData(data, 0); } catch (SplitNodeReplacement e) { throw new RuntimeException("Should never happen!"); } } else { double distance = distanceFunction.calculate(data, root.data); try { root.addDat...
java
{ "resource": "" }
q23015
MTree.remove
train
public boolean remove(DATA data) { if(root == null) { return false; } double distanceToRoot = distanceFunction.calculate(data, root.data); try { root.removeData(data, distanceToRoot); } catch(RootNodeReplacement e) { @SuppressWarnings("unchecked") Node newRoot = (Node) e.newRoot; root = newR...
java
{ "resource": "" }
q23016
MTree.getNearestByRange
train
public Query getNearestByRange(DATA queryData, double range) { return getNearest(queryData, range, Integer.MAX_VALUE); }
java
{ "resource": "" }
q23017
MTree.getNearestByLimit
train
public Query getNearestByLimit(DATA queryData, int limit) { return getNearest(queryData, Double.POSITIVE_INFINITY, limit); }
java
{ "resource": "" }
q23018
MTree.getNearest
train
public Query getNearest(DATA queryData) { return new Query(queryData, Double.POSITIVE_INFINITY, Integer.MAX_VALUE); }
java
{ "resource": "" }
q23019
WithKmeans.distance
train
private static double distance(double[] pointA, double [] pointB) { double distance = 0.0; for (int i = 0; i < pointA.length; i++) { double d = pointA[i] - pointB[i]; distance += d * d; } return Math.sqrt(distance); }
java
{ "resource": "" }
q23020
WithKmeans.cleanUpKMeans
train
protected static Clustering cleanUpKMeans(Clustering kMeansResult, ArrayList<CFCluster> microclusters) { /* Convert k-means result to CFClusters */ int k = kMeansResult.size(); CFCluster[] converted = new CFCluster[k]; for (CFCluster mc : microclusters) { // Find closest kMeans cluster double minDi...
java
{ "resource": "" }
q23021
Entry.clear
train
protected void clear() { this.data.clear(); this.buffer.clear(); this.child = null; this.timestamp = Entry.defaultTimestamp; }
java
{ "resource": "" }
q23022
Entry.makeOlder
train
protected void makeOlder(long currentTime, double negLambda) { // assert (currentTime > this.timestamp) : "currentTime : " // + currentTime + ", this.timestamp: " + this.timestamp; long diff = currentTime - this.timestamp; this.buffer.makeOlder(diff, negLambda); this.data....
java
{ "resource": "" }
q23023
HSTrees.resetLearningImpl
train
@Override public void resetLearningImpl() { this.windowSize = this.windowSizeOption.getValue(); this.numTrees = this.numTreesOption.getValue(); this.maxDepth = this.maxDepthOption.getValue(); this.sizeLimit = this.sizeLimitOption.getValue(); this.numInstances = 0; this.forest = new HSTreeNode[numTrees]; ...
java
{ "resource": "" }
q23024
HSTrees.trainOnInstanceImpl
train
@Override public void trainOnInstanceImpl(Instance inst) { // If this is the first instance, then initialize the forest. if(this.numInstances == 0) { this.buildForest(inst); } // Update the mass profile of every HSTree in the forest for(int i = 0 ; i < this.numTrees ; i++) { forest[i].updateMas...
java
{ "resource": "" }
q23025
HSTrees.buildForest
train
private void buildForest(Instance inst) { this.dimensions = inst.numAttributes(); double[]max = new double[dimensions]; double[]min = new double[dimensions]; double sq; for (int i = 0 ; i < this.numTrees ; i++) { for(int j = 0 ; j < this.dimensions ; j++) { sq = this.classifierRandom.nextDoubl...
java
{ "resource": "" }
q23026
HSTrees.getVotesForInstance
train
@Override public double[] getVotesForInstance(Instance inst) { double[] votes = {0.5, 0.5}; if(!referenceWindow) { votes[1] = this.getAnomalyScore(inst) + 0.5 - this.anomalyThreshold; votes[0] = 1.0 - votes[1]; } return votes; }
java
{ "resource": "" }
q23027
HSTrees.getAnomalyScore
train
public double getAnomalyScore(Instance inst) { if(this.referenceWindow) return 0.5; else { double accumulatedScore = 0.0; int massLimit = (int) (Math.ceil(this.sizeLimit*this.windowSize)); double maxScore = this.windowSize * Math.pow(2.0, this.maxDepth); for(int i = 0 ; i < this.numTrees ; i++) ...
java
{ "resource": "" }
q23028
HSTrees.initialize
train
@Override public void initialize(Collection<Instance> trainingPoints) { Iterator<Instance> trgPtsIterator = trainingPoints.iterator(); if(trgPtsIterator.hasNext() && this.numInstances == 0) { Instance inst = trgPtsIterator.next(); this.buildForest(inst); this.trainOnInstance(inst); } while(tr...
java
{ "resource": "" }
q23029
FIMTDDNumericAttributeClassObserver.searchForBestSplitOption
train
protected AttributeSplitSuggestion searchForBestSplitOption(Node currentNode, AttributeSplitSuggestion currentBestOption, SplitCriterion criterion, int attIndex) { // Return null if the current node is null or we have finished looking through all the possible splits if (currentNode == null || countRight...
java
{ "resource": "" }
q23030
FIMTDDNumericAttributeClassObserver.removeBadSplits
train
public void removeBadSplits(SplitCriterion criterion, double lastCheckRatio, double lastCheckSDR, double lastCheckE) { removeBadSplitNodes(criterion, this.root, lastCheckRatio, lastCheckSDR, lastCheckE); }
java
{ "resource": "" }
q23031
FIMTDDNumericAttributeClassObserver.removeBadSplitNodes
train
private boolean removeBadSplitNodes(SplitCriterion criterion, Node currentNode, double lastCheckRatio, double lastCheckSDR, double lastCheckE) { boolean isBad = false; if (currentNode == null) { return true; } if (currentNode.left != null) { isBad = removeBadSpl...
java
{ "resource": "" }
q23032
NearestNeighbourDescription.resetLearningImpl
train
@Override public void resetLearningImpl() { this.nbhdSize = this.neighbourhoodSizeOption.getValue(); //this.k = this.kOption.getValue(); //NOT IMPLEMENTED// //this.m = this.mOption.getValue(); //NOT IMPLEMENTED// this.tau = this.thresholdOption.getValue(); this.neighbourhood = new FixedLengthList<Inst...
java
{ "resource": "" }
q23033
NearestNeighbourDescription.getVotesForInstance
train
@Override public double[] getVotesForInstance(Instance inst) { double[] votes = {0.5, 0.5}; if(this.neighbourhood.size() > 2) { votes[1] = Math.pow(2.0, -1.0 * this.getAnomalyScore(inst) / this.tau); votes[0] = 1.0 - votes[1]; } return votes; }
java
{ "resource": "" }
q23034
NearestNeighbourDescription.getAnomalyScore
train
public double getAnomalyScore(Instance inst) { if(this.neighbourhood.size() < 2) return 1.0; Instance nearestNeighbour = getNearestNeighbour(inst, this.neighbourhood, false); Instance nnNearestNeighbour = getNearestNeighbour(nearestNeighbour, this.neighbourhood, true); double indicatorArgument = dista...
java
{ "resource": "" }
q23035
NearestNeighbourDescription.getNearestNeighbour
train
private Instance getNearestNeighbour(Instance inst, List<Instance> neighbourhood2, boolean inNbhd) { double dist = Double.MAX_VALUE; Instance nearestNeighbour = null; for(Instance candidateNN : neighbourhood2) { // If inst is in neighbourhood2 and an identical instance is found, then it is no longer requ...
java
{ "resource": "" }
q23036
NearestNeighbourDescription.distance
train
private double distance(Instance inst1, Instance inst2) { double dist = 0.0; for(int i = 0 ; i < inst1.numAttributes() ; i++) { dist += Math.pow((inst1.value(i) - inst2.value(i)), 2.0); } return Math.sqrt(dist); }
java
{ "resource": "" }
q23037
Point.costOfPointToCenter
train
public double costOfPointToCenter(Point centre){ if(this.weight == 0.0){ return 0.0; } //stores the distance between p and centre double distance = 0.0; //loop counter for(int l=0; l<this.dimension; l++){ //Centroid coordinate of the point double centroidCoordinatePoint; if(this.weight != 0.0)...
java
{ "resource": "" }
q23038
MOAUtils.fromOption
train
public static MOAObject fromOption(ClassOption option) { return MOAUtils.fromCommandLine(option.getRequiredType(), option.getValueAsCLIString()); }
java
{ "resource": "" }
q23039
MOAUtils.toCommandLine
train
public static String toCommandLine(MOAObject obj) { String result = obj.getClass().getName(); if (obj instanceof AbstractOptionHandler) result += " " + ((AbstractOptionHandler) obj).getOptions().getAsCLIString(); return result.trim(); }
java
{ "resource": "" }
q23040
ArffLoader.readDenseInstanceSparse
train
private Instance readDenseInstanceSparse() { //Returns a dense instance Instance instance = newDenseInstance(this.instanceInformation.numAttributes()); //System.out.println(this.instanceInformation.numAttributes()); int numAttribute; try { //while (streamTokenizer.tty...
java
{ "resource": "" }
q23041
MakeObject.main
train
public static void main(String[] args) { try { System.err.println(); System.err.println(Globals.getWorkbenchInfoString()); System.err.println(); if (args.length < 2) { System.err.println("usage: java " + MakeObject.class.getName() ...
java
{ "resource": "" }
q23042
CFCluster.addVectors
train
public static void addVectors(double[] a1, double[] a2) { assert (a1 != null); assert (a2 != null); assert (a1.length == a2.length) : "Adding two arrays of different " + "length"; for (int i = 0; i < a1.length; i++) { a1[i] += a2[i]; } }
java
{ "resource": "" }
q23043
ALPreviewPanel.refresh
train
private void refresh() { if (this.previewedThread != null) { if (this.previewedThread.isComplete()) { setLatestPreview(); disableRefresh(); } else { this.previewedThread.getPreview(ALPreviewPanel.this); } } }
java
{ "resource": "" }
q23044
ALPreviewPanel.setTaskThreadToPreview
train
public void setTaskThreadToPreview(ALTaskThread thread) { this.previewedThread = thread; setLatestPreview(); if (thread == null) { disableRefresh(); } else if (!thread.isComplete()) { enableRefresh(); } }
java
{ "resource": "" }
q23045
ALPreviewPanel.getColorCodings
train
private Color[] getColorCodings(ALTaskThread thread) { if (thread == null) { return null; } ALMainTask task = (ALMainTask) thread.getTask(); List<ALTaskThread> subtaskThreads = task.getSubtaskThreads(); if (subtaskThreads.size() == 0) { // no hierarchical thread, e...
java
{ "resource": "" }
q23046
ALPreviewPanel.disableRefresh
train
private void disableRefresh() { this.refreshButton.setEnabled(false); this.autoRefreshLabel.setEnabled(false); this.autoRefreshComboBox.setEnabled(false); this.autoRefreshTimer.stop(); }
java
{ "resource": "" }
q23047
ALPreviewPanel.enableRefresh
train
private void enableRefresh() { this.refreshButton.setEnabled(true); this.autoRefreshLabel.setEnabled(true); this.autoRefreshComboBox.setEnabled(true); updateAutoRefreshTimer(); }
java
{ "resource": "" }
q23048
ReLUFilter.filterInstance
train
public Instance filterInstance(Instance x) { if(dataset==null){ initialize(x); } double z_[] = new double[H+1]; int d = x.numAttributes() - 1; // suppose one class attribute (at the end) for(int k = 0; k < H; k++) { // for each hidden unit ... double a_k = 0.; // k-th activation (dot p...
java
{ "resource": "" }
q23049
TreeCoreset.treeNodeSplitCost
train
double treeNodeSplitCost(treeNode node, Point centreA, Point centreB){ //loop counter variable int i; //stores the cost double sum = 0.0; for(i=0; i<node.n; i++){ //loop counter variable int l; //stores the distance between p and centreA double distanceA = 0.0; for(l=0;l<node.points[i]...
java
{ "resource": "" }
q23050
TreeCoreset.treeNodeCostOfPoint
train
double treeNodeCostOfPoint(treeNode node, Point p){ if(p.weight == 0.0){ return 0.0; } //stores the distance between centre and p double distance = 0.0; //loop counter variable int l; for(l=0;l<p.dimension;l++){ //centroid coordinate of the point double centroidCoordinatePoint; if(p.weigh...
java
{ "resource": "" }
q23051
TreeCoreset.isLeaf
train
boolean isLeaf(treeNode node){ if(node.lc == null && node.rc == null){ return true; } else { return false; } }
java
{ "resource": "" }
q23052
TreeCoreset.determineClosestCentre
train
Point determineClosestCentre(Point p, Point centreA, Point centreB){ //loop counter variable int l; //stores the distance between p and centreA double distanceA = 0.0; for(l=0;l<p.dimension;l++){ //centroid coordinate of the point double centroidCoordinatePoint; if(p.weight != 0.0){ centroi...
java
{ "resource": "" }
q23053
TreeCoreset.treeFinished
train
boolean treeFinished(treeNode root){ return (root.parent == null && root.lc == null && root.rc == null); }
java
{ "resource": "" }
q23054
TreeCoreset.freeTree
train
void freeTree(treeNode root){ while(!treeFinished(root)){ if(root.lc == null && root.rc == null){ root = root.parent; } else if(root.lc == null && root.rc != null){ //Schau ob rc ein Blatt ist if(isLeaf(root.rc)){ //Gebe rechtes Kind frei root.rc.free(); root.rc = null; } else { ...
java
{ "resource": "" }
q23055
Autoencoder.initializeNetwork
train
private void initializeNetwork() { this.hiddenLayerSize = this.hiddenLayerOption.getValue(); this.learningRate = this.learningRateOption.getValue(); this.threshold = this.thresholdOption.getValue(); double[][] randomWeightsOne = new double[this.hiddenLayerSize][this.numAttributes]; double[][] randomWeightsTw...
java
{ "resource": "" }
q23056
Autoencoder.trainOnInstanceImpl
train
@Override public void trainOnInstanceImpl(Instance inst) { //Initialize if(this.reset) { this.numAttributes = inst.numAttributes()-1; this.initializeNetwork(); } this.backpropagation(inst); }
java
{ "resource": "" }
q23057
Autoencoder.firstLayer
train
private RealMatrix firstLayer(RealMatrix input) { RealMatrix hidden = (this.weightsOne.multiply(input)).scalarAdd(this.biasOne); double[] tempValues = new double[this.hiddenLayerSize]; // Logistic function used for hidden layer activation for(int i = 0 ; i < this.hiddenLayerSize ; i++) { tempValues[i] ...
java
{ "resource": "" }
q23058
Autoencoder.secondLayer
train
private RealMatrix secondLayer(RealMatrix hidden) { RealMatrix output = (this.weightsTwo.multiply(hidden)).scalarAdd(this.biasTwo); double[] tempValues = new double[this.numAttributes]; // Logistic function used for output layer activation for(int i = 0 ; i < this.numAttributes ; i++) { tempValues[i] =...
java
{ "resource": "" }
q23059
Autoencoder.backpropagation
train
private void backpropagation(Instance inst) { double [] attributeValues = new double[this.numAttributes]; for(int i = 0 ; i < this.numAttributes ; i++) { attributeValues[i] = inst.value(i); } RealMatrix input = new Array2DRowRealMatrix(attributeValues); RealMatrix hidden = firstLayer(input); Rea...
java
{ "resource": "" }
q23060
Autoencoder.getVotesForInstance
train
@Override public double[] getVotesForInstance(Instance inst) { double[] votes = new double[2]; if (this.reset == false) { double error = this.getAnomalyScore(inst); // Exponential function to convert the error [0, +inf) into a vote [1,0]. votes[0] = Math.pow(2.0, -1.0 * (error / this.threshold)); ...
java
{ "resource": "" }
q23061
Autoencoder.getAnomalyScore
train
public double getAnomalyScore(Instance inst) { double error = 0.0; if(!this.reset) { double [] attributeValues = new double[inst.numAttributes()-1]; for(int i = 0 ; i < attributeValues.length ; i++) { attributeValues[i] = inst.value(i); } RealMatrix input = new Array2DRowRealMatrix(attri...
java
{ "resource": "" }
q23062
Autoencoder.initialize
train
@Override public void initialize(Collection<Instance> trainingPoints) { Iterator<Instance> trgPtsIterator = trainingPoints.iterator(); if(trgPtsIterator.hasNext() && this.reset) { Instance inst = (Instance)trgPtsIterator.next(); this.numAttributes = inst.numAttributes()-1; this.initializeNetwork(); ...
java
{ "resource": "" }
q23063
AttributesInformation.setAttributes
train
public void setAttributes(Attribute[] v) { this.attributes = v; this.numberAttributes=v.length; this.indexValues = new int[numberAttributes]; for (int i = 0; i < numberAttributes; i++) { this.indexValues[i]=i; } }
java
{ "resource": "" }
q23064
AttributesInformation.locateIndex
train
public int locateIndex(int index) { int min = 0; int max = this.indexValues.length - 1; if (max == -1) { return -1; } // Binary search while ((this.indexValues[min] <= index) && (this.indexValues[max] >= index)) { int current = (max + min) / 2; ...
java
{ "resource": "" }
q23065
MetaMainTask.setIsLastSubtaskOnLevel
train
public void setIsLastSubtaskOnLevel( boolean[] parentIsLastSubtaskList, boolean isLastSubtask) { this.isLastSubtaskOnLevel = new boolean[parentIsLastSubtaskList.length + 1]; for (int i = 0; i < parentIsLastSubtaskList.length; i++) { this.isLastSubtaskOnLevel[i] = parentIsLastSubtaskList[i]; } thi...
java
{ "resource": "" }
q23066
RankingGraph.fontSelection
train
public void fontSelection() { FontChooserPanel panel = new FontChooserPanel(textFont); int result = JOptionPane.showConfirmDialog( this, panel, "Font Selection", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE ...
java
{ "resource": "" }
q23067
Options.splitParameterFromRemainingOptions
train
protected static String[] splitParameterFromRemainingOptions( String cliString) { String[] paramSplit = new String[2]; cliString = cliString.trim(); if (cliString.startsWith("\"") || cliString.startsWith("'")) { int endQuoteIndex = cliString.indexOf(cliString.charAt(0), 1...
java
{ "resource": "" }
q23068
ClusTree.updateToTop
train
private void updateToTop(Node toUpdate) { while(toUpdate!=null){ for (Entry e: toUpdate.getEntries()) e.recalculateData(); if (toUpdate.getEntries()[0].getParentEntry()==null) break; toUpdate=toUpdate.getEntries()[0].getParentEntry().getNode(); } }
java
{ "resource": "" }
q23069
ClusTree.insertHereWithSplit
train
private Entry insertHereWithSplit(Entry toInsert, Node insertNode, long timestamp) { //Handle root split if (insertNode.getEntries()[0].getParentEntry()==null){ root.makeOlder(timestamp, negLambda); Entry irrelevantEntry = insertNode.getIrrelevantEntry(this.weightThreshold); i...
java
{ "resource": "" }
q23070
ClusTree.findBestLeafNode
train
private Node findBestLeafNode(ClusKernel newPoint) { double minDist = Double.MAX_VALUE; Node bestFit = null; for (Node e: collectLeafNodes(root)){ if (newPoint.calcDistance(e.nearestEntry(newPoint).getData())<minDist){ bestFit = e; minDist = newPoint.calcDistance(e.nearestEntry(newPoi...
java
{ "resource": "" }
q23071
ClusTree.calculateBestMergeInNode
train
private BestMergeInNode calculateBestMergeInNode(Node node) { assert (node.numFreeEntries() == 0); Entry[] entries = node.getEntries(); int toMerge1 = -1; int toMerge2 = -1; double distanceBetweenMergeEntries = Double.NaN; double minDistance = Double.MAX_VALUE; ...
java
{ "resource": "" }
q23072
EvaluateClustering.setMeasures
train
protected void setMeasures(boolean[] measures) { this.generalEvalOption.setValue(measures[0]); this.f1Option.setValue(measures[1]); this.entropyOption.setValue(measures[2]); this.cmmOption.setValue(measures[3]); this.ssqOption.setValue(measures[4]); this.separationOption.setValu...
java
{ "resource": "" }
q23073
GridCluster.isConnected
train
public boolean isConnected() { this.visited = new HashMap<DensityGrid, Boolean>(); Iterator<DensityGrid> initIter = this.grids.keySet().iterator(); DensityGrid dg; if (initIter.hasNext()) { dg = initIter.next(); visited.put(dg, this.grids.get(dg)); boolean changesMade; do{ changesMade ...
java
{ "resource": "" }
q23074
GridCluster.getInclusionProbability
train
@Override public double getInclusionProbability(Instance instance) { Iterator<Map.Entry<DensityGrid, Boolean>> gridIter = grids.entrySet().iterator(); while(gridIter.hasNext()) { Map.Entry<DensityGrid, Boolean> grid = gridIter.next(); DensityGrid dg = grid.getKey(); if(dg.getInclusionProbability(inst...
java
{ "resource": "" }
q23075
ClusteringFeature.add
train
public void add(int numPoints, double[] sumPoints, double sumSquaredPoints) { assert (this.sumPoints.length == sumPoints.length); this.numPoints += numPoints; super.setWeight(this.numPoints); for (int i = 0; i < this.sumPoints.length; i++) { this.sumPoints[i] += sumPoints[i]; } this.sumSquaredLength += s...
java
{ "resource": "" }
q23076
ClusteringFeature.merge
train
public void merge(ClusteringFeature x) { assert (this.sumPoints.length == x.sumPoints.length); this.numPoints += x.numPoints; super.setWeight(this.numPoints); for (int i = 0; i < this.sumPoints.length; i++) { this.sumPoints[i] += x.sumPoints[i]; } this.sumSquaredLength += x.sumSquaredLength; }
java
{ "resource": "" }
q23077
ClusteringFeature.toCluster
train
public Cluster toCluster() { double[] output = new double[this.sumPoints.length]; System.arraycopy(this.sumPoints, 0, output, 0, this.sumPoints.length); for (int i = 0; i < output.length; i++) { output[i] /= this.numPoints; } return new SphereCluster(output, getThreshold(), this.numPoints); }
java
{ "resource": "" }
q23078
ClusteringFeature.toClusterCenter
train
public double[] toClusterCenter() { double[] output = new double[this.sumPoints.length + 1]; System.arraycopy(this.sumPoints, 0, output, 1, this.sumPoints.length); output[0] = this.numPoints; for (int i = 1; i < output.length; i++) { output[i] /= this.numPoints; } return output; }
java
{ "resource": "" }
q23079
ClusteringFeature.printClusterCenter
train
public void printClusterCenter(Writer stream) throws IOException { stream.write(String.valueOf(this.numPoints)); for (int j = 0; j < this.sumPoints.length; j++) { stream.write(' '); stream.write(String.valueOf(this.sumPoints[j] / this.numPoints)); } stream.write(System.getProperty("line.separator")); }
java
{ "resource": "" }
q23080
ClusteringFeature.calcKMeansCosts
train
public double calcKMeansCosts(double[] center) { assert (this.sumPoints.length == center.length); return this.sumSquaredLength - 2 * Metric.dotProduct(this.sumPoints, center) + this.numPoints * Metric.dotProduct(center); }
java
{ "resource": "" }
q23081
ClusteringFeature.calcKMeansCosts
train
public double calcKMeansCosts(double[] center, double[] point) { assert (this.sumPoints.length == center.length && this.sumPoints.length == point.length); return (this.sumSquaredLength + Metric.distanceSquared(point)) - 2 * Metric.dotProductWithAddition(this.sumPoints, point, center) + (this.numPoints +...
java
{ "resource": "" }
q23082
ClusteringFeature.calcKMeansCosts
train
public double calcKMeansCosts(double[] center, ClusteringFeature points) { assert (this.sumPoints.length == center.length && this.sumPoints.length == points.sumPoints.length); return (this.sumSquaredLength + points.sumSquaredLength) - 2 * Metric.dotProductWithAddition(this.sumPoints, points.sumPoints,...
java
{ "resource": "" }
q23083
OnlineAccuracyUpdatedEnsemble.computeWeight
train
protected double computeWeight(int i, Instance example) { int d = this.windowSize; int t = this.processedInstances - this.ensemble[i].birthday; double e_it = 0; double mse_it = 0; double voteSum = 0; try{ double[] votes = this.ensemble[i].clas...
java
{ "resource": "" }
q23084
OnlineAccuracyUpdatedEnsemble.getPoorestClassifierIndex
train
private int getPoorestClassifierIndex() { int minIndex = 0; for (int i = 1; i < this.weights.length; i++) { if(this.weights[i][0] < this.weights[minIndex][0]){ minIndex = i; } } return minIndex; }
java
{ "resource": "" }
q23085
InstanceImpl.classIndex
train
@Override public int classIndex() { int classIndex = instanceHeader.classIndex(); // return ? classIndex : 0; if(classIndex == Integer.MAX_VALUE) if(this.instanceHeader.instanceInformation.range!=null) classIndex=instanceHeader.instanceInformation.range.getStart(); ...
java
{ "resource": "" }
q23086
InstanceImpl.setDataset
train
@Override public void setDataset(Instances dataset) { if(dataset instanceof InstancesHeader) { this.instanceHeader = (InstancesHeader) dataset; }else { this.instanceHeader = new InstancesHeader(dataset); } }
java
{ "resource": "" }
q23087
InstanceImpl.addSparseValues
train
@Override public void addSparseValues(int[] indexValues, double[] attributeValues, int numberAttributes) { this.instanceData = new SparseInstanceData(attributeValues, indexValues, numberAttributes); //??? }
java
{ "resource": "" }
q23088
DACC.initVariables
train
protected void initVariables(){ int ensembleSize = (int)this.memberCountOption.getValue(); this.ensemble = new Classifier[ensembleSize]; this.ensembleAges = new double[ensembleSize]; this.ensembleWindows = new int[ensembleSize][(int)this.evaluationSizeOption.getValue()]; }
java
{ "resource": "" }
q23089
DACC.trainAndClassify
train
protected void trainAndClassify(Instance inst){ nbInstances++; boolean mature = true; boolean unmature = true; for (int i = 0; i < getNbActiveClassifiers(); i++) { // check if all adaptive learners are mature if (this.ensembleAges[i] < this.maturit...
java
{ "resource": "" }
q23090
DACC.discardModel
train
public void discardModel(int index) { this.ensemble[index].resetLearning(); this.ensembleWeights[index].val = 0; this.ensembleAges[index] = 0; this.ensembleWindows[index]=new int[(int)this.evaluationSizeOption.getValue()]; }
java
{ "resource": "" }
q23091
DACC.updateEvaluationWindow
train
protected double updateEvaluationWindow(int index,int val){ int[] newEnsembleWindows = new int[this.ensembleWindows[index].length]; int wsize = (int)Math.min(this.evaluationSizeOption.getValue(),this.ensembleAges[index]+1); int sum = 0; for (int i = 0; i < wsize-1 ; i++){ ...
java
{ "resource": "" }
q23092
DACC.getMAXIndexes
train
protected ArrayList<Integer> getMAXIndexes(){ ArrayList<Integer> maxWIndex=new ArrayList<Integer>(); Pair[] newEnsembleWeights = new Pair[getNbActiveClassifiers()]; System.arraycopy(ensembleWeights, 0, newEnsembleWeights, 0, newEnsembleWeights.length); Arrays.sort(newEnsembleWeights);...
java
{ "resource": "" }
q23093
ImageChart.exportIMG
train
public void exportIMG(String path, String type) throws IOException { switch (type) { case "JPG": try { ChartUtilities.saveChartAsJPEG(new File(path + File.separator + name + ".jpg"), chart, width, height); } catch (IOException e) { ...
java
{ "resource": "" }
q23094
MeasureOverview.setActionListener
train
public void setActionListener(ActionListener listener) { for (int i = 0; i < this.radioButtons.length; i++) { this.radioButtons[i].addActionListener(listener); } }
java
{ "resource": "" }
q23095
MeasureOverview.update
train
public void update(MeasureCollection[] measures, String variedParamName, double[] variedParamValues) { this.measures = measures; this.variedParamName = variedParamName; this.variedParamValues = variedParamValues; update(); updateParamBox(); }
java
{ "resource": "" }
q23096
MeasureOverview.update
train
public void update() { if (this.measures == null || this.measures.length == 0) { // no measures to show -> empty entries for (int i = 0; i < this.currentValues.length; i++) { this.currentValues[i].setText("-"); this.meanValues[i].setText("-"); ...
java
{ "resource": "" }
q23097
MeasureOverview.updateParamBox
train
private void updateParamBox() { if (this.variedParamValues == null || this.variedParamValues.length == 0) { // no varied parameter -> set to empty box this.paramBox.removeAllItems(); this.paramBox.setEnabled(false); } else if (this.paramBox.getItemCount() != this.vari...
java
{ "resource": "" }
q23098
AbstractAMRules.getModelMeasurementsImpl
train
@Override protected Measurement[] getModelMeasurementsImpl() { return new Measurement[]{ new Measurement("anomaly detections", this.numAnomaliesDetected), new Measurement("change detections", this.numChangesDetected), new Measurement("rules (number)", this.ruleSet.size()+1)}; }
java
{ "resource": "" }
q23099
AbstractAMRules.getModelDescription
train
@Override public void getModelDescription(StringBuilder out, int indent) { indent=0; if(!this.unorderedRulesOption.isSet()){ StringUtils.appendIndented(out, indent, "Method Ordered"); StringUtils.appendNewline(out); }else{ StringUtils.appendIndented(out, indent, "Method Unordered"); StringUtils.appen...
java
{ "resource": "" }