repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/SOD.java
SOD.getNearestNeighbors
private DBIDs getNearestNeighbors(Relation<V> relation, SimilarityQuery<V> simQ, DBIDRef queryObject) { Heap<DoubleDBIDPair> nearestNeighbors = new TiedTopBoundedHeap<>(knn); for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { if(DBIDUtil.equal(iter, queryObject)) { continue; } double sim = simQ.similarity(queryObject, iter); if(sim > 0.) { nearestNeighbors.add(DBIDUtil.newPair(sim, iter)); } } // Collect DBIDs ArrayModifiableDBIDs dbids = DBIDUtil.newArray(nearestNeighbors.size()); while(nearestNeighbors.size() > 0) { dbids.add(nearestNeighbors.poll()); } return dbids; }
java
private DBIDs getNearestNeighbors(Relation<V> relation, SimilarityQuery<V> simQ, DBIDRef queryObject) { Heap<DoubleDBIDPair> nearestNeighbors = new TiedTopBoundedHeap<>(knn); for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { if(DBIDUtil.equal(iter, queryObject)) { continue; } double sim = simQ.similarity(queryObject, iter); if(sim > 0.) { nearestNeighbors.add(DBIDUtil.newPair(sim, iter)); } } // Collect DBIDs ArrayModifiableDBIDs dbids = DBIDUtil.newArray(nearestNeighbors.size()); while(nearestNeighbors.size() > 0) { dbids.add(nearestNeighbors.poll()); } return dbids; }
[ "private", "DBIDs", "getNearestNeighbors", "(", "Relation", "<", "V", ">", "relation", ",", "SimilarityQuery", "<", "V", ">", "simQ", ",", "DBIDRef", "queryObject", ")", "{", "Heap", "<", "DoubleDBIDPair", ">", "nearestNeighbors", "=", "new", "TiedTopBoundedHeap...
Get the k nearest neighbors in terms of the shared nearest neighbor distance. The query object is excluded from the knn list. FIXME: move this to the database layer. @param relation the database holding the objects @param simQ similarity function @param queryObject the query object for which the kNNs should be determined @return the k nearest neighbors in terms of the shared nearest neighbor distance without the query object
[ "Get", "the", "k", "nearest", "neighbors", "in", "terms", "of", "the", "shared", "nearest", "neighbor", "distance", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/SOD.java#L203-L220
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/SOD.java
SOD.computePerDimensionVariances
private static double[] computePerDimensionVariances(Relation<? extends NumberVector> relation, double[] center, DBIDs neighborhood) { final int dim = center.length; double[] variances = new double[dim]; for(DBIDIter iter = neighborhood.iter(); iter.valid(); iter.advance()) { NumberVector databaseObject = relation.get(iter); for(int d = 0; d < dim; d++) { final double deviation = databaseObject.doubleValue(d) - center[d]; variances[d] += deviation * deviation; } } return VMath.timesEquals(variances, 1. / neighborhood.size()); }
java
private static double[] computePerDimensionVariances(Relation<? extends NumberVector> relation, double[] center, DBIDs neighborhood) { final int dim = center.length; double[] variances = new double[dim]; for(DBIDIter iter = neighborhood.iter(); iter.valid(); iter.advance()) { NumberVector databaseObject = relation.get(iter); for(int d = 0; d < dim; d++) { final double deviation = databaseObject.doubleValue(d) - center[d]; variances[d] += deviation * deviation; } } return VMath.timesEquals(variances, 1. / neighborhood.size()); }
[ "private", "static", "double", "[", "]", "computePerDimensionVariances", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "relation", ",", "double", "[", "]", "center", ",", "DBIDs", "neighborhood", ")", "{", "final", "int", "dim", "=", "center", "...
Compute the per-dimension variances for the given neighborhood and center. @param relation Data relation @param center Center vector @param neighborhood Neighbors @return Per-dimension variances.
[ "Compute", "the", "per", "-", "dimension", "variances", "for", "the", "given", "neighborhood", "and", "center", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/SOD.java#L230-L241
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/SOD.java
SOD.subspaceOutlierDegree
private double subspaceOutlierDegree(V queryObject, double[] center, long[] weightVector) { final int card = BitsUtil.cardinality(weightVector); if(card == 0) { return 0; } final SubspaceEuclideanDistanceFunction df = new SubspaceEuclideanDistanceFunction(weightVector); return df.distance(queryObject, DoubleVector.wrap(center)) / card; }
java
private double subspaceOutlierDegree(V queryObject, double[] center, long[] weightVector) { final int card = BitsUtil.cardinality(weightVector); if(card == 0) { return 0; } final SubspaceEuclideanDistanceFunction df = new SubspaceEuclideanDistanceFunction(weightVector); return df.distance(queryObject, DoubleVector.wrap(center)) / card; }
[ "private", "double", "subspaceOutlierDegree", "(", "V", "queryObject", ",", "double", "[", "]", "center", ",", "long", "[", "]", "weightVector", ")", "{", "final", "int", "card", "=", "BitsUtil", ".", "cardinality", "(", "weightVector", ")", ";", "if", "("...
Compute SOD score. @param queryObject Query object @param center Center vector @param weightVector Weight vector @return sod score
[ "Compute", "SOD", "score", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/SOD.java#L251-L258
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ParseUtil.java
ParseUtil.parseLongBase10
public static long parseLongBase10(final CharSequence str, final int start, final int end) { // Current position and character. int pos = start; char cur = str.charAt(pos); // Match sign boolean isNegative = (cur == '-'); // Carefully consume the - character, update c and i: if((isNegative || (cur == '+')) && (++pos < end)) { cur = str.charAt(pos); } // Begin parsing real numbers! if((cur < '0') || (cur > '9')) { throw NOT_A_NUMBER; } // Parse digits into a long, remember offset of decimal point. long decimal = 0; while(true) { final int digit = cur - '0'; if((digit >= 0) && (digit <= 9)) { final long tmp = (decimal << 3) + (decimal << 1) + digit; if(tmp < decimal) { throw PRECISION_OVERFLOW; } decimal = tmp; } else { // No more digits, or a second dot. break; } if(++pos < end) { cur = str.charAt(pos); } else { break; } } if(pos != end) { throw TRAILING_CHARACTERS; } return isNegative ? -decimal : decimal; }
java
public static long parseLongBase10(final CharSequence str, final int start, final int end) { // Current position and character. int pos = start; char cur = str.charAt(pos); // Match sign boolean isNegative = (cur == '-'); // Carefully consume the - character, update c and i: if((isNegative || (cur == '+')) && (++pos < end)) { cur = str.charAt(pos); } // Begin parsing real numbers! if((cur < '0') || (cur > '9')) { throw NOT_A_NUMBER; } // Parse digits into a long, remember offset of decimal point. long decimal = 0; while(true) { final int digit = cur - '0'; if((digit >= 0) && (digit <= 9)) { final long tmp = (decimal << 3) + (decimal << 1) + digit; if(tmp < decimal) { throw PRECISION_OVERFLOW; } decimal = tmp; } else { // No more digits, or a second dot. break; } if(++pos < end) { cur = str.charAt(pos); } else { break; } } if(pos != end) { throw TRAILING_CHARACTERS; } return isNegative ? -decimal : decimal; }
[ "public", "static", "long", "parseLongBase10", "(", "final", "CharSequence", "str", ",", "final", "int", "start", ",", "final", "int", "end", ")", "{", "// Current position and character.", "int", "pos", "=", "start", ";", "char", "cur", "=", "str", ".", "ch...
Parse a long integer from a character sequence. @param str String @param start Begin @param end End @return Long value
[ "Parse", "a", "long", "integer", "from", "a", "character", "sequence", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ParseUtil.java#L364-L407
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ParseUtil.java
ParseUtil.matchInf
private static boolean matchInf(byte[] str, byte firstchar, int start, int end) { final int len = end - start; // The wonders of unicode. The infinity symbol \u221E is three bytes: if(len == 3 && firstchar == -0x1E && str[start + 1] == -0x78 && str[start + 2] == -0x62) { return true; } if((len != 3 && len != INFINITY_LENGTH) // || (firstchar != 'I' && firstchar != 'i')) { return false; } for(int i = 1, j = INFINITY_LENGTH + 1; i < INFINITY_LENGTH; i++, j++) { final byte c = str[start + i]; if(c != INFINITY_PATTERN[i] && c != INFINITY_PATTERN[j]) { return false; } if(i == 2 && len == 3) { return true; } } return true; }
java
private static boolean matchInf(byte[] str, byte firstchar, int start, int end) { final int len = end - start; // The wonders of unicode. The infinity symbol \u221E is three bytes: if(len == 3 && firstchar == -0x1E && str[start + 1] == -0x78 && str[start + 2] == -0x62) { return true; } if((len != 3 && len != INFINITY_LENGTH) // || (firstchar != 'I' && firstchar != 'i')) { return false; } for(int i = 1, j = INFINITY_LENGTH + 1; i < INFINITY_LENGTH; i++, j++) { final byte c = str[start + i]; if(c != INFINITY_PATTERN[i] && c != INFINITY_PATTERN[j]) { return false; } if(i == 2 && len == 3) { return true; } } return true; }
[ "private", "static", "boolean", "matchInf", "(", "byte", "[", "]", "str", ",", "byte", "firstchar", ",", "int", "start", ",", "int", "end", ")", "{", "final", "int", "len", "=", "end", "-", "start", ";", "// The wonders of unicode. The infinity symbol \\u221E ...
Match "inf", "infinity" in a number of different capitalizations. @param str String to match @param firstchar First character @param start Interval begin @param end Interval end @return {@code true} when infinity was recognized.
[ "Match", "inf", "infinity", "in", "a", "number", "of", "different", "capitalizations", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ParseUtil.java#L481-L501
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ParseUtil.java
ParseUtil.matchNaN
private static boolean matchNaN(byte[] str, byte firstchar, int start, int end) { final int len = end - start; if(len < 2 || len > 3 || (firstchar != 'N' && firstchar != 'n')) { return false; } final byte c1 = str[start + 1]; if(c1 != 'a' && c1 != 'A') { return false; } // Accept just "NA", too: if(len == 2) { return true; } final byte c2 = str[start + 2]; return c2 == 'N' || c2 == 'n'; }
java
private static boolean matchNaN(byte[] str, byte firstchar, int start, int end) { final int len = end - start; if(len < 2 || len > 3 || (firstchar != 'N' && firstchar != 'n')) { return false; } final byte c1 = str[start + 1]; if(c1 != 'a' && c1 != 'A') { return false; } // Accept just "NA", too: if(len == 2) { return true; } final byte c2 = str[start + 2]; return c2 == 'N' || c2 == 'n'; }
[ "private", "static", "boolean", "matchNaN", "(", "byte", "[", "]", "str", ",", "byte", "firstchar", ",", "int", "start", ",", "int", "end", ")", "{", "final", "int", "len", "=", "end", "-", "start", ";", "if", "(", "len", "<", "2", "||", "len", "...
Match "NaN" in a number of different capitalizations. @param str String to match @param firstchar First character @param start Interval begin @param end Interval end @return {@code true} when NaN was recognized.
[ "Match", "NaN", "in", "a", "number", "of", "different", "capitalizations", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ParseUtil.java#L543-L558
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/GUIUtil.java
GUIUtil.setLookAndFeel
public static void setLookAndFeel() { try { if(PREFER_GTK) { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for(LookAndFeelInfo lf : lfs) { if(lf.getClassName().contains("GTK")) { UIManager.setLookAndFeel(lf.getClassName()); return; } } } // Fallback: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { // ignore } }
java
public static void setLookAndFeel() { try { if(PREFER_GTK) { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for(LookAndFeelInfo lf : lfs) { if(lf.getClassName().contains("GTK")) { UIManager.setLookAndFeel(lf.getClassName()); return; } } } // Fallback: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { // ignore } }
[ "public", "static", "void", "setLookAndFeel", "(", ")", "{", "try", "{", "if", "(", "PREFER_GTK", ")", "{", "LookAndFeelInfo", "[", "]", "lfs", "=", "UIManager", ".", "getInstalledLookAndFeels", "(", ")", ";", "for", "(", "LookAndFeelInfo", "lf", ":", "lfs...
Setup look at feel.
[ "Setup", "look", "at", "feel", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/GUIUtil.java#L50-L67
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/GUIUtil.java
GUIUtil.logUncaughtExceptions
public static void logUncaughtExceptions(Logging logger) { try { Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.exception(e)); } catch(SecurityException e) { logger.warning("Could not set the Default Uncaught Exception Handler", e); } }
java
public static void logUncaughtExceptions(Logging logger) { try { Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.exception(e)); } catch(SecurityException e) { logger.warning("Could not set the Default Uncaught Exception Handler", e); } }
[ "public", "static", "void", "logUncaughtExceptions", "(", "Logging", "logger", ")", "{", "try", "{", "Thread", ".", "setDefaultUncaughtExceptionHandler", "(", "(", "t", ",", "e", ")", "->", "logger", ".", "exception", "(", "e", ")", ")", ";", "}", "catch",...
Setup logging of uncaught exceptions. @param logger logger
[ "Setup", "logging", "of", "uncaught", "exceptions", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/GUIUtil.java#L74-L81
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
APRIORI.buildFrequentOneItemsets
protected List<OneItemset> buildFrequentOneItemsets(final Relation<? extends SparseFeatureVector<?>> relation, final int dim, final int needed) { // TODO: use TIntList and prefill appropriately to avoid knowing "dim" // beforehand? int[] counts = new int[dim]; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { SparseFeatureVector<?> bv = relation.get(iditer); for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) { counts[bv.iterDim(it)]++; } } if(LOG.isStatistics()) { LOG.statistics(new LongStatistic(STAT + "1-items.candidates", dim)); } // Generate initial candidates of length 1. List<OneItemset> frequent = new ArrayList<>(dim); for(int i = 0; i < dim; i++) { if(counts[i] >= needed) { frequent.add(new OneItemset(i, counts[i])); } } return frequent; }
java
protected List<OneItemset> buildFrequentOneItemsets(final Relation<? extends SparseFeatureVector<?>> relation, final int dim, final int needed) { // TODO: use TIntList and prefill appropriately to avoid knowing "dim" // beforehand? int[] counts = new int[dim]; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { SparseFeatureVector<?> bv = relation.get(iditer); for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) { counts[bv.iterDim(it)]++; } } if(LOG.isStatistics()) { LOG.statistics(new LongStatistic(STAT + "1-items.candidates", dim)); } // Generate initial candidates of length 1. List<OneItemset> frequent = new ArrayList<>(dim); for(int i = 0; i < dim; i++) { if(counts[i] >= needed) { frequent.add(new OneItemset(i, counts[i])); } } return frequent; }
[ "protected", "List", "<", "OneItemset", ">", "buildFrequentOneItemsets", "(", "final", "Relation", "<", "?", "extends", "SparseFeatureVector", "<", "?", ">", ">", "relation", ",", "final", "int", "dim", ",", "final", "int", "needed", ")", "{", "// TODO: use TI...
Build the 1-itemsets. @param relation Data relation @param dim Maximum dimensionality @param needed Minimum support needed @return 1-itemsets
[ "Build", "the", "1", "-", "itemsets", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L198-L219
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
APRIORI.buildFrequentTwoItemsets
protected List<SparseItemset> buildFrequentTwoItemsets(List<OneItemset> oneitems, final Relation<BitVector> relation, final int dim, final int needed, DBIDs ids, ArrayModifiableDBIDs survivors) { int f1 = 0; long[] mask = BitsUtil.zero(dim); for(OneItemset supported : oneitems) { BitsUtil.setI(mask, supported.item); f1++; } if(LOG.isStatistics()) { LOG.statistics(new LongStatistic(STAT + "2-items.candidates", f1 * (long) (f1 - 1))); } // We quite aggressively size the map, assuming that almost each combination // is present somewhere. If this won't fit into memory, we're likely running // OOM somewhere later anyway! Long2IntOpenHashMap map = new Long2IntOpenHashMap((f1 * (f1 - 1)) >>> 1); final long[] scratch = BitsUtil.zero(dim); for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitsUtil.setI(scratch, mask); relation.get(iditer).andOnto(scratch); int lives = 0; for(int i = BitsUtil.nextSetBit(scratch, 0); i >= 0; i = BitsUtil.nextSetBit(scratch, i + 1)) { for(int j = BitsUtil.nextSetBit(scratch, i + 1); j >= 0; j = BitsUtil.nextSetBit(scratch, j + 1)) { long key = (((long) i) << 32) | j; map.put(key, 1 + map.get(key)); ++lives; } } if(lives > 2) { survivors.add(iditer); } } // Generate candidates of length 2. List<SparseItemset> frequent = new ArrayList<>(f1 * (int) FastMath.sqrt(f1)); for(ObjectIterator<Long2IntMap.Entry> iter = map.long2IntEntrySet().fastIterator(); iter.hasNext();) { Long2IntMap.Entry entry = iter.next(); if(entry.getIntValue() >= needed) { int ii = (int) (entry.getLongKey() >>> 32); int ij = (int) (entry.getLongKey() & -1L); frequent.add(new SparseItemset(new int[] { ii, ij }, entry.getIntValue())); } } // The hashmap may produce them out of order. Collections.sort(frequent); if(LOG.isStatistics()) { LOG.statistics(new LongStatistic(STAT + "2-items.frequent", frequent.size())); } return frequent; }
java
protected List<SparseItemset> buildFrequentTwoItemsets(List<OneItemset> oneitems, final Relation<BitVector> relation, final int dim, final int needed, DBIDs ids, ArrayModifiableDBIDs survivors) { int f1 = 0; long[] mask = BitsUtil.zero(dim); for(OneItemset supported : oneitems) { BitsUtil.setI(mask, supported.item); f1++; } if(LOG.isStatistics()) { LOG.statistics(new LongStatistic(STAT + "2-items.candidates", f1 * (long) (f1 - 1))); } // We quite aggressively size the map, assuming that almost each combination // is present somewhere. If this won't fit into memory, we're likely running // OOM somewhere later anyway! Long2IntOpenHashMap map = new Long2IntOpenHashMap((f1 * (f1 - 1)) >>> 1); final long[] scratch = BitsUtil.zero(dim); for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitsUtil.setI(scratch, mask); relation.get(iditer).andOnto(scratch); int lives = 0; for(int i = BitsUtil.nextSetBit(scratch, 0); i >= 0; i = BitsUtil.nextSetBit(scratch, i + 1)) { for(int j = BitsUtil.nextSetBit(scratch, i + 1); j >= 0; j = BitsUtil.nextSetBit(scratch, j + 1)) { long key = (((long) i) << 32) | j; map.put(key, 1 + map.get(key)); ++lives; } } if(lives > 2) { survivors.add(iditer); } } // Generate candidates of length 2. List<SparseItemset> frequent = new ArrayList<>(f1 * (int) FastMath.sqrt(f1)); for(ObjectIterator<Long2IntMap.Entry> iter = map.long2IntEntrySet().fastIterator(); iter.hasNext();) { Long2IntMap.Entry entry = iter.next(); if(entry.getIntValue() >= needed) { int ii = (int) (entry.getLongKey() >>> 32); int ij = (int) (entry.getLongKey() & -1L); frequent.add(new SparseItemset(new int[] { ii, ij }, entry.getIntValue())); } } // The hashmap may produce them out of order. Collections.sort(frequent); if(LOG.isStatistics()) { LOG.statistics(new LongStatistic(STAT + "2-items.frequent", frequent.size())); } return frequent; }
[ "protected", "List", "<", "SparseItemset", ">", "buildFrequentTwoItemsets", "(", "List", "<", "OneItemset", ">", "oneitems", ",", "final", "Relation", "<", "BitVector", ">", "relation", ",", "final", "int", "dim", ",", "final", "int", "needed", ",", "DBIDs", ...
Build the 2-itemsets. @param oneitems Frequent 1-itemsets @param relation Data relation @param dim Maximum dimensionality @param needed Minimum support needed @param ids Objects to process @param survivors Output: objects that had at least two 1-frequent items. @return Frequent 2-itemsets
[ "Build", "the", "2", "-", "itemsets", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L232-L278
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
APRIORI.frequentItemsets
protected List<? extends Itemset> frequentItemsets(List<? extends Itemset> candidates, Relation<BitVector> relation, int needed, DBIDs ids, ArrayModifiableDBIDs survivors, int length) { if(candidates.isEmpty()) { return Collections.emptyList(); } Itemset first = candidates.get(0); // We have an optimized codepath for large and sparse itemsets. // It probably pays off when #cands >> (avlen choose length) but we do not // currently have the average number of items. These thresholds yield // 2700, 6400, 12500, ... and thus will almost always be met until the // number of frequent itemsets is about to break down to 0. if(candidates.size() > length * length * length * 100 && first instanceof SparseItemset) { // Assume that all itemsets are sparse itemsets! @SuppressWarnings("unchecked") List<SparseItemset> sparsecand = (List<SparseItemset>) candidates; return frequentItemsetsSparse(sparsecand, relation, needed, ids, survivors, length); } for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitVector bv = relation.get(iditer); // TODO: exploit that the candidate set it sorted? int lives = 0; for(Itemset candidate : candidates) { if(candidate.containedIn(bv)) { candidate.increaseSupport(); ++lives; } } if(lives > length) { survivors.add(iditer); } } // Retain only those with minimum support: List<Itemset> frequent = new ArrayList<>(candidates.size()); for(Iterator<? extends Itemset> iter = candidates.iterator(); iter.hasNext();) { final Itemset candidate = iter.next(); if(candidate.getSupport() >= needed) { frequent.add(candidate); } } return frequent; }
java
protected List<? extends Itemset> frequentItemsets(List<? extends Itemset> candidates, Relation<BitVector> relation, int needed, DBIDs ids, ArrayModifiableDBIDs survivors, int length) { if(candidates.isEmpty()) { return Collections.emptyList(); } Itemset first = candidates.get(0); // We have an optimized codepath for large and sparse itemsets. // It probably pays off when #cands >> (avlen choose length) but we do not // currently have the average number of items. These thresholds yield // 2700, 6400, 12500, ... and thus will almost always be met until the // number of frequent itemsets is about to break down to 0. if(candidates.size() > length * length * length * 100 && first instanceof SparseItemset) { // Assume that all itemsets are sparse itemsets! @SuppressWarnings("unchecked") List<SparseItemset> sparsecand = (List<SparseItemset>) candidates; return frequentItemsetsSparse(sparsecand, relation, needed, ids, survivors, length); } for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitVector bv = relation.get(iditer); // TODO: exploit that the candidate set it sorted? int lives = 0; for(Itemset candidate : candidates) { if(candidate.containedIn(bv)) { candidate.increaseSupport(); ++lives; } } if(lives > length) { survivors.add(iditer); } } // Retain only those with minimum support: List<Itemset> frequent = new ArrayList<>(candidates.size()); for(Iterator<? extends Itemset> iter = candidates.iterator(); iter.hasNext();) { final Itemset candidate = iter.next(); if(candidate.getSupport() >= needed) { frequent.add(candidate); } } return frequent; }
[ "protected", "List", "<", "?", "extends", "Itemset", ">", "frequentItemsets", "(", "List", "<", "?", "extends", "Itemset", ">", "candidates", ",", "Relation", "<", "BitVector", ">", "relation", ",", "int", "needed", ",", "DBIDs", "ids", ",", "ArrayModifiable...
Returns the frequent BitSets out of the given BitSets with respect to the given database. @param candidates the candidates to be evaluated @param relation the database to evaluate the candidates on @param needed Minimum support needed @param ids Objects to process @param survivors Output: objects that had at least two 1-frequent items. @param length Itemset length @return Itemsets with sufficient support
[ "Returns", "the", "frequent", "BitSets", "out", "of", "the", "given", "BitSets", "with", "respect", "to", "the", "given", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L394-L433
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
APRIORI.frequentItemsetsSparse
protected List<SparseItemset> frequentItemsetsSparse(List<SparseItemset> candidates, Relation<BitVector> relation, int needed, DBIDs ids, ArrayModifiableDBIDs survivors, int length) { // Current search interval: int begin = 0, end = candidates.size(); int[] scratchi = new int[length], iters = new int[length]; SparseItemset scratch = new SparseItemset(scratchi); for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitVector bv = relation.get(iditer); if(!initializeSearchItemset(bv, scratchi, iters)) { continue; } int lives = 0; while(begin < end) { begin = binarySearch(candidates, scratch, begin, end); if(begin > 0) { candidates.get(begin).increaseSupport(); ++lives; } else { begin = (-begin) - 1; } if(begin >= end || !nextSearchItemset(bv, scratchi, iters)) { break; } } for(Itemset candidate : candidates) { if(candidate.containedIn(bv)) { candidate.increaseSupport(); ++lives; } } if(lives > length) { survivors.add(iditer); } } // Retain only those with minimum support: List<SparseItemset> frequent = new ArrayList<>(candidates.size()); for(Iterator<SparseItemset> iter = candidates.iterator(); iter.hasNext();) { final SparseItemset candidate = iter.next(); if(candidate.getSupport() >= needed) { frequent.add(candidate); } } return frequent; }
java
protected List<SparseItemset> frequentItemsetsSparse(List<SparseItemset> candidates, Relation<BitVector> relation, int needed, DBIDs ids, ArrayModifiableDBIDs survivors, int length) { // Current search interval: int begin = 0, end = candidates.size(); int[] scratchi = new int[length], iters = new int[length]; SparseItemset scratch = new SparseItemset(scratchi); for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitVector bv = relation.get(iditer); if(!initializeSearchItemset(bv, scratchi, iters)) { continue; } int lives = 0; while(begin < end) { begin = binarySearch(candidates, scratch, begin, end); if(begin > 0) { candidates.get(begin).increaseSupport(); ++lives; } else { begin = (-begin) - 1; } if(begin >= end || !nextSearchItemset(bv, scratchi, iters)) { break; } } for(Itemset candidate : candidates) { if(candidate.containedIn(bv)) { candidate.increaseSupport(); ++lives; } } if(lives > length) { survivors.add(iditer); } } // Retain only those with minimum support: List<SparseItemset> frequent = new ArrayList<>(candidates.size()); for(Iterator<SparseItemset> iter = candidates.iterator(); iter.hasNext();) { final SparseItemset candidate = iter.next(); if(candidate.getSupport() >= needed) { frequent.add(candidate); } } return frequent; }
[ "protected", "List", "<", "SparseItemset", ">", "frequentItemsetsSparse", "(", "List", "<", "SparseItemset", ">", "candidates", ",", "Relation", "<", "BitVector", ">", "relation", ",", "int", "needed", ",", "DBIDs", "ids", ",", "ArrayModifiableDBIDs", "survivors",...
Returns the frequent BitSets out of the given BitSets with respect to the given database. Optimized implementation for SparseItemset. @param candidates the candidates to be evaluated @param relation the database to evaluate the candidates on @param needed Minimum support needed @param ids Objects to process @param survivors Output: objects that had at least two 1-frequent items. @param length Itemset length @return Itemsets with sufficient support
[ "Returns", "the", "frequent", "BitSets", "out", "of", "the", "given", "BitSets", "with", "respect", "to", "the", "given", "database", ".", "Optimized", "implementation", "for", "SparseItemset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L447-L490
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
APRIORI.initializeSearchItemset
private boolean initializeSearchItemset(BitVector bv, int[] scratchi, int[] iters) { for(int i = 0; i < scratchi.length; i++) { iters[i] = (i == 0) ? bv.iter() : bv.iterAdvance(iters[i - 1]); if(iters[i] < 0) { return false; } scratchi[i] = bv.iterDim(iters[i]); } return true; }
java
private boolean initializeSearchItemset(BitVector bv, int[] scratchi, int[] iters) { for(int i = 0; i < scratchi.length; i++) { iters[i] = (i == 0) ? bv.iter() : bv.iterAdvance(iters[i - 1]); if(iters[i] < 0) { return false; } scratchi[i] = bv.iterDim(iters[i]); } return true; }
[ "private", "boolean", "initializeSearchItemset", "(", "BitVector", "bv", ",", "int", "[", "]", "scratchi", ",", "int", "[", "]", "iters", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "scratchi", ".", "length", ";", "i", "++", ")", "{"...
Initialize the scratch itemset. @param bv Bit vector data source @param scratchi Scratch itemset @param iters Iterator array @return {@code true} if the itemset had minimum length
[ "Initialize", "the", "scratch", "itemset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L500-L509
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
APRIORI.nextSearchItemset
private boolean nextSearchItemset(BitVector bv, int[] scratchi, int[] iters) { final int last = scratchi.length - 1; for(int j = last; j >= 0; j--) { int n = bv.iterAdvance(iters[j]); if(n >= 0 && (j == last || n != iters[j + 1])) { iters[j] = n; scratchi[j] = bv.iterDim(n); return true; // Success } } return false; }
java
private boolean nextSearchItemset(BitVector bv, int[] scratchi, int[] iters) { final int last = scratchi.length - 1; for(int j = last; j >= 0; j--) { int n = bv.iterAdvance(iters[j]); if(n >= 0 && (j == last || n != iters[j + 1])) { iters[j] = n; scratchi[j] = bv.iterDim(n); return true; // Success } } return false; }
[ "private", "boolean", "nextSearchItemset", "(", "BitVector", "bv", ",", "int", "[", "]", "scratchi", ",", "int", "[", "]", "iters", ")", "{", "final", "int", "last", "=", "scratchi", ".", "length", "-", "1", ";", "for", "(", "int", "j", "=", "last", ...
Advance scratch itemset to the next. @param bv Bit vector data source @param scratchi Scratch itemset @param iters Iterator array @return {@code true} if the itemset had minimum length
[ "Advance", "scratch", "itemset", "to", "the", "next", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L519-L530
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java
APRIORI.binarySearch
private int binarySearch(List<SparseItemset> candidates, SparseItemset scratch, int begin, int end) { --end; while(begin < end) { final int mid = (begin + end) >>> 1; SparseItemset midVal = candidates.get(mid); int cmp = midVal.compareTo(scratch); if(cmp < 0) { begin = mid + 1; } else if(cmp > 0) { end = mid - 1; } else { return mid; // key found } } return -(begin + 1); // key not found, return next }
java
private int binarySearch(List<SparseItemset> candidates, SparseItemset scratch, int begin, int end) { --end; while(begin < end) { final int mid = (begin + end) >>> 1; SparseItemset midVal = candidates.get(mid); int cmp = midVal.compareTo(scratch); if(cmp < 0) { begin = mid + 1; } else if(cmp > 0) { end = mid - 1; } else { return mid; // key found } } return -(begin + 1); // key not found, return next }
[ "private", "int", "binarySearch", "(", "List", "<", "SparseItemset", ">", "candidates", ",", "SparseItemset", "scratch", ",", "int", "begin", ",", "int", "end", ")", "{", "--", "end", ";", "while", "(", "begin", "<", "end", ")", "{", "final", "int", "m...
Binary-search for the next-larger element. @param candidates Candidates to search for @param scratch Scratch space @param begin Search interval begin @param end Search interval end @return Position of first equal-or-larger element
[ "Binary", "-", "search", "for", "the", "next", "-", "larger", "element", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/APRIORI.java#L541-L559
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java
MCEDependenceMeasure.buildPartitions
private <A> ArrayList<int[]> buildPartitions(NumberArrayAdapter<?, A> adapter1, A data1, int len, int depth) { final int[] idx = new int[len]; final double[] tmp = new double[len]; for(int i = 0; i < len; ++i) { idx[i] = i; tmp[i] = adapter1.getDouble(data1, i); } // Sort indexes: IntegerArrayQuickSort.sort(idx, (x, y) -> Double.compare(tmp[x], tmp[y])); Arrays.sort(tmp); // Should yield the same ordering ArrayList<int[]> ret = new ArrayList<>(1 << depth); divide(idx, tmp, ret, 0, tmp.length, depth); return ret; }
java
private <A> ArrayList<int[]> buildPartitions(NumberArrayAdapter<?, A> adapter1, A data1, int len, int depth) { final int[] idx = new int[len]; final double[] tmp = new double[len]; for(int i = 0; i < len; ++i) { idx[i] = i; tmp[i] = adapter1.getDouble(data1, i); } // Sort indexes: IntegerArrayQuickSort.sort(idx, (x, y) -> Double.compare(tmp[x], tmp[y])); Arrays.sort(tmp); // Should yield the same ordering ArrayList<int[]> ret = new ArrayList<>(1 << depth); divide(idx, tmp, ret, 0, tmp.length, depth); return ret; }
[ "private", "<", "A", ">", "ArrayList", "<", "int", "[", "]", ">", "buildPartitions", "(", "NumberArrayAdapter", "<", "?", ",", "A", ">", "adapter1", ",", "A", "data1", ",", "int", "len", ",", "int", "depth", ")", "{", "final", "int", "[", "]", "idx...
Partitions an attribute. @param adapter1 Data adapter @param data1 Data set @param len Length of data @param depth Splitting depth @return List of sorted objects
[ "Partitions", "an", "attribute", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java#L95-L109
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java
MCEDependenceMeasure.divide
private void divide(int[] idx, double[] data, ArrayList<int[]> ret, int start, int end, int depth) { if(depth == 0) { int[] a = Arrays.copyOfRange(idx, start, end); Arrays.sort(a); ret.add(a); return; } final int count = end - start; if(count == 0) { // Corner case, that should barely happen. But for ties, we currently // Do not yet assure that it doesn't happen! for(int j = 1 << depth; j > 0; --j) { ret.add(new int[0]); } return; } double m = 0.; for(int i = start; i < end; i++) { m += data[i]; } m /= count; int pos = Arrays.binarySearch(data, start, end, m); if(pos >= 0) { // Ties: try to choose the most central element. final int opt = (start + end) >> 1; while(data[pos] == m) { if(pos < opt) { pos++; } else if(pos > opt) { pos--; } else { break; } } } else { pos = (-pos - 1); } divide(idx, data, ret, start, pos, depth - 1); divide(idx, data, ret, pos, end, depth - 1); }
java
private void divide(int[] idx, double[] data, ArrayList<int[]> ret, int start, int end, int depth) { if(depth == 0) { int[] a = Arrays.copyOfRange(idx, start, end); Arrays.sort(a); ret.add(a); return; } final int count = end - start; if(count == 0) { // Corner case, that should barely happen. But for ties, we currently // Do not yet assure that it doesn't happen! for(int j = 1 << depth; j > 0; --j) { ret.add(new int[0]); } return; } double m = 0.; for(int i = start; i < end; i++) { m += data[i]; } m /= count; int pos = Arrays.binarySearch(data, start, end, m); if(pos >= 0) { // Ties: try to choose the most central element. final int opt = (start + end) >> 1; while(data[pos] == m) { if(pos < opt) { pos++; } else if(pos > opt) { pos--; } else { break; } } } else { pos = (-pos - 1); } divide(idx, data, ret, start, pos, depth - 1); divide(idx, data, ret, pos, end, depth - 1); }
[ "private", "void", "divide", "(", "int", "[", "]", "idx", ",", "double", "[", "]", "data", ",", "ArrayList", "<", "int", "[", "]", ">", "ret", ",", "int", "start", ",", "int", "end", ",", "int", "depth", ")", "{", "if", "(", "depth", "==", "0",...
Recursive call to further subdivide the array. @param idx Object indexes. @param data 1D data, sorted @param ret Output index @param start Interval start @param end Interval end @param depth Depth
[ "Recursive", "call", "to", "further", "subdivide", "the", "array", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java#L121-L163
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java
MCEDependenceMeasure.intersectionMatrix
private void intersectionMatrix(int[][] res, ArrayList<int[]> partsx, ArrayList<int[]> partsy, int gridsize) { for(int x = 0; x < gridsize; x++) { final int[] px = partsx.get(x); final int[] rowx = res[x]; for(int y = 0; y < gridsize; y++) { int[] py = partsy.get(y); rowx[y] = intersectionSize(px, py); } } }
java
private void intersectionMatrix(int[][] res, ArrayList<int[]> partsx, ArrayList<int[]> partsy, int gridsize) { for(int x = 0; x < gridsize; x++) { final int[] px = partsx.get(x); final int[] rowx = res[x]; for(int y = 0; y < gridsize; y++) { int[] py = partsy.get(y); rowx[y] = intersectionSize(px, py); } } }
[ "private", "void", "intersectionMatrix", "(", "int", "[", "]", "[", "]", "res", ",", "ArrayList", "<", "int", "[", "]", ">", "partsx", ",", "ArrayList", "<", "int", "[", "]", ">", "partsy", ",", "int", "gridsize", ")", "{", "for", "(", "int", "x", ...
Intersect the two 1d grid decompositions, to obtain a 2d matrix. @param res Output matrix to fill @param partsx Partitions in first component @param partsy Partitions in second component. @param gridsize Size of partition decomposition
[ "Intersect", "the", "two", "1d", "grid", "decompositions", "to", "obtain", "a", "2d", "matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java#L173-L182
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java
MCEDependenceMeasure.intersectionSize
private int intersectionSize(int[] px, int[] py) { int i = 0, j = 0, c = 0; while(i < px.length && j < py.length) { final int vx = px[i], vy = py[j]; if(vx < vy) { ++i; } else if(vx > vy) { ++j; } else { ++c; ++i; ++j; } } return c; }
java
private int intersectionSize(int[] px, int[] py) { int i = 0, j = 0, c = 0; while(i < px.length && j < py.length) { final int vx = px[i], vy = py[j]; if(vx < vy) { ++i; } else if(vx > vy) { ++j; } else { ++c; ++i; ++j; } } return c; }
[ "private", "int", "intersectionSize", "(", "int", "[", "]", "px", ",", "int", "[", "]", "py", ")", "{", "int", "i", "=", "0", ",", "j", "=", "0", ",", "c", "=", "0", ";", "while", "(", "i", "<", "px", ".", "length", "&&", "j", "<", "py", ...
Compute the intersection of two sorted integer lists. @param px First list @param py Second list @return Intersection size.
[ "Compute", "the", "intersection", "of", "two", "sorted", "integer", "lists", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java#L191-L208
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java
MCEDependenceMeasure.getMCEntropy
private double getMCEntropy(int[][] mat, ArrayList<int[]> partsx, ArrayList<int[]> partsy, int size, int gridsize, double loggrid) { // Margin entropies: double[] mx = new double[gridsize]; double[] my = new double[gridsize]; for(int i = 0; i < gridsize; i++) { // Note: indexes are a bit tricky here, because we compute both margin // entropies at the same time! final double sumx = (double) partsx.get(i).length; final double sumy = (double) partsy.get(i).length; for(int j = 0; j < gridsize; j++) { double px = mat[i][j] / sumx; double py = mat[j][i] / sumy; if(px > 0.) { mx[i] -= px * FastMath.log(px); } if(py > 0.) { my[i] -= py * FastMath.log(py); } } } // Weighted sums of margin entropies. double sumx = 0., sumy = 0.; for(int i = 0; i < gridsize; i++) { sumx += mx[i] * partsx.get(i).length; sumy += my[i] * partsy.get(i).length; } double max = ((sumx > sumy) ? sumx : sumy); return max / (size * loggrid); }
java
private double getMCEntropy(int[][] mat, ArrayList<int[]> partsx, ArrayList<int[]> partsy, int size, int gridsize, double loggrid) { // Margin entropies: double[] mx = new double[gridsize]; double[] my = new double[gridsize]; for(int i = 0; i < gridsize; i++) { // Note: indexes are a bit tricky here, because we compute both margin // entropies at the same time! final double sumx = (double) partsx.get(i).length; final double sumy = (double) partsy.get(i).length; for(int j = 0; j < gridsize; j++) { double px = mat[i][j] / sumx; double py = mat[j][i] / sumy; if(px > 0.) { mx[i] -= px * FastMath.log(px); } if(py > 0.) { my[i] -= py * FastMath.log(py); } } } // Weighted sums of margin entropies. double sumx = 0., sumy = 0.; for(int i = 0; i < gridsize; i++) { sumx += mx[i] * partsx.get(i).length; sumy += my[i] * partsy.get(i).length; } double max = ((sumx > sumy) ? sumx : sumy); return max / (size * loggrid); }
[ "private", "double", "getMCEntropy", "(", "int", "[", "]", "[", "]", "mat", ",", "ArrayList", "<", "int", "[", "]", ">", "partsx", ",", "ArrayList", "<", "int", "[", "]", ">", "partsy", ",", "int", "size", ",", "int", "gridsize", ",", "double", "lo...
Compute the MCE entropy value. @param mat Partition size matrix @param partsx Partitions on X @param partsy Partitions on Y @param size Data set size @param gridsize Size of grids @param loggrid Logarithm of grid sizes, for normalization @return MCE score.
[ "Compute", "the", "MCE", "entropy", "value", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/MCEDependenceMeasure.java#L221-L253
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java
Heap.add
public void add(E e) { // resize when needed if(size + 1 > queue.length) { resize(size + 1); } // final int pos = size; this.size += 1; heapifyUp(size - 1, e); heapModified(); }
java
public void add(E e) { // resize when needed if(size + 1 > queue.length) { resize(size + 1); } // final int pos = size; this.size += 1; heapifyUp(size - 1, e); heapModified(); }
[ "public", "void", "add", "(", "E", "e", ")", "{", "// resize when needed", "if", "(", "size", "+", "1", ">", "queue", ".", "length", ")", "{", "resize", "(", "size", "+", "1", ")", ";", "}", "// final int pos = size;", "this", ".", "size", "+=", "1",...
Add an element to the heap. @param e Element to add
[ "Add", "an", "element", "to", "the", "heap", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java#L113-L122
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java
Heap.replaceTopElement
@SuppressWarnings("unchecked") public E replaceTopElement(E e) { E oldroot = (E) queue[0]; heapifyDown(0, e); heapModified(); return oldroot; }
java
@SuppressWarnings("unchecked") public E replaceTopElement(E e) { E oldroot = (E) queue[0]; heapifyDown(0, e); heapModified(); return oldroot; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "E", "replaceTopElement", "(", "E", "e", ")", "{", "E", "oldroot", "=", "(", "E", ")", "queue", "[", "0", "]", ";", "heapifyDown", "(", "0", ",", "e", ")", ";", "heapModified", "(", ")", ...
Combined operation that removes the top element, and inserts a new element instead. @param e New element to insert @return Previous top element of the heap
[ "Combined", "operation", "that", "removes", "the", "top", "element", "and", "inserts", "a", "new", "element", "instead", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java#L131-L137
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java
Heap.removeAt
@SuppressWarnings("unchecked") protected E removeAt(int pos) { if(pos < 0 || pos >= size) { return null; } final E ret = (E) queue[pos]; // Replacement object: final Object reinsert = queue[size - 1]; queue[size - 1] = null; size--; heapifyDown(pos, reinsert); heapModified(); return ret; }
java
@SuppressWarnings("unchecked") protected E removeAt(int pos) { if(pos < 0 || pos >= size) { return null; } final E ret = (E) queue[pos]; // Replacement object: final Object reinsert = queue[size - 1]; queue[size - 1] = null; size--; heapifyDown(pos, reinsert); heapModified(); return ret; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "E", "removeAt", "(", "int", "pos", ")", "{", "if", "(", "pos", "<", "0", "||", "pos", ">=", "size", ")", "{", "return", "null", ";", "}", "final", "E", "ret", "=", "(", "E", ")", "...
Remove the element at the given position. @param pos Element position. @return Element that was at this position.
[ "Remove", "the", "element", "at", "the", "given", "position", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java#L164-L177
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java
Heap.resize
protected final void resize(int requiredSize) { // Double until 64, then increase by 50% each time. int newCapacity = ((queue.length < 64) ? ((queue.length + 1) << 1) : ((queue.length >> 1) + queue.length)); // overflow? if(newCapacity < 0) { throw new OutOfMemoryError(); } if(requiredSize > newCapacity) { newCapacity = requiredSize; } queue = Arrays.copyOf(queue, newCapacity); }
java
protected final void resize(int requiredSize) { // Double until 64, then increase by 50% each time. int newCapacity = ((queue.length < 64) ? ((queue.length + 1) << 1) : ((queue.length >> 1) + queue.length)); // overflow? if(newCapacity < 0) { throw new OutOfMemoryError(); } if(requiredSize > newCapacity) { newCapacity = requiredSize; } queue = Arrays.copyOf(queue, newCapacity); }
[ "protected", "final", "void", "resize", "(", "int", "requiredSize", ")", "{", "// Double until 64, then increase by 50% each time.", "int", "newCapacity", "=", "(", "(", "queue", ".", "length", "<", "64", ")", "?", "(", "(", "queue", ".", "length", "+", "1", ...
Test whether we need to resize to have the requested capacity. @param requiredSize required capacity
[ "Test", "whether", "we", "need", "to", "resize", "to", "have", "the", "requested", "capacity", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java#L262-L273
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java
Heap.clear
public void clear() { // clean up references in the array for memory management for(int i = 0; i < size; i++) { queue[i] = null; } this.size = 0; heapModified(); }
java
public void clear() { // clean up references in the array for memory management for(int i = 0; i < size; i++) { queue[i] = null; } this.size = 0; heapModified(); }
[ "public", "void", "clear", "(", ")", "{", "// clean up references in the array for memory management", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "queue", "[", "i", "]", "=", "null", ";", "}", "this", ".", "size"...
Clear the heap.
[ "Clear", "the", "heap", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java#L278-L285
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java
Heap.checkHeap
protected String checkHeap() { for(int i = 1; i < size; i++) { final int parent = (i - 1) >>> 1; if(comparator.compare(queue[parent], queue[i]) > 0) { return "@" + parent + ": " + queue[parent] + " < @" + i + ": " + queue[i]; } } return null; }
java
protected String checkHeap() { for(int i = 1; i < size; i++) { final int parent = (i - 1) >>> 1; if(comparator.compare(queue[parent], queue[i]) > 0) { return "@" + parent + ": " + queue[parent] + " < @" + i + ": " + queue[i]; } } return null; }
[ "protected", "String", "checkHeap", "(", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<", "size", ";", "i", "++", ")", "{", "final", "int", "parent", "=", "(", "i", "-", "1", ")", ">>>", "1", ";", "if", "(", "comparator", ".", "comp...
Test whether the heap is still valid. Debug method. @return {@code null} when the heap is correct
[ "Test", "whether", "the", "heap", "is", "still", "valid", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/Heap.java#L310-L318
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/KDDTask.java
KDDTask.run
public void run() { // Input step Database db = inputStep.getDatabase(); hier = db.getHierarchy(); // Algorithms - Data Mining Step algorithmStep.runAlgorithms(db); // TODO: this could be nicer hier.add(db, new SettingsResult(settings)); // Evaluation evaluationStep.runEvaluators(hier, db); // Output / Visualization outputStep.runResultHandlers(hier, db); }
java
public void run() { // Input step Database db = inputStep.getDatabase(); hier = db.getHierarchy(); // Algorithms - Data Mining Step algorithmStep.runAlgorithms(db); // TODO: this could be nicer hier.add(db, new SettingsResult(settings)); // Evaluation evaluationStep.runEvaluators(hier, db); // Output / Visualization outputStep.runResultHandlers(hier, db); }
[ "public", "void", "run", "(", ")", "{", "// Input step", "Database", "db", "=", "inputStep", ".", "getDatabase", "(", ")", ";", "hier", "=", "db", ".", "getHierarchy", "(", ")", ";", "// Algorithms - Data Mining Step", "algorithmStep", ".", "runAlgorithms", "(...
Method to run the specified algorithm using the specified database connection.
[ "Method", "to", "run", "the", "specified", "algorithm", "using", "the", "specified", "database", "connection", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/KDDTask.java#L103-L119
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/ModifiableHyperBoundingBox.java
ModifiableHyperBoundingBox.set
public void set(SpatialComparable obj) { final int dim = min.length; assert (obj.getDimensionality() == dim); if(obj instanceof ModifiableHyperBoundingBox) { ModifiableHyperBoundingBox ho = (ModifiableHyperBoundingBox) obj; System.arraycopy(ho.getMinRef(), 0, min, 0, dim); System.arraycopy(ho.getMaxRef(), 0, max, 0, dim); return; } for(int i = 0; i < dim; i++) { min[i] = obj.getMin(i); max[i] = obj.getMax(i); } }
java
public void set(SpatialComparable obj) { final int dim = min.length; assert (obj.getDimensionality() == dim); if(obj instanceof ModifiableHyperBoundingBox) { ModifiableHyperBoundingBox ho = (ModifiableHyperBoundingBox) obj; System.arraycopy(ho.getMinRef(), 0, min, 0, dim); System.arraycopy(ho.getMaxRef(), 0, max, 0, dim); return; } for(int i = 0; i < dim; i++) { min[i] = obj.getMin(i); max[i] = obj.getMax(i); } }
[ "public", "void", "set", "(", "SpatialComparable", "obj", ")", "{", "final", "int", "dim", "=", "min", ".", "length", ";", "assert", "(", "obj", ".", "getDimensionality", "(", ")", "==", "dim", ")", ";", "if", "(", "obj", "instanceof", "ModifiableHyperBo...
Set the bounding box to the same as some other spatial object. @param obj Spatial object to set to.
[ "Set", "the", "bounding", "box", "to", "the", "same", "as", "some", "other", "spatial", "object", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/ModifiableHyperBoundingBox.java#L134-L147
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/ModifiableHyperBoundingBox.java
ModifiableHyperBoundingBox.extend
public boolean extend(SpatialComparable obj) { final int dim = min.length; assert (obj.getDimensionality() == dim); boolean extended = false; for(int i = 0; i < dim; i++) { final double omin = obj.getMin(i); final double omax = obj.getMax(i); if(omin < min[i]) { min[i] = omin; extended = true; } if(omax > max[i]) { max[i] = omax; extended = true; } } return extended; }
java
public boolean extend(SpatialComparable obj) { final int dim = min.length; assert (obj.getDimensionality() == dim); boolean extended = false; for(int i = 0; i < dim; i++) { final double omin = obj.getMin(i); final double omax = obj.getMax(i); if(omin < min[i]) { min[i] = omin; extended = true; } if(omax > max[i]) { max[i] = omax; extended = true; } } return extended; }
[ "public", "boolean", "extend", "(", "SpatialComparable", "obj", ")", "{", "final", "int", "dim", "=", "min", ".", "length", ";", "assert", "(", "obj", ".", "getDimensionality", "(", ")", "==", "dim", ")", ";", "boolean", "extended", "=", "false", ";", ...
Extend the bounding box by some other spatial object. @param obj Spatial object to extend with @return true when the MBR changed.
[ "Extend", "the", "bounding", "box", "by", "some", "other", "spatial", "object", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/ModifiableHyperBoundingBox.java#L155-L172
train
elki-project/elki
elki-classification/src/main/java/de/lmu/ifi/dbs/elki/evaluation/classification/holdout/AbstractHoldout.java
AbstractHoldout.findClassLabelColumn
public static int findClassLabelColumn(MultipleObjectsBundle bundle) { for(int i = 0, l = bundle.metaLength(); i < l; ++i) { if(TypeUtil.CLASSLABEL.isAssignableFromType(bundle.meta(i))) { return i; } } return -1; }
java
public static int findClassLabelColumn(MultipleObjectsBundle bundle) { for(int i = 0, l = bundle.metaLength(); i < l; ++i) { if(TypeUtil.CLASSLABEL.isAssignableFromType(bundle.meta(i))) { return i; } } return -1; }
[ "public", "static", "int", "findClassLabelColumn", "(", "MultipleObjectsBundle", "bundle", ")", "{", "for", "(", "int", "i", "=", "0", ",", "l", "=", "bundle", ".", "metaLength", "(", ")", ";", "i", "<", "l", ";", "++", "i", ")", "{", "if", "(", "T...
Find the class label column in the given data set. @param bundle Bundle @return Class label column
[ "Find", "the", "class", "label", "column", "in", "the", "given", "data", "set", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-classification/src/main/java/de/lmu/ifi/dbs/elki/evaluation/classification/holdout/AbstractHoldout.java#L72-L79
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/HierarchicalClassLabel.java
HierarchicalClassLabel.compareTo
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public int compareTo(ClassLabel o) { HierarchicalClassLabel h = (HierarchicalClassLabel) o; for (int i = 0; i < this.levelwiseNames.length && i < h.levelwiseNames.length; i++) { int comp = 0; try { Comparable first = this.levelwiseNames[i]; Comparable second = h.levelwiseNames[i]; comp = first.compareTo(second); } catch (RuntimeException e) { String h1 = (String) (this.levelwiseNames[i] instanceof Integer ? this.levelwiseNames[i].toString() : this.levelwiseNames[i]); String h2 = (String) (h.levelwiseNames[i] instanceof Integer ? h.levelwiseNames[i].toString() : h.levelwiseNames[i]); comp = h1.compareTo(h2); } if (comp != 0) { return comp; } } return (this.levelwiseNames.length < h.levelwiseNames.length) ? -1 : ((this.levelwiseNames.length == h.levelwiseNames.length) ? 0 : 1); }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public int compareTo(ClassLabel o) { HierarchicalClassLabel h = (HierarchicalClassLabel) o; for (int i = 0; i < this.levelwiseNames.length && i < h.levelwiseNames.length; i++) { int comp = 0; try { Comparable first = this.levelwiseNames[i]; Comparable second = h.levelwiseNames[i]; comp = first.compareTo(second); } catch (RuntimeException e) { String h1 = (String) (this.levelwiseNames[i] instanceof Integer ? this.levelwiseNames[i].toString() : this.levelwiseNames[i]); String h2 = (String) (h.levelwiseNames[i] instanceof Integer ? h.levelwiseNames[i].toString() : h.levelwiseNames[i]); comp = h1.compareTo(h2); } if (comp != 0) { return comp; } } return (this.levelwiseNames.length < h.levelwiseNames.length) ? -1 : ((this.levelwiseNames.length == h.levelwiseNames.length) ? 0 : 1); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "@", "Override", "public", "int", "compareTo", "(", "ClassLabel", "o", ")", "{", "HierarchicalClassLabel", "h", "=", "(", "HierarchicalClassLabel", ")", "o", ";", "for", "(", ...
Compares two HierarchicalClassLabels. Names at higher levels are compared first. Names at a lower level are compared only if their parent-names are equal. Names at a level are tried to be compared as integer values. If this does not succeed, both names are compared as Strings. {@inheritDoc}
[ "Compares", "two", "HierarchicalClassLabels", ".", "Names", "at", "higher", "levels", "are", "compared", "first", ".", "Names", "at", "a", "lower", "level", "are", "compared", "only", "if", "their", "parent", "-", "names", "are", "equal", ".", "Names", "at",...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/HierarchicalClassLabel.java#L116-L136
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/HierarchicalClassLabel.java
HierarchicalClassLabel.getNameAt
public String getNameAt(int level) { return this.levelwiseNames[level] instanceof Integer ? this.levelwiseNames[level].toString() : (String) this.levelwiseNames[level]; }
java
public String getNameAt(int level) { return this.levelwiseNames[level] instanceof Integer ? this.levelwiseNames[level].toString() : (String) this.levelwiseNames[level]; }
[ "public", "String", "getNameAt", "(", "int", "level", ")", "{", "return", "this", ".", "levelwiseNames", "[", "level", "]", "instanceof", "Integer", "?", "this", ".", "levelwiseNames", "[", "level", "]", ".", "toString", "(", ")", ":", "(", "String", ")"...
Returns the name at the given level as a String. @param level the level to return the name at @return the name at the given level as a String
[ "Returns", "the", "name", "at", "the", "given", "level", "as", "a", "String", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/HierarchicalClassLabel.java#L153-L155
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/result/LogResultStructureResultHandler.java
LogResultStructureResultHandler.recursiveLogResult
private void recursiveLogResult(StringBuilder buf, Hierarchy<Result> hier, Result result, int depth) { if(result == null) { buf.append("null"); LOG.warning("null result!"); return; } if(depth > 50) { LOG.warning("Probably infinitely nested results, aborting!"); return; } for(int i = 0; i < depth; i++) { buf.append(' '); } buf.append(result.getClass().getSimpleName()).append(": ").append(result.getLongName()) // .append(" (").append(result.getShortName()).append(")\n"); if(hier.numChildren(result) > 0) { for(It<Result> iter = hier.iterChildren(result); iter.valid(); iter.advance()) { recursiveLogResult(buf, hier, iter.get(), depth + 1); } } }
java
private void recursiveLogResult(StringBuilder buf, Hierarchy<Result> hier, Result result, int depth) { if(result == null) { buf.append("null"); LOG.warning("null result!"); return; } if(depth > 50) { LOG.warning("Probably infinitely nested results, aborting!"); return; } for(int i = 0; i < depth; i++) { buf.append(' '); } buf.append(result.getClass().getSimpleName()).append(": ").append(result.getLongName()) // .append(" (").append(result.getShortName()).append(")\n"); if(hier.numChildren(result) > 0) { for(It<Result> iter = hier.iterChildren(result); iter.valid(); iter.advance()) { recursiveLogResult(buf, hier, iter.get(), depth + 1); } } }
[ "private", "void", "recursiveLogResult", "(", "StringBuilder", "buf", ",", "Hierarchy", "<", "Result", ">", "hier", ",", "Result", "result", ",", "int", "depth", ")", "{", "if", "(", "result", "==", "null", ")", "{", "buf", ".", "append", "(", "\"null\""...
Recursively walk through the result tree. @param buf Output buffer @param result Current result @param depth Depth
[ "Recursively", "walk", "through", "the", "result", "tree", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/result/LogResultStructureResultHandler.java#L67-L87
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/ListParameterization.java
ListParameterization.addFlag
public ListParameterization addFlag(OptionID optionid) { parameters.add(new ParameterPair(optionid, Flag.SET)); return this; }
java
public ListParameterization addFlag(OptionID optionid) { parameters.add(new ParameterPair(optionid, Flag.SET)); return this; }
[ "public", "ListParameterization", "addFlag", "(", "OptionID", "optionid", ")", "{", "parameters", ".", "add", "(", "new", "ParameterPair", "(", "optionid", ",", "Flag", ".", "SET", ")", ")", ";", "return", "this", ";", "}" ]
Add a flag to the parameter list @param optionid Option ID @return this, for chaining
[ "Add", "a", "flag", "to", "the", "parameter", "list" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/ListParameterization.java#L77-L80
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/ListParameterization.java
ListParameterization.serialize
public ArrayList<String> serialize() { ArrayList<String> params = new ArrayList<>(); for(ParameterPair pair : parameters) { params.add(SerializedParameterization.OPTION_PREFIX + pair.option.toString()); if(pair.value instanceof String) { params.add((String) pair.value); } else if(pair.value instanceof Class) { params.add(((Class<?>) pair.value).getCanonicalName()); } else { // Fallback: params.add(pair.value.toString()); } } return params; }
java
public ArrayList<String> serialize() { ArrayList<String> params = new ArrayList<>(); for(ParameterPair pair : parameters) { params.add(SerializedParameterization.OPTION_PREFIX + pair.option.toString()); if(pair.value instanceof String) { params.add((String) pair.value); } else if(pair.value instanceof Class) { params.add(((Class<?>) pair.value).getCanonicalName()); } else { // Fallback: params.add(pair.value.toString()); } } return params; }
[ "public", "ArrayList", "<", "String", ">", "serialize", "(", ")", "{", "ArrayList", "<", "String", ">", "params", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "ParameterPair", "pair", ":", "parameters", ")", "{", "params", ".", "add", "(",...
Serialize parameters. @return Array list of parameters
[ "Serialize", "parameters", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/ListParameterization.java#L177-L192
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/anglebased/FastABOD.java
FastABOD.run
@Override public OutlierResult run(Database db, Relation<V> relation) { DBIDs ids = relation.getDBIDs(); WritableDoubleDataStore abodvalues = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_STATIC); DoubleMinMax minmaxabod = new DoubleMinMax(); if(kernelFunction.getClass() == LinearKernelFunction.class) { if(!kNNABOD(db, relation, ids, abodvalues, minmaxabod)) { // Fallback, if we do not have an index. fastABOD(db, relation, ids, abodvalues, minmaxabod); } } else { fastABOD(db, relation, ids, abodvalues, minmaxabod); } // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Angle-Based Outlier Degree", "abod-outlier", abodvalues, relation.getDBIDs()); OutlierScoreMeta scoreMeta = new InvertedOutlierScoreMeta(minmaxabod.getMin(), minmaxabod.getMax(), 0.0, Double.POSITIVE_INFINITY); return new OutlierResult(scoreMeta, scoreResult); }
java
@Override public OutlierResult run(Database db, Relation<V> relation) { DBIDs ids = relation.getDBIDs(); WritableDoubleDataStore abodvalues = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_STATIC); DoubleMinMax minmaxabod = new DoubleMinMax(); if(kernelFunction.getClass() == LinearKernelFunction.class) { if(!kNNABOD(db, relation, ids, abodvalues, minmaxabod)) { // Fallback, if we do not have an index. fastABOD(db, relation, ids, abodvalues, minmaxabod); } } else { fastABOD(db, relation, ids, abodvalues, minmaxabod); } // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Angle-Based Outlier Degree", "abod-outlier", abodvalues, relation.getDBIDs()); OutlierScoreMeta scoreMeta = new InvertedOutlierScoreMeta(minmaxabod.getMin(), minmaxabod.getMax(), 0.0, Double.POSITIVE_INFINITY); return new OutlierResult(scoreMeta, scoreResult); }
[ "@", "Override", "public", "OutlierResult", "run", "(", "Database", "db", ",", "Relation", "<", "V", ">", "relation", ")", "{", "DBIDs", "ids", "=", "relation", ".", "getDBIDs", "(", ")", ";", "WritableDoubleDataStore", "abodvalues", "=", "DataStoreUtil", "....
Run Fast-ABOD on the data set. @param relation Relation to process @return Outlier detection result
[ "Run", "Fast", "-", "ABOD", "on", "the", "data", "set", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/anglebased/FastABOD.java#L115-L134
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/anglebased/FastABOD.java
FastABOD.kNNABOD
private boolean kNNABOD(Database db, Relation<V> relation, DBIDs ids, WritableDoubleDataStore abodvalues, DoubleMinMax minmaxabod) { DistanceQuery<V> dq = db.getDistanceQuery(relation, SquaredEuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = db.getKNNQuery(dq, DatabaseQuery.HINT_OPTIMIZED_ONLY); boolean squared = true; if(knnq == null) { dq = db.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); knnq = db.getKNNQuery(dq, DatabaseQuery.HINT_OPTIMIZED_ONLY); if(knnq == null) { return false; } squared = false; } SimilarityQuery<V> lk = db.getSimilarityQuery(relation, LinearKernelFunction.STATIC); int k1 = k + 1; // We will get the query point back by the knnq. MeanVariance s = new MeanVariance(); for(DBIDIter pA = ids.iter(); pA.valid(); pA.advance()) { KNNList nl = knnq.getKNNForDBID(pA, k1); double simAA = lk.similarity(pA, pA); s.reset(); DoubleDBIDListIter iB = nl.iter(), iC = nl.iter(); for(; iB.valid(); iB.advance()) { double dAB = iB.doubleValue(); double simAB = lk.similarity(pA, iB); if(!(dAB > 0.)) { continue; } for(iC.seek(iB.getOffset() + 1); iC.valid(); iC.advance()) { double dAC = iC.doubleValue(); double simAC = lk.similarity(pA, iC); if(!(dAC > 0.)) { continue; } // Exploit bilinearity of scalar product: // <B-A, C-A> = <B, C-A> - <A,C-A> // = <B,C> - <B,A> - <A,C> + <A,A> double simBC = lk.similarity(iB, iC); double numerator = simBC - simAB - simAC + simAA; if(squared) { double div = 1. / (dAB * dAC); s.put(numerator * div, FastMath.sqrt(div)); } else { double sqrtdiv = 1. / (dAB * dAC); s.put(numerator * sqrtdiv * sqrtdiv, sqrtdiv); } } } final double abof = s.getNaiveVariance(); minmaxabod.put(abof); abodvalues.putDouble(pA, abof); } return true; }
java
private boolean kNNABOD(Database db, Relation<V> relation, DBIDs ids, WritableDoubleDataStore abodvalues, DoubleMinMax minmaxabod) { DistanceQuery<V> dq = db.getDistanceQuery(relation, SquaredEuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = db.getKNNQuery(dq, DatabaseQuery.HINT_OPTIMIZED_ONLY); boolean squared = true; if(knnq == null) { dq = db.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); knnq = db.getKNNQuery(dq, DatabaseQuery.HINT_OPTIMIZED_ONLY); if(knnq == null) { return false; } squared = false; } SimilarityQuery<V> lk = db.getSimilarityQuery(relation, LinearKernelFunction.STATIC); int k1 = k + 1; // We will get the query point back by the knnq. MeanVariance s = new MeanVariance(); for(DBIDIter pA = ids.iter(); pA.valid(); pA.advance()) { KNNList nl = knnq.getKNNForDBID(pA, k1); double simAA = lk.similarity(pA, pA); s.reset(); DoubleDBIDListIter iB = nl.iter(), iC = nl.iter(); for(; iB.valid(); iB.advance()) { double dAB = iB.doubleValue(); double simAB = lk.similarity(pA, iB); if(!(dAB > 0.)) { continue; } for(iC.seek(iB.getOffset() + 1); iC.valid(); iC.advance()) { double dAC = iC.doubleValue(); double simAC = lk.similarity(pA, iC); if(!(dAC > 0.)) { continue; } // Exploit bilinearity of scalar product: // <B-A, C-A> = <B, C-A> - <A,C-A> // = <B,C> - <B,A> - <A,C> + <A,A> double simBC = lk.similarity(iB, iC); double numerator = simBC - simAB - simAC + simAA; if(squared) { double div = 1. / (dAB * dAC); s.put(numerator * div, FastMath.sqrt(div)); } else { double sqrtdiv = 1. / (dAB * dAC); s.put(numerator * sqrtdiv * sqrtdiv, sqrtdiv); } } } final double abof = s.getNaiveVariance(); minmaxabod.put(abof); abodvalues.putDouble(pA, abof); } return true; }
[ "private", "boolean", "kNNABOD", "(", "Database", "db", ",", "Relation", "<", "V", ">", "relation", ",", "DBIDs", "ids", ",", "WritableDoubleDataStore", "abodvalues", ",", "DoubleMinMax", "minmaxabod", ")", "{", "DistanceQuery", "<", "V", ">", "dq", "=", "db...
Simpler kNN based, can use more indexing. @param db Database @param relation Data relation @param ids IDs @param abodvalues Score storage @param minmaxabod Min/max storage @return {@code true} if kNN were available and usable.
[ "Simpler", "kNN", "based", "can", "use", "more", "indexing", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/anglebased/FastABOD.java#L146-L200
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/anglebased/FastABOD.java
FastABOD.fastABOD
private void fastABOD(Database db, Relation<V> relation, DBIDs ids, WritableDoubleDataStore abodvalues, DoubleMinMax minmaxabod) { // Build a kernel matrix, to make O(n^3) slightly less bad. SimilarityQuery<V> sq = db.getSimilarityQuery(relation, kernelFunction); KernelMatrix kernelMatrix = new KernelMatrix(sq, relation, ids); MeanVariance s = new MeanVariance(); KNNHeap nn = DBIDUtil.newHeap(k); for(DBIDIter pA = ids.iter(); pA.valid(); pA.advance()) { final double simAA = kernelMatrix.getSimilarity(pA, pA); // Choose the k-min nearest nn.clear(); for(DBIDIter nB = relation.iterDBIDs(); nB.valid(); nB.advance()) { if(DBIDUtil.equal(nB, pA)) { continue; } double simBB = kernelMatrix.getSimilarity(nB, nB); double simAB = kernelMatrix.getSimilarity(pA, nB); double sqdAB = simAA + simBB - simAB - simAB; if(!(sqdAB > 0.)) { continue; } nn.insert(sqdAB, nB); } KNNList nl = nn.toKNNList(); s.reset(); DoubleDBIDListIter iB = nl.iter(), iC = nl.iter(); for(; iB.valid(); iB.advance()) { double sqdAB = iB.doubleValue(); double simAB = kernelMatrix.getSimilarity(pA, iB); if(!(sqdAB > 0.)) { continue; } for(iC.seek(iB.getOffset() + 1); iC.valid(); iC.advance()) { double sqdAC = iC.doubleValue(); double simAC = kernelMatrix.getSimilarity(pA, iC); if(!(sqdAC > 0.)) { continue; } // Exploit bilinearity of scalar product: // <B-A, C-A> = <B, C-A> - <A,C-A> // = <B,C> - <B,A> - <A,C> + <A,A> double simBC = kernelMatrix.getSimilarity(iB, iC); double numerator = simBC - simAB - simAC + simAA; double div = 1. / (sqdAB * sqdAC); s.put(numerator * div, FastMath.sqrt(div)); } } final double abof = s.getNaiveVariance(); minmaxabod.put(abof); abodvalues.putDouble(pA, abof); } }
java
private void fastABOD(Database db, Relation<V> relation, DBIDs ids, WritableDoubleDataStore abodvalues, DoubleMinMax minmaxabod) { // Build a kernel matrix, to make O(n^3) slightly less bad. SimilarityQuery<V> sq = db.getSimilarityQuery(relation, kernelFunction); KernelMatrix kernelMatrix = new KernelMatrix(sq, relation, ids); MeanVariance s = new MeanVariance(); KNNHeap nn = DBIDUtil.newHeap(k); for(DBIDIter pA = ids.iter(); pA.valid(); pA.advance()) { final double simAA = kernelMatrix.getSimilarity(pA, pA); // Choose the k-min nearest nn.clear(); for(DBIDIter nB = relation.iterDBIDs(); nB.valid(); nB.advance()) { if(DBIDUtil.equal(nB, pA)) { continue; } double simBB = kernelMatrix.getSimilarity(nB, nB); double simAB = kernelMatrix.getSimilarity(pA, nB); double sqdAB = simAA + simBB - simAB - simAB; if(!(sqdAB > 0.)) { continue; } nn.insert(sqdAB, nB); } KNNList nl = nn.toKNNList(); s.reset(); DoubleDBIDListIter iB = nl.iter(), iC = nl.iter(); for(; iB.valid(); iB.advance()) { double sqdAB = iB.doubleValue(); double simAB = kernelMatrix.getSimilarity(pA, iB); if(!(sqdAB > 0.)) { continue; } for(iC.seek(iB.getOffset() + 1); iC.valid(); iC.advance()) { double sqdAC = iC.doubleValue(); double simAC = kernelMatrix.getSimilarity(pA, iC); if(!(sqdAC > 0.)) { continue; } // Exploit bilinearity of scalar product: // <B-A, C-A> = <B, C-A> - <A,C-A> // = <B,C> - <B,A> - <A,C> + <A,A> double simBC = kernelMatrix.getSimilarity(iB, iC); double numerator = simBC - simAB - simAC + simAA; double div = 1. / (sqdAB * sqdAC); s.put(numerator * div, FastMath.sqrt(div)); } } final double abof = s.getNaiveVariance(); minmaxabod.put(abof); abodvalues.putDouble(pA, abof); } }
[ "private", "void", "fastABOD", "(", "Database", "db", ",", "Relation", "<", "V", ">", "relation", ",", "DBIDs", "ids", ",", "WritableDoubleDataStore", "abodvalues", ",", "DoubleMinMax", "minmaxabod", ")", "{", "// Build a kernel matrix, to make O(n^3) slightly less bad....
Full kernel-based version. @param db Database @param relation Data relation @param ids IDs @param abodvalues Score storage @param minmaxabod Min/max storage
[ "Full", "kernel", "-", "based", "version", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/anglebased/FastABOD.java#L211-L264
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/weightfunctions/ErfcStddevWeight.java
ErfcStddevWeight.getWeight
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } return NormalDistribution.erfc(MathUtil.SQRTHALF * distance / stddev); }
java
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } return NormalDistribution.erfc(MathUtil.SQRTHALF * distance / stddev); }
[ "@", "Override", "public", "double", "getWeight", "(", "double", "distance", ",", "double", "max", ",", "double", "stddev", ")", "{", "if", "(", "stddev", "<=", "0", ")", "{", "return", "1", ";", "}", "return", "NormalDistribution", ".", "erfc", "(", "...
Return Erfc weight, scaled by standard deviation. max is ignored.
[ "Return", "Erfc", "weight", "scaled", "by", "standard", "deviation", ".", "max", "is", "ignored", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/weightfunctions/ErfcStddevWeight.java#L39-L45
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java
LOF.run
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress("LOF", 3) : null; DBIDs ids = relation.getDBIDs(); LOG.beginStep(stepprog, 1, "Materializing nearest-neighbor sets."); KNNQuery<O> knnq = DatabaseUtil.precomputedKNNQuery(database, relation, getDistanceFunction(), k); // Compute LRDs LOG.beginStep(stepprog, 2, "Computing Local Reachability Densities (LRD)."); WritableDoubleDataStore lrds = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); computeLRDs(knnq, ids, lrds); // compute LOF_SCORE of each db object LOG.beginStep(stepprog, 3, "Computing Local Outlier Factors (LOF)."); WritableDoubleDataStore lofs = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); // track the maximum value for normalization. DoubleMinMax lofminmax = new DoubleMinMax(); computeLOFScores(knnq, ids, lrds, lofs, lofminmax); LOG.setCompleted(stepprog); // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Local Outlier Factor", "lof-outlier", lofs, ids); OutlierScoreMeta scoreMeta = new QuotientOutlierScoreMeta(lofminmax.getMin(), lofminmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 1.0); return new OutlierResult(scoreMeta, scoreResult); }
java
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress("LOF", 3) : null; DBIDs ids = relation.getDBIDs(); LOG.beginStep(stepprog, 1, "Materializing nearest-neighbor sets."); KNNQuery<O> knnq = DatabaseUtil.precomputedKNNQuery(database, relation, getDistanceFunction(), k); // Compute LRDs LOG.beginStep(stepprog, 2, "Computing Local Reachability Densities (LRD)."); WritableDoubleDataStore lrds = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); computeLRDs(knnq, ids, lrds); // compute LOF_SCORE of each db object LOG.beginStep(stepprog, 3, "Computing Local Outlier Factors (LOF)."); WritableDoubleDataStore lofs = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); // track the maximum value for normalization. DoubleMinMax lofminmax = new DoubleMinMax(); computeLOFScores(knnq, ids, lrds, lofs, lofminmax); LOG.setCompleted(stepprog); // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Local Outlier Factor", "lof-outlier", lofs, ids); OutlierScoreMeta scoreMeta = new QuotientOutlierScoreMeta(lofminmax.getMin(), lofminmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 1.0); return new OutlierResult(scoreMeta, scoreResult); }
[ "public", "OutlierResult", "run", "(", "Database", "database", ",", "Relation", "<", "O", ">", "relation", ")", "{", "StepProgress", "stepprog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "StepProgress", "(", "\"LOF\"", ",", "3", ")", ":", "null...
Runs the LOF algorithm on the given database. @param database Database to query @param relation Data to process @return LOF outlier result
[ "Runs", "the", "LOF", "algorithm", "on", "the", "given", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java#L125-L150
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java
LOF.computeLRDs
private void computeLRDs(KNNQuery<O> knnq, DBIDs ids, WritableDoubleDataStore lrds) { FiniteProgress lrdsProgress = LOG.isVerbose() ? new FiniteProgress("Local Reachability Densities (LRD)", ids.size(), LOG) : null; double lrd; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { lrd = computeLRD(knnq, iter); lrds.putDouble(iter, lrd); LOG.incrementProcessed(lrdsProgress); } LOG.ensureCompleted(lrdsProgress); }
java
private void computeLRDs(KNNQuery<O> knnq, DBIDs ids, WritableDoubleDataStore lrds) { FiniteProgress lrdsProgress = LOG.isVerbose() ? new FiniteProgress("Local Reachability Densities (LRD)", ids.size(), LOG) : null; double lrd; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { lrd = computeLRD(knnq, iter); lrds.putDouble(iter, lrd); LOG.incrementProcessed(lrdsProgress); } LOG.ensureCompleted(lrdsProgress); }
[ "private", "void", "computeLRDs", "(", "KNNQuery", "<", "O", ">", "knnq", ",", "DBIDs", "ids", ",", "WritableDoubleDataStore", "lrds", ")", "{", "FiniteProgress", "lrdsProgress", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "FiniteProgress", "(", "\"L...
Compute local reachability distances. @param knnq KNN query @param ids IDs to process @param lrds Reachability storage
[ "Compute", "local", "reachability", "distances", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java#L159-L168
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java
LOF.computeLRD
protected double computeLRD(KNNQuery<O> knnq, DBIDIter curr) { final KNNList neighbors = knnq.getKNNForDBID(curr, k); double sum = 0.0; int count = 0; for(DoubleDBIDListIter neighbor = neighbors.iter(); neighbor.valid(); neighbor.advance()) { if(DBIDUtil.equal(curr, neighbor)) { continue; } KNNList neighborsNeighbors = knnq.getKNNForDBID(neighbor, k); sum += MathUtil.max(neighbor.doubleValue(), neighborsNeighbors.getKNNDistance()); count++; } // Avoid division by 0 return (sum > 0) ? (count / sum) : Double.POSITIVE_INFINITY; }
java
protected double computeLRD(KNNQuery<O> knnq, DBIDIter curr) { final KNNList neighbors = knnq.getKNNForDBID(curr, k); double sum = 0.0; int count = 0; for(DoubleDBIDListIter neighbor = neighbors.iter(); neighbor.valid(); neighbor.advance()) { if(DBIDUtil.equal(curr, neighbor)) { continue; } KNNList neighborsNeighbors = knnq.getKNNForDBID(neighbor, k); sum += MathUtil.max(neighbor.doubleValue(), neighborsNeighbors.getKNNDistance()); count++; } // Avoid division by 0 return (sum > 0) ? (count / sum) : Double.POSITIVE_INFINITY; }
[ "protected", "double", "computeLRD", "(", "KNNQuery", "<", "O", ">", "knnq", ",", "DBIDIter", "curr", ")", "{", "final", "KNNList", "neighbors", "=", "knnq", ".", "getKNNForDBID", "(", "curr", ",", "k", ")", ";", "double", "sum", "=", "0.0", ";", "int"...
Compute a single local reachability distance. @param knnq kNN Query @param curr Current object @return Local Reachability Density
[ "Compute", "a", "single", "local", "reachability", "distance", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java#L177-L191
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java
LOF.computeLOFScores
private void computeLOFScores(KNNQuery<O> knnq, DBIDs ids, DoubleDataStore lrds, WritableDoubleDataStore lofs, DoubleMinMax lofminmax) { FiniteProgress progressLOFs = LOG.isVerbose() ? new FiniteProgress("Local Outlier Factor (LOF) scores", ids.size(), LOG) : null; double lof; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { lof = computeLOFScore(knnq, iter, lrds); lofs.putDouble(iter, lof); // update minimum and maximum lofminmax.put(lof); LOG.incrementProcessed(progressLOFs); } LOG.ensureCompleted(progressLOFs); }
java
private void computeLOFScores(KNNQuery<O> knnq, DBIDs ids, DoubleDataStore lrds, WritableDoubleDataStore lofs, DoubleMinMax lofminmax) { FiniteProgress progressLOFs = LOG.isVerbose() ? new FiniteProgress("Local Outlier Factor (LOF) scores", ids.size(), LOG) : null; double lof; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { lof = computeLOFScore(knnq, iter, lrds); lofs.putDouble(iter, lof); // update minimum and maximum lofminmax.put(lof); LOG.incrementProcessed(progressLOFs); } LOG.ensureCompleted(progressLOFs); }
[ "private", "void", "computeLOFScores", "(", "KNNQuery", "<", "O", ">", "knnq", ",", "DBIDs", "ids", ",", "DoubleDataStore", "lrds", ",", "WritableDoubleDataStore", "lofs", ",", "DoubleMinMax", "lofminmax", ")", "{", "FiniteProgress", "progressLOFs", "=", "LOG", ...
Compute local outlier factors. @param knnq KNN query @param ids IDs to process @param lrds Local reachability distances @param lofs Local outlier factor storage @param lofminmax Score minimum/maximum tracker
[ "Compute", "local", "outlier", "factors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java#L202-L213
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java
LOF.computeLOFScore
protected double computeLOFScore(KNNQuery<O> knnq, DBIDRef cur, DoubleDataStore lrds) { final double lrdp = lrds.doubleValue(cur); if(Double.isInfinite(lrdp)) { return 1.0; } double sum = 0.; int count = 0; final KNNList neighbors = knnq.getKNNForDBID(cur, k); for(DBIDIter neighbor = neighbors.iter(); neighbor.valid(); neighbor.advance()) { // skip the point itself if(DBIDUtil.equal(cur, neighbor)) { continue; } sum += lrds.doubleValue(neighbor); ++count; } return sum / (lrdp * count); }
java
protected double computeLOFScore(KNNQuery<O> knnq, DBIDRef cur, DoubleDataStore lrds) { final double lrdp = lrds.doubleValue(cur); if(Double.isInfinite(lrdp)) { return 1.0; } double sum = 0.; int count = 0; final KNNList neighbors = knnq.getKNNForDBID(cur, k); for(DBIDIter neighbor = neighbors.iter(); neighbor.valid(); neighbor.advance()) { // skip the point itself if(DBIDUtil.equal(cur, neighbor)) { continue; } sum += lrds.doubleValue(neighbor); ++count; } return sum / (lrdp * count); }
[ "protected", "double", "computeLOFScore", "(", "KNNQuery", "<", "O", ">", "knnq", ",", "DBIDRef", "cur", ",", "DoubleDataStore", "lrds", ")", "{", "final", "double", "lrdp", "=", "lrds", ".", "doubleValue", "(", "cur", ")", ";", "if", "(", "Double", ".",...
Compute a single LOF score. @param knnq kNN query @param cur Current object @param lrds Stored reachability densities @return LOF score.
[ "Compute", "a", "single", "LOF", "score", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LOF.java#L223-L240
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNNode.java
RdKNNNode.kNNDistance
protected double kNNDistance() { double result = getEntry(0).getKnnDistance(); for(int i = 1; i < getNumEntries(); i++) { double knnDistance = getEntry(i).getKnnDistance(); result = (result < knnDistance) ? knnDistance : result; } return result; }
java
protected double kNNDistance() { double result = getEntry(0).getKnnDistance(); for(int i = 1; i < getNumEntries(); i++) { double knnDistance = getEntry(i).getKnnDistance(); result = (result < knnDistance) ? knnDistance : result; } return result; }
[ "protected", "double", "kNNDistance", "(", ")", "{", "double", "result", "=", "getEntry", "(", "0", ")", ".", "getKnnDistance", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "getNumEntries", "(", ")", ";", "i", "++", ")", "{", "...
Computes and returns the aggregated knn distance of this node @return the aggregated knn distance of this node
[ "Computes", "and", "returns", "the", "aggregated", "knn", "distance", "of", "this", "node" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNNode.java#L59-L66
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/LineReader.java
LineReader.readLine
public boolean readLine(Appendable buf) throws IOException { boolean success = false; while(true) { // Process buffer: while(pos < end) { success = true; final char c = buffer[pos++]; if(c == '\n') { return success; } if(c == '\r') { continue; } buf.append(c); } // Refill buffer: assert (pos >= end) : "Buffer wasn't empty when refilling!"; end = in.read(buffer, 0, buffer.length); pos = 0; if(end < 0) { // End of stream. return success; } } }
java
public boolean readLine(Appendable buf) throws IOException { boolean success = false; while(true) { // Process buffer: while(pos < end) { success = true; final char c = buffer[pos++]; if(c == '\n') { return success; } if(c == '\r') { continue; } buf.append(c); } // Refill buffer: assert (pos >= end) : "Buffer wasn't empty when refilling!"; end = in.read(buffer, 0, buffer.length); pos = 0; if(end < 0) { // End of stream. return success; } } }
[ "public", "boolean", "readLine", "(", "Appendable", "buf", ")", "throws", "IOException", "{", "boolean", "success", "=", "false", ";", "while", "(", "true", ")", "{", "// Process buffer:", "while", "(", "pos", "<", "end", ")", "{", "success", "=", "true", ...
Read a line into the given buffer. @param buf Buffer. @return {@code true} if some characters have been read.
[ "Read", "a", "line", "into", "the", "given", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/LineReader.java#L118-L141
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/QuickSelect.java
QuickSelect.bestPivot
private static final int bestPivot(int rank, int m1, int m2, int m3, int m4, int m5) { if(rank < m1) { return m1; } if(rank > m5) { return m5; } if(rank < m2) { return m2; } if(rank > m4) { return m4; } return m3; }
java
private static final int bestPivot(int rank, int m1, int m2, int m3, int m4, int m5) { if(rank < m1) { return m1; } if(rank > m5) { return m5; } if(rank < m2) { return m2; } if(rank > m4) { return m4; } return m3; }
[ "private", "static", "final", "int", "bestPivot", "(", "int", "rank", ",", "int", "m1", ",", "int", "m2", ",", "int", "m3", ",", "int", "m4", ",", "int", "m5", ")", "{", "if", "(", "rank", "<", "m1", ")", "{", "return", "m1", ";", "}", "if", ...
Choose the best pivot for the given rank. @param rank Rank @param m1 Pivot candidate @param m2 Pivot candidate @param m3 Pivot candidate @param m4 Pivot candidate @param m5 Pivot candidate @return Best pivot candidate
[ "Choose", "the", "best", "pivot", "for", "the", "given", "rank", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/QuickSelect.java#L69-L83
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mktab/MkTabLeafEntry.java
MkTabLeafEntry.writeExternal
@Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); int k_max = knnDistances.length; out.writeInt(k_max); for(int i = 0; i < k_max; i++) { out.writeDouble(knnDistances[i]); } }
java
@Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); int k_max = knnDistances.length; out.writeInt(k_max); for(int i = 0; i < k_max; i++) { out.writeDouble(knnDistances[i]); } }
[ "@", "Override", "public", "void", "writeExternal", "(", "ObjectOutput", "out", ")", "throws", "IOException", "{", "super", ".", "writeExternal", "(", "out", ")", ";", "int", "k_max", "=", "knnDistances", ".", "length", ";", "out", ".", "writeInt", "(", "k...
Calls the super method and writes the parameter k_max and the knn distances of this entry to the specified stream. @param out the stream to write the object to @throws java.io.IOException Includes any I/O exceptions that may occur
[ "Calls", "the", "super", "method", "and", "writes", "the", "parameter", "k_max", "and", "the", "knn", "distances", "of", "this", "entry", "to", "the", "specified", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mktab/MkTabLeafEntry.java#L96-L104
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mktab/MkTabLeafEntry.java
MkTabLeafEntry.readExternal
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); int k_max = in.readInt(); knnDistances = new double[k_max]; for(int i = 0; i < k_max; i++) { knnDistances[i] = in.readDouble(); } }
java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); int k_max = in.readInt(); knnDistances = new double[k_max]; for(int i = 0; i < k_max; i++) { knnDistances[i] = in.readDouble(); } }
[ "@", "Override", "public", "void", "readExternal", "(", "ObjectInput", "in", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "super", ".", "readExternal", "(", "in", ")", ";", "int", "k_max", "=", "in", ".", "readInt", "(", ")", ";", "knn...
Calls the super method and reads the parameter k_max and knn distance of this entry from the specified input stream. @param in the stream to read data from in order to restore the object @throws java.io.IOException if I/O errors occur @throws ClassNotFoundException If the class for an object being restored cannot be found.
[ "Calls", "the", "super", "method", "and", "reads", "the", "parameter", "k_max", "and", "knn", "distance", "of", "this", "entry", "from", "the", "specified", "input", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mktab/MkTabLeafEntry.java#L115-L123
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/ApproximationLine.java
ApproximationLine.getValueAt
public double getValueAt(int k) { if (k < k_0) { return Double.POSITIVE_INFINITY; } return m * FastMath.log(k) + t; }
java
public double getValueAt(int k) { if (k < k_0) { return Double.POSITIVE_INFINITY; } return m * FastMath.log(k) + t; }
[ "public", "double", "getValueAt", "(", "int", "k", ")", "{", "if", "(", "k", "<", "k_0", ")", "{", "return", "Double", ".", "POSITIVE_INFINITY", ";", "}", "return", "m", "*", "FastMath", ".", "log", "(", "k", ")", "+", "t", ";", "}" ]
Returns the function value of the approximation line at the specified k. @param k the value for which the function value of the approximation line should be returned @return the function value of the approximation line at the specified k
[ "Returns", "the", "function", "value", "of", "the", "approximation", "line", "at", "the", "specified", "k", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/ApproximationLine.java#L110-L115
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/fitting/LevenbergMarquardtMethod.java
LevenbergMarquardtMethod.iterate
public void iterate() { // build covmat out of fitting matrix by multiplying diagonal elements with // 1+lambda for(int i = 0; i < numfit; i++) { System.arraycopy(alpha[i], 0, covmat[i], 0, numfit); covmat[i][i] *= (1.0 + lambda); } // Solve the equation system (Gauss-Jordan) LinearEquationSystem ls = new LinearEquationSystem(covmat, beta); ls.solveByTotalPivotSearch(); // update covmat with the inverse covmat = ls.getCoefficents(); // and deltaparams with the solution vector deltaparams = ls.getRHS(); // deltaparams = beta; for(int i = 0, i2 = 0; i < numparams; i++) { if(dofit[i]) { paramstry[i] = params[i] + deltaparams[i2++]; } } double newchisq = simulateParameters(paramstry); // have the results improved? if(newchisq < chisq) { // TODO: Do we need a larger limit than MIN_NORMAL? if(lambda * 0.1 > Double.MIN_NORMAL) { lambda *= 0.1; } chisq = newchisq; // keep modified covmat as new alpha matrix // and da as new beta for(int i = 0; i < numfit; i++) { System.arraycopy(covmat[i], 0, alpha[i], 0, numfit); beta[i] = deltaparams[i]; } System.arraycopy(paramstry, 0, params, 0, numparams); } else { // TODO: Do we need a larger limit than MAX_VALUE? // Does it ever make sense to go as far up? // Anyway, this should prevent overflows. if(lambda * 10 < Double.MAX_VALUE) { lambda *= 10; } } }
java
public void iterate() { // build covmat out of fitting matrix by multiplying diagonal elements with // 1+lambda for(int i = 0; i < numfit; i++) { System.arraycopy(alpha[i], 0, covmat[i], 0, numfit); covmat[i][i] *= (1.0 + lambda); } // Solve the equation system (Gauss-Jordan) LinearEquationSystem ls = new LinearEquationSystem(covmat, beta); ls.solveByTotalPivotSearch(); // update covmat with the inverse covmat = ls.getCoefficents(); // and deltaparams with the solution vector deltaparams = ls.getRHS(); // deltaparams = beta; for(int i = 0, i2 = 0; i < numparams; i++) { if(dofit[i]) { paramstry[i] = params[i] + deltaparams[i2++]; } } double newchisq = simulateParameters(paramstry); // have the results improved? if(newchisq < chisq) { // TODO: Do we need a larger limit than MIN_NORMAL? if(lambda * 0.1 > Double.MIN_NORMAL) { lambda *= 0.1; } chisq = newchisq; // keep modified covmat as new alpha matrix // and da as new beta for(int i = 0; i < numfit; i++) { System.arraycopy(covmat[i], 0, alpha[i], 0, numfit); beta[i] = deltaparams[i]; } System.arraycopy(paramstry, 0, params, 0, numparams); } else { // TODO: Do we need a larger limit than MAX_VALUE? // Does it ever make sense to go as far up? // Anyway, this should prevent overflows. if(lambda * 10 < Double.MAX_VALUE) { lambda *= 10; } } }
[ "public", "void", "iterate", "(", ")", "{", "// build covmat out of fitting matrix by multiplying diagonal elements with", "// 1+lambda", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numfit", ";", "i", "++", ")", "{", "System", ".", "arraycopy", "(", "alpha...
Perform an iteration of the approximation loop.
[ "Perform", "an", "iteration", "of", "the", "approximation", "loop", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/fitting/LevenbergMarquardtMethod.java#L238-L282
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/fitting/LevenbergMarquardtMethod.java
LevenbergMarquardtMethod.run
public void run() { int maxruns = this.maxruns, maxsmall = this.maxsmall; double oldchi = getChiSq(); while(maxruns-- > 0) { iterate(); double newchi = getChiSq(), deltachi = newchi - oldchi; oldchi = newchi; // stop condition: only a small improvement in Chi. if(deltachi < 0 && deltachi > -small && --maxsmall < 0) { break; } } }
java
public void run() { int maxruns = this.maxruns, maxsmall = this.maxsmall; double oldchi = getChiSq(); while(maxruns-- > 0) { iterate(); double newchi = getChiSq(), deltachi = newchi - oldchi; oldchi = newchi; // stop condition: only a small improvement in Chi. if(deltachi < 0 && deltachi > -small && --maxsmall < 0) { break; } } }
[ "public", "void", "run", "(", ")", "{", "int", "maxruns", "=", "this", ".", "maxruns", ",", "maxsmall", "=", "this", ".", "maxsmall", ";", "double", "oldchi", "=", "getChiSq", "(", ")", ";", "while", "(", "maxruns", "--", ">", "0", ")", "{", "itera...
Iterate until convergence, at most 100 times.
[ "Iterate", "until", "convergence", "at", "most", "100", "times", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/fitting/LevenbergMarquardtMethod.java#L330-L342
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java
RectangleArranger.get
public double[] get(T object) { double[] v = map.get(object); if(v == null) { return null; } return v.clone(); }
java
public double[] get(T object) { double[] v = map.get(object); if(v == null) { return null; } return v.clone(); }
[ "public", "double", "[", "]", "get", "(", "T", "object", ")", "{", "double", "[", "]", "v", "=", "map", ".", "get", "(", "object", ")", ";", "if", "(", "v", "==", "null", ")", "{", "return", "null", ";", "}", "return", "v", ".", "clone", "(",...
Get the position data of the object @param object Query object @return Position information: x,y,w,h
[ "Get", "the", "position", "data", "of", "the", "object" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java#L380-L386
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java
RectangleArranger.relativeFill
public double relativeFill() { double acc = 0.0; final int cols = widths.size(); final int rows = heights.size(); { for(int y = 0; y < rows; y++) { for(int x = 0; x < cols; x++) { if(usage.get(y).get(x) != null) { acc += widths.get(x) * heights.get(y); } } } } return acc / (twidth * theight); }
java
public double relativeFill() { double acc = 0.0; final int cols = widths.size(); final int rows = heights.size(); { for(int y = 0; y < rows; y++) { for(int x = 0; x < cols; x++) { if(usage.get(y).get(x) != null) { acc += widths.get(x) * heights.get(y); } } } } return acc / (twidth * theight); }
[ "public", "double", "relativeFill", "(", ")", "{", "double", "acc", "=", "0.0", ";", "final", "int", "cols", "=", "widths", ".", "size", "(", ")", ";", "final", "int", "rows", "=", "heights", ".", "size", "(", ")", ";", "{", "for", "(", "int", "y...
Compute the relative fill. Useful for triggering a relayout if the relative fill is not satisfactory. @return relative fill
[ "Compute", "the", "relative", "fill", ".", "Useful", "for", "triggering", "a", "relayout", "if", "the", "relative", "fill", "is", "not", "satisfactory", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java#L464-L478
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java
CLIQUEUnit.contains
public boolean contains(NumberVector vector) { for(int i = 0; i < dims.length; i++) { final double value = vector.doubleValue(dims[i]); if(bounds[i << 1] > value || value >= bounds[(i << 1) + 1]) { return false; } } return true; }
java
public boolean contains(NumberVector vector) { for(int i = 0; i < dims.length; i++) { final double value = vector.doubleValue(dims[i]); if(bounds[i << 1] > value || value >= bounds[(i << 1) + 1]) { return false; } } return true; }
[ "public", "boolean", "contains", "(", "NumberVector", "vector", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dims", ".", "length", ";", "i", "++", ")", "{", "final", "double", "value", "=", "vector", ".", "doubleValue", "(", "dims", ...
Returns true, if the intervals of this unit contain the specified feature vector. @param vector the feature vector to be tested for containment @return true, if the intervals of this unit contain the specified feature vector, false otherwise
[ "Returns", "true", "if", "the", "intervals", "of", "this", "unit", "contain", "the", "specified", "feature", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java#L120-L128
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java
CLIQUEUnit.addFeatureVector
public boolean addFeatureVector(DBIDRef id, NumberVector vector) { if(contains(vector)) { ids.add(id); return true; } return false; }
java
public boolean addFeatureVector(DBIDRef id, NumberVector vector) { if(contains(vector)) { ids.add(id); return true; } return false; }
[ "public", "boolean", "addFeatureVector", "(", "DBIDRef", "id", ",", "NumberVector", "vector", ")", "{", "if", "(", "contains", "(", "vector", ")", ")", "{", "ids", ".", "add", "(", "id", ")", ";", "return", "true", ";", "}", "return", "false", ";", "...
Adds the id of the specified feature vector to this unit, if this unit contains the feature vector. @param id Vector id @param vector the feature vector to be added @return true, if this unit contains the specified feature vector, false otherwise
[ "Adds", "the", "id", "of", "the", "specified", "feature", "vector", "to", "this", "unit", "if", "this", "unit", "contains", "the", "feature", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java#L139-L145
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java
CLIQUEUnit.containsRightNeighbor
protected boolean containsRightNeighbor(CLIQUEUnit unit, int d) { final int e = dims.length - 1; return checkDimensions(unit, e) && bounds[e << 1] == unit.bounds[(e << 1) + 1]; }
java
protected boolean containsRightNeighbor(CLIQUEUnit unit, int d) { final int e = dims.length - 1; return checkDimensions(unit, e) && bounds[e << 1] == unit.bounds[(e << 1) + 1]; }
[ "protected", "boolean", "containsRightNeighbor", "(", "CLIQUEUnit", "unit", ",", "int", "d", ")", "{", "final", "int", "e", "=", "dims", ".", "length", "-", "1", ";", "return", "checkDimensions", "(", "unit", ",", "e", ")", "&&", "bounds", "[", "e", "<...
Returns true if this unit is the right neighbor of the given unit. @param unit Reference unit @param d Current dimension @return true if this unit is the right neighbor of the given unit
[ "Returns", "true", "if", "this", "unit", "is", "the", "right", "neighbor", "of", "the", "given", "unit", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java#L186-L189
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java
CLIQUEUnit.join
protected CLIQUEUnit join(CLIQUEUnit other, double all, double tau) { if(other.dimensionality() != this.dimensionality()) { return null; } // n-1 dimensions must be the same: int e = dims.length - 1; if(!checkDimensions(other, e)) { return null; } if(dims[e] >= other.dims[e]) { return null; } HashSetModifiableDBIDs resultIDs = DBIDUtil.newHashSet(this.ids); resultIDs.retainAll(other.ids); if(resultIDs.size() / all < tau) { return null; } return new CLIQUEUnit(this, other.dims[e], other.bounds[e << 1], other.bounds[(e << 1) + 1], resultIDs); }
java
protected CLIQUEUnit join(CLIQUEUnit other, double all, double tau) { if(other.dimensionality() != this.dimensionality()) { return null; } // n-1 dimensions must be the same: int e = dims.length - 1; if(!checkDimensions(other, e)) { return null; } if(dims[e] >= other.dims[e]) { return null; } HashSetModifiableDBIDs resultIDs = DBIDUtil.newHashSet(this.ids); resultIDs.retainAll(other.ids); if(resultIDs.size() / all < tau) { return null; } return new CLIQUEUnit(this, other.dims[e], other.bounds[e << 1], other.bounds[(e << 1) + 1], resultIDs); }
[ "protected", "CLIQUEUnit", "join", "(", "CLIQUEUnit", "other", ",", "double", "all", ",", "double", "tau", ")", "{", "if", "(", "other", ".", "dimensionality", "(", ")", "!=", "this", ".", "dimensionality", "(", ")", ")", "{", "return", "null", ";", "}...
Joins this unit with the specified unit. @param other the unit to be joined @param all the overall number of feature vectors @param tau the density threshold for the selectivity of a unit @return the joined unit if the selectivity of the join result is equal or greater than tau, null otherwise
[ "Joins", "this", "unit", "with", "the", "specified", "unit", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java#L226-L246
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java
CLIQUEUnit.checkDimensions
private boolean checkDimensions(CLIQUEUnit other, int e) { for(int i = 0, j = 0; i < e; i++, j += 2) { if(dims[i] != other.dims[i] || bounds[j] != other.bounds[j] || bounds[j + 1] != bounds[j + 1]) { return false; } } return true; }
java
private boolean checkDimensions(CLIQUEUnit other, int e) { for(int i = 0, j = 0; i < e; i++, j += 2) { if(dims[i] != other.dims[i] || bounds[j] != other.bounds[j] || bounds[j + 1] != bounds[j + 1]) { return false; } } return true; }
[ "private", "boolean", "checkDimensions", "(", "CLIQUEUnit", "other", ",", "int", "e", ")", "{", "for", "(", "int", "i", "=", "0", ",", "j", "=", "0", ";", "i", "<", "e", ";", "i", "++", ",", "j", "+=", "2", ")", "{", "if", "(", "dims", "[", ...
Check that the first e dimensions agree. @param other Other unit @param e Number of dimensions to check @return {@code true} if the first e dimensions are the same (index and bounds)
[ "Check", "that", "the", "first", "e", "dimensions", "agree", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUEUnit.java#L256-L263
train
elki-project/elki
elki-core-parallel/src/main/java/de/lmu/ifi/dbs/elki/parallel/processor/DoubleMinMaxProcessor.java
DoubleMinMaxProcessor.merge
protected synchronized void merge(DoubleMinMax minmax) { this.minmax.put(minmax.getMin()); this.minmax.put(minmax.getMax()); }
java
protected synchronized void merge(DoubleMinMax minmax) { this.minmax.put(minmax.getMin()); this.minmax.put(minmax.getMax()); }
[ "protected", "synchronized", "void", "merge", "(", "DoubleMinMax", "minmax", ")", "{", "this", ".", "minmax", ".", "put", "(", "minmax", ".", "getMin", "(", ")", ")", ";", "this", ".", "minmax", ".", "put", "(", "minmax", ".", "getMax", "(", ")", ")"...
Merge the result of an instance. @param minmax Minmax value
[ "Merge", "the", "result", "of", "an", "instance", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-parallel/src/main/java/de/lmu/ifi/dbs/elki/parallel/processor/DoubleMinMaxProcessor.java#L80-L83
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.enableStart
public void enableStart() { EventTarget targ = (EventTarget) element; targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEDOWN, this, false); }
java
public void enableStart() { EventTarget targ = (EventTarget) element; targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEDOWN, this, false); }
[ "public", "void", "enableStart", "(", ")", "{", "EventTarget", "targ", "=", "(", "EventTarget", ")", "element", ";", "targ", ".", "addEventListener", "(", "SVGConstants", ".", "SVG_EVENT_MOUSEDOWN", ",", "this", ",", "false", ")", ";", "}" ]
Enable capturing of 'mousedown' events.
[ "Enable", "capturing", "of", "mousedown", "events", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L172-L175
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.disableStart
public void disableStart() { EventTarget targ = (EventTarget) element; targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEDOWN, this, false); }
java
public void disableStart() { EventTarget targ = (EventTarget) element; targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEDOWN, this, false); }
[ "public", "void", "disableStart", "(", ")", "{", "EventTarget", "targ", "=", "(", "EventTarget", ")", "element", ";", "targ", ".", "removeEventListener", "(", "SVGConstants", ".", "SVG_EVENT_MOUSEDOWN", ",", "this", ",", "false", ")", ";", "}" ]
Disable capturing of 'mousedown' events.
[ "Disable", "capturing", "of", "mousedown", "events", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L180-L183
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.enableStop
protected void enableStop() { EventTarget targ = svgp.getDocument().getRootElement(); targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEMOVE, this, false); targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEUP, this, false); // FIXME: listen on the background object! targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEOUT, this, false); }
java
protected void enableStop() { EventTarget targ = svgp.getDocument().getRootElement(); targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEMOVE, this, false); targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEUP, this, false); // FIXME: listen on the background object! targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEOUT, this, false); }
[ "protected", "void", "enableStop", "(", ")", "{", "EventTarget", "targ", "=", "svgp", ".", "getDocument", "(", ")", ".", "getRootElement", "(", ")", ";", "targ", ".", "addEventListener", "(", "SVGConstants", ".", "SVG_EVENT_MOUSEMOVE", ",", "this", ",", "fal...
Enable capturing of 'mousemove' and 'mouseup' events.
[ "Enable", "capturing", "of", "mousemove", "and", "mouseup", "events", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L188-L194
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.disableStop
protected void disableStop() { EventTarget targ = svgp.getDocument().getRootElement(); targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEMOVE, this, false); targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEUP, this, false); // FIXME: listen on the background object! targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEOUT, this, false); }
java
protected void disableStop() { EventTarget targ = svgp.getDocument().getRootElement(); targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEMOVE, this, false); targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEUP, this, false); // FIXME: listen on the background object! targ.removeEventListener(SVGConstants.SVG_EVENT_MOUSEOUT, this, false); }
[ "protected", "void", "disableStop", "(", ")", "{", "EventTarget", "targ", "=", "svgp", ".", "getDocument", "(", ")", ".", "getRootElement", "(", ")", ";", "targ", ".", "removeEventListener", "(", "SVGConstants", ".", "SVG_EVENT_MOUSEMOVE", ",", "this", ",", ...
Disable capturing of 'mousemove' and 'mouseup' events.
[ "Disable", "capturing", "of", "mousemove", "and", "mouseup", "events", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L199-L205
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.getCoordinates
protected SVGPoint getCoordinates(Event evt) { return SVGUtil.elementCoordinatesFromEvent(this.svgp.getDocument(), this.coordref, evt); }
java
protected SVGPoint getCoordinates(Event evt) { return SVGUtil.elementCoordinatesFromEvent(this.svgp.getDocument(), this.coordref, evt); }
[ "protected", "SVGPoint", "getCoordinates", "(", "Event", "evt", ")", "{", "return", "SVGUtil", ".", "elementCoordinatesFromEvent", "(", "this", ".", "svgp", ".", "getDocument", "(", ")", ",", "this", ".", "coordref", ",", "evt", ")", ";", "}" ]
Return the event coordinates for this event. @param evt Event @return Coordinates
[ "Return", "the", "event", "coordinates", "for", "this", "event", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L256-L258
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.startDrag
protected boolean startDrag(SVGPoint startPoint, Event evt) { if (listener != null) { return listener.startDrag(startPoint, evt); } return true; }
java
protected boolean startDrag(SVGPoint startPoint, Event evt) { if (listener != null) { return listener.startDrag(startPoint, evt); } return true; }
[ "protected", "boolean", "startDrag", "(", "SVGPoint", "startPoint", ",", "Event", "evt", ")", "{", "if", "(", "listener", "!=", "null", ")", "{", "return", "listener", ".", "startDrag", "(", "startPoint", ",", "evt", ")", ";", "}", "return", "true", ";",...
Action to do on drag start. @param startPoint Point where the drag was started. @param evt The event object @return {@code true} to start the drag operation
[ "Action", "to", "do", "on", "drag", "start", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L267-L272
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.duringDrag
protected boolean duringDrag(SVGPoint startPoint, SVGPoint dragPoint, Event evt, boolean inside) { if (listener != null) { return listener.duringDrag(startPoint, dragPoint, evt, inside); } return true; }
java
protected boolean duringDrag(SVGPoint startPoint, SVGPoint dragPoint, Event evt, boolean inside) { if (listener != null) { return listener.duringDrag(startPoint, dragPoint, evt, inside); } return true; }
[ "protected", "boolean", "duringDrag", "(", "SVGPoint", "startPoint", ",", "SVGPoint", "dragPoint", ",", "Event", "evt", ",", "boolean", "inside", ")", "{", "if", "(", "listener", "!=", "null", ")", "{", "return", "listener", ".", "duringDrag", "(", "startPoi...
Method called during drags. @param startPoint Drag starting point @param dragPoint Drag end point @param evt The event object @param inside Inside the tracked element @return {@code true} to continue the drag
[ "Method", "called", "during", "drags", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L283-L288
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.makeInvisible
public void makeInvisible() { CSSClass cls = new CSSClass(this, "unused"); cls.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0"); cls.setStatement(SVGConstants.CSS_CURSOR_PROPERTY, SVGConstants.CSS_POINTER_VALUE); SVGUtil.setAtt(element, SVGConstants.SVG_STYLE_ATTRIBUTE, cls.inlineCSS()); }
java
public void makeInvisible() { CSSClass cls = new CSSClass(this, "unused"); cls.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0"); cls.setStatement(SVGConstants.CSS_CURSOR_PROPERTY, SVGConstants.CSS_POINTER_VALUE); SVGUtil.setAtt(element, SVGConstants.SVG_STYLE_ATTRIBUTE, cls.inlineCSS()); }
[ "public", "void", "makeInvisible", "(", ")", "{", "CSSClass", "cls", "=", "new", "CSSClass", "(", "this", ",", "\"unused\"", ")", ";", "cls", ".", "setStatement", "(", "SVGConstants", ".", "CSS_FILL_OPACITY_PROPERTY", ",", "\"0\"", ")", ";", "cls", ".", "s...
Make the rectangle invisible.
[ "Make", "the", "rectangle", "invisible", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L309-L314
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java
DragableArea.makeVisible
public void makeVisible() { CSSClass cls = new CSSClass(this, "unused"); cls.setStatement(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_GREEN_VALUE); cls.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0.2"); cls.setStatement(SVGConstants.CSS_CURSOR_PROPERTY, SVGConstants.CSS_POINTER_VALUE); SVGUtil.setAtt(element, SVGConstants.SVG_STYLE_ATTRIBUTE, cls.inlineCSS()); }
java
public void makeVisible() { CSSClass cls = new CSSClass(this, "unused"); cls.setStatement(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_GREEN_VALUE); cls.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0.2"); cls.setStatement(SVGConstants.CSS_CURSOR_PROPERTY, SVGConstants.CSS_POINTER_VALUE); SVGUtil.setAtt(element, SVGConstants.SVG_STYLE_ATTRIBUTE, cls.inlineCSS()); }
[ "public", "void", "makeVisible", "(", ")", "{", "CSSClass", "cls", "=", "new", "CSSClass", "(", "this", ",", "\"unused\"", ")", ";", "cls", ".", "setStatement", "(", "SVGConstants", ".", "CSS_FILL_PROPERTY", ",", "SVGConstants", ".", "CSS_GREEN_VALUE", ")", ...
Make the rectangle visible, for debug purposes.
[ "Make", "the", "rectangle", "visible", "for", "debug", "purposes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/DragableArea.java#L319-L325
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGScoreBar.java
SVGScoreBar.setFill
public void setFill(double val, double min, double max) { this.val = val; this.min = min; this.max = max; }
java
public void setFill(double val, double min, double max) { this.val = val; this.min = min; this.max = max; }
[ "public", "void", "setFill", "(", "double", "val", ",", "double", "min", ",", "double", "max", ")", "{", "this", ".", "val", "=", "val", ";", "this", ".", "min", "=", "min", ";", "this", ".", "max", "=", "max", ";", "}" ]
Set the fill of the score bar. @param val Value @param min Minimum value @param max Maximum value
[ "Set", "the", "fill", "of", "the", "score", "bar", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGScoreBar.java#L71-L75
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGScoreBar.java
SVGScoreBar.build
public Element build(SVGPlot svgp, double x, double y, double width, double height) { Element barchart = svgp.svgElement(SVGConstants.SVG_G_TAG); // TODO: use style library for colors! Element bar = svgp.svgRect(x, y, width, height); bar.setAttribute(SVGConstants.SVG_FILL_ATTRIBUTE, "#a0a0a0"); bar.setAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE, "#a0a0a0"); bar.setAttribute(SVGConstants.SVG_STROKE_WIDTH_ATTRIBUTE, String.valueOf(height * 0.01)); barchart.appendChild(bar); if(val >= min && val <= max && min < max) { final double frame = 0.02 * height; double fpos = (val - min) / (max - min) * (width - 2 * frame); Element chart; if(reversed) { chart = svgp.svgRect(x + frame + fpos, y + frame, width - fpos - 2 * frame, height - 2 * frame); } else { chart = svgp.svgRect(x + frame, y + frame, fpos, height - 2 * frame); } chart.setAttribute(SVGConstants.SVG_FILL_ATTRIBUTE, "#d4e4f1"); chart.setAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE, "#a0a0a0"); chart.setAttribute(SVGConstants.SVG_STROKE_WIDTH_ATTRIBUTE, String.valueOf(height * 0.01)); barchart.appendChild(chart); } // Draw the values: if(format != null) { String num = Double.isNaN(val) ? "NaN" : format.format(val); Element lbl = svgp.svgText(x + 0.05 * width, y + 0.75 * height, num); lbl.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, "font-size: " + 0.75 * height + "; font-weight: bold"); barchart.appendChild(lbl); } // Draw the label if(label != null) { Element lbl = svgp.svgText(x + 1.05 * width, y + 0.75 * height, label); lbl.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, "font-size: " + 0.75 * height + "; font-weight: normal"); barchart.appendChild(lbl); } return barchart; }
java
public Element build(SVGPlot svgp, double x, double y, double width, double height) { Element barchart = svgp.svgElement(SVGConstants.SVG_G_TAG); // TODO: use style library for colors! Element bar = svgp.svgRect(x, y, width, height); bar.setAttribute(SVGConstants.SVG_FILL_ATTRIBUTE, "#a0a0a0"); bar.setAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE, "#a0a0a0"); bar.setAttribute(SVGConstants.SVG_STROKE_WIDTH_ATTRIBUTE, String.valueOf(height * 0.01)); barchart.appendChild(bar); if(val >= min && val <= max && min < max) { final double frame = 0.02 * height; double fpos = (val - min) / (max - min) * (width - 2 * frame); Element chart; if(reversed) { chart = svgp.svgRect(x + frame + fpos, y + frame, width - fpos - 2 * frame, height - 2 * frame); } else { chart = svgp.svgRect(x + frame, y + frame, fpos, height - 2 * frame); } chart.setAttribute(SVGConstants.SVG_FILL_ATTRIBUTE, "#d4e4f1"); chart.setAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE, "#a0a0a0"); chart.setAttribute(SVGConstants.SVG_STROKE_WIDTH_ATTRIBUTE, String.valueOf(height * 0.01)); barchart.appendChild(chart); } // Draw the values: if(format != null) { String num = Double.isNaN(val) ? "NaN" : format.format(val); Element lbl = svgp.svgText(x + 0.05 * width, y + 0.75 * height, num); lbl.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, "font-size: " + 0.75 * height + "; font-weight: bold"); barchart.appendChild(lbl); } // Draw the label if(label != null) { Element lbl = svgp.svgText(x + 1.05 * width, y + 0.75 * height, label); lbl.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, "font-size: " + 0.75 * height + "; font-weight: normal"); barchart.appendChild(lbl); } return barchart; }
[ "public", "Element", "build", "(", "SVGPlot", "svgp", ",", "double", "x", ",", "double", "y", ",", "double", "width", ",", "double", "height", ")", "{", "Element", "barchart", "=", "svgp", ".", "svgElement", "(", "SVGConstants", ".", "SVG_G_TAG", ")", ";...
Build the actual element @param svgp Plot to draw to @param x X coordinate @param y Y coordinate @param width Width @param height Height @return new element
[ "Build", "the", "actual", "element" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGScoreBar.java#L114-L155
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleReader.java
BundleReader.openBuffer
void openBuffer() { if(buffer == null) { try { buffer = input.map(MapMode.READ_ONLY, 0, input.size()); } catch(IOException e) { throw new AbortException("Cannot map input bundle.", e); } } }
java
void openBuffer() { if(buffer == null) { try { buffer = input.map(MapMode.READ_ONLY, 0, input.size()); } catch(IOException e) { throw new AbortException("Cannot map input bundle.", e); } } }
[ "void", "openBuffer", "(", ")", "{", "if", "(", "buffer", "==", "null", ")", "{", "try", "{", "buffer", "=", "input", ".", "map", "(", "MapMode", ".", "READ_ONLY", ",", "0", ",", "input", ".", "size", "(", ")", ")", ";", "}", "catch", "(", "IOE...
Map the input file.
[ "Map", "the", "input", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleReader.java#L116-L125
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleReader.java
BundleReader.readMeta
void readMeta() { final int check = buffer.getInt(); if(check != MAGIC) { throw new AbortException("File does not start with expected magic."); } final int nummeta = buffer.getInt(); assert (nummeta > 0) : "Empty bundle?"; meta = new BundleMeta(nummeta); sers = new ByteBufferSerializer<?>[nummeta]; data = new Object[nummeta]; for(int i = 0; i < nummeta; i++) { try { @SuppressWarnings("unchecked") SimpleTypeInformation<? extends Object> type = (SimpleTypeInformation<? extends Object>) TypeInformationSerializer.STATIC.fromByteBuffer(buffer); sers[i] = type.getSerializer(); if(i == 0 && DBID.class.isAssignableFrom(type.getRestrictionClass())) { hasids = true; } else { meta.add(type); } } catch(UnsupportedOperationException e) { throw new AbortException("Deserialization failed: " + e.getMessage(), e); } catch(IOException e) { throw new AbortException("IO error", e); } } }
java
void readMeta() { final int check = buffer.getInt(); if(check != MAGIC) { throw new AbortException("File does not start with expected magic."); } final int nummeta = buffer.getInt(); assert (nummeta > 0) : "Empty bundle?"; meta = new BundleMeta(nummeta); sers = new ByteBufferSerializer<?>[nummeta]; data = new Object[nummeta]; for(int i = 0; i < nummeta; i++) { try { @SuppressWarnings("unchecked") SimpleTypeInformation<? extends Object> type = (SimpleTypeInformation<? extends Object>) TypeInformationSerializer.STATIC.fromByteBuffer(buffer); sers[i] = type.getSerializer(); if(i == 0 && DBID.class.isAssignableFrom(type.getRestrictionClass())) { hasids = true; } else { meta.add(type); } } catch(UnsupportedOperationException e) { throw new AbortException("Deserialization failed: " + e.getMessage(), e); } catch(IOException e) { throw new AbortException("IO error", e); } } }
[ "void", "readMeta", "(", ")", "{", "final", "int", "check", "=", "buffer", ".", "getInt", "(", ")", ";", "if", "(", "check", "!=", "MAGIC", ")", "{", "throw", "new", "AbortException", "(", "\"File does not start with expected magic.\"", ")", ";", "}", "fin...
Read the metadata.
[ "Read", "the", "metadata", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleReader.java#L130-L159
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleReader.java
BundleReader.readObject
void readObject() { for(int i = 0; i < sers.length; ++i) { try { data[i] = sers[i].fromByteBuffer(buffer); } catch(UnsupportedOperationException e) { throw new AbortException("Deserialization failed.", e); } catch(IOException e) { throw new AbortException("IO error", e); } } }
java
void readObject() { for(int i = 0; i < sers.length; ++i) { try { data[i] = sers[i].fromByteBuffer(buffer); } catch(UnsupportedOperationException e) { throw new AbortException("Deserialization failed.", e); } catch(IOException e) { throw new AbortException("IO error", e); } } }
[ "void", "readObject", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sers", ".", "length", ";", "++", "i", ")", "{", "try", "{", "data", "[", "i", "]", "=", "sers", "[", "i", "]", ".", "fromByteBuffer", "(", "buffer", ")", ...
Read an object.
[ "Read", "an", "object", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleReader.java#L164-L176
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/Leader.java
Leader.run
public Clustering<PrototypeModel<O>> run(Relation<O> relation) { RangeQuery<O> rq = relation.getRangeQuery(getDistanceFunction(), threshold); ModifiableDBIDs seen = DBIDUtil.newHashSet(relation.size()); Clustering<PrototypeModel<O>> clustering = new Clustering<>("Prototype clustering", "prototype-clustering"); int queries = 0; FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Leader clustering", relation.size(), LOG) : null; for(DBIDIter it = relation.iterDBIDs(); it.valid() && seen.size() < relation.size(); it.advance()) { if(seen.contains(it)) { continue; } DoubleDBIDList res = rq.getRangeForDBID(it, threshold); ++queries; ModifiableDBIDs ids = DBIDUtil.newArray(res.size()); for(DBIDIter cand = res.iter(); cand.valid(); cand.advance()) { if(seen.add(cand)) { LOG.incrementProcessed(prog); ids.add(cand); } } assert (ids.size() > 0 && ids.contains(it)); PrototypeModel<O> mod = new SimplePrototypeModel<>(relation.get(it)); clustering.addToplevelCluster(new Cluster<>(ids, mod)); } LOG.statistics(new LongStatistic(this.getClass().getName() + ".queries", queries)); LOG.ensureCompleted(prog); return clustering; }
java
public Clustering<PrototypeModel<O>> run(Relation<O> relation) { RangeQuery<O> rq = relation.getRangeQuery(getDistanceFunction(), threshold); ModifiableDBIDs seen = DBIDUtil.newHashSet(relation.size()); Clustering<PrototypeModel<O>> clustering = new Clustering<>("Prototype clustering", "prototype-clustering"); int queries = 0; FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Leader clustering", relation.size(), LOG) : null; for(DBIDIter it = relation.iterDBIDs(); it.valid() && seen.size() < relation.size(); it.advance()) { if(seen.contains(it)) { continue; } DoubleDBIDList res = rq.getRangeForDBID(it, threshold); ++queries; ModifiableDBIDs ids = DBIDUtil.newArray(res.size()); for(DBIDIter cand = res.iter(); cand.valid(); cand.advance()) { if(seen.add(cand)) { LOG.incrementProcessed(prog); ids.add(cand); } } assert (ids.size() > 0 && ids.contains(it)); PrototypeModel<O> mod = new SimplePrototypeModel<>(relation.get(it)); clustering.addToplevelCluster(new Cluster<>(ids, mod)); } LOG.statistics(new LongStatistic(this.getClass().getName() + ".queries", queries)); LOG.ensureCompleted(prog); return clustering; }
[ "public", "Clustering", "<", "PrototypeModel", "<", "O", ">", ">", "run", "(", "Relation", "<", "O", ">", "relation", ")", "{", "RangeQuery", "<", "O", ">", "rq", "=", "relation", ".", "getRangeQuery", "(", "getDistanceFunction", "(", ")", ",", "threshol...
Run the leader clustering algorithm. @param relation Data set @return Clustering result
[ "Run", "the", "leader", "clustering", "algorithm", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/Leader.java#L91-L119
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/data/Cluster.java
Cluster.writeToText
@Override public void writeToText(TextWriterStream out, String label) { String name = getNameAutomatic(); if(name != null) { out.commentPrintLn("Cluster name: " + name); } out.commentPrintLn("Cluster noise flag: " + isNoise()); out.commentPrintLn("Cluster size: " + ids.size()); // also print model, if any and printable if(getModel() != null && (getModel() instanceof TextWriteable)) { ((TextWriteable) getModel()).writeToText(out, label); } }
java
@Override public void writeToText(TextWriterStream out, String label) { String name = getNameAutomatic(); if(name != null) { out.commentPrintLn("Cluster name: " + name); } out.commentPrintLn("Cluster noise flag: " + isNoise()); out.commentPrintLn("Cluster size: " + ids.size()); // also print model, if any and printable if(getModel() != null && (getModel() instanceof TextWriteable)) { ((TextWriteable) getModel()).writeToText(out, label); } }
[ "@", "Override", "public", "void", "writeToText", "(", "TextWriterStream", "out", ",", "String", "label", ")", "{", "String", "name", "=", "getNameAutomatic", "(", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "out", ".", "commentPrintLn", "(", "\...
Write to a textual representation. Writing the actual group data will be handled by the caller, this is only meant to write the meta information. @param out output writer stream @param label Label to prefix
[ "Write", "to", "a", "textual", "representation", ".", "Writing", "the", "actual", "group", "data", "will", "be", "handled", "by", "the", "caller", "this", "is", "only", "meant", "to", "write", "the", "meta", "information", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/data/Cluster.java#L247-L259
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGSynchronizedCanvas.java
JSVGSynchronizedCanvas.scheduleSetPlot
private void scheduleSetPlot(final SVGPlot oldplot, final SVGPlot newplot) { UpdateManager um = this.getUpdateManager(); if(um != null) { synchronized(um) { if(um.isRunning()) { // LoggingUtil.warning("Scheduling detach: " + this + " " + oldplot); final Runnable detach = new Runnable() { @Override public void run() { if(latest.compareAndSet(this, null)) { detachPlot(oldplot); attachPlot(newplot); } } }; latest.set(detach); um.getUpdateRunnableQueue().preemptLater(detach); return; } } } else { if(oldplot != null) { LoggingUtil.warning("No update manager, but a previous plot exists. Incorrectly initialized?"); } } detachPlot(oldplot); attachPlot(newplot); }
java
private void scheduleSetPlot(final SVGPlot oldplot, final SVGPlot newplot) { UpdateManager um = this.getUpdateManager(); if(um != null) { synchronized(um) { if(um.isRunning()) { // LoggingUtil.warning("Scheduling detach: " + this + " " + oldplot); final Runnable detach = new Runnable() { @Override public void run() { if(latest.compareAndSet(this, null)) { detachPlot(oldplot); attachPlot(newplot); } } }; latest.set(detach); um.getUpdateRunnableQueue().preemptLater(detach); return; } } } else { if(oldplot != null) { LoggingUtil.warning("No update manager, but a previous plot exists. Incorrectly initialized?"); } } detachPlot(oldplot); attachPlot(newplot); }
[ "private", "void", "scheduleSetPlot", "(", "final", "SVGPlot", "oldplot", ",", "final", "SVGPlot", "newplot", ")", "{", "UpdateManager", "um", "=", "this", ".", "getUpdateManager", "(", ")", ";", "if", "(", "um", "!=", "null", ")", "{", "synchronized", "("...
Schedule a detach. @param oldplot Plot to detach from.
[ "Schedule", "a", "detach", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGSynchronizedCanvas.java#L111-L139
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGSynchronizedCanvas.java
JSVGSynchronizedCanvas.attachPlot
private void attachPlot(SVGPlot newplot) { this.plot = newplot; if(newplot == null) { super.setSVGDocument(null); return; } newplot.synchronizeWith(synchronizer); super.setSVGDocument(newplot.getDocument()); super.setDisableInteractions(newplot.getDisableInteractions()); }
java
private void attachPlot(SVGPlot newplot) { this.plot = newplot; if(newplot == null) { super.setSVGDocument(null); return; } newplot.synchronizeWith(synchronizer); super.setSVGDocument(newplot.getDocument()); super.setDisableInteractions(newplot.getDisableInteractions()); }
[ "private", "void", "attachPlot", "(", "SVGPlot", "newplot", ")", "{", "this", ".", "plot", "=", "newplot", ";", "if", "(", "newplot", "==", "null", ")", "{", "super", ".", "setSVGDocument", "(", "null", ")", ";", "return", ";", "}", "newplot", ".", "...
Attach to a new plot, and display. @param newplot Plot to attach to.
[ "Attach", "to", "a", "new", "plot", "and", "display", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGSynchronizedCanvas.java#L146-L155
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGSynchronizedCanvas.java
JSVGSynchronizedCanvas.detachPlot
private void detachPlot(SVGPlot oldplot) { if(oldplot == null) { return; } this.plot = null; oldplot.unsynchronizeWith(synchronizer); }
java
private void detachPlot(SVGPlot oldplot) { if(oldplot == null) { return; } this.plot = null; oldplot.unsynchronizeWith(synchronizer); }
[ "private", "void", "detachPlot", "(", "SVGPlot", "oldplot", ")", "{", "if", "(", "oldplot", "==", "null", ")", "{", "return", ";", "}", "this", ".", "plot", "=", "null", ";", "oldplot", ".", "unsynchronizeWith", "(", "synchronizer", ")", ";", "}" ]
Execute the detaching event. @param oldplot Plot to detach from.
[ "Execute", "the", "detaching", "event", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGSynchronizedCanvas.java#L162-L168
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/intrinsic/ISOS.java
ISOS.estimateID
protected double estimateID(DBIDRef ignore, DoubleDBIDListIter it, double[] p) { int j = 0; for(it.seek(0); it.valid(); it.advance()) { if(it.doubleValue() == 0. || DBIDUtil.equal(ignore, it)) { continue; } p[j++] = it.doubleValue(); } if(j < 2) { throw new ArithmeticException("Too little data to estimate ID."); } return estimator.estimate(p, j); }
java
protected double estimateID(DBIDRef ignore, DoubleDBIDListIter it, double[] p) { int j = 0; for(it.seek(0); it.valid(); it.advance()) { if(it.doubleValue() == 0. || DBIDUtil.equal(ignore, it)) { continue; } p[j++] = it.doubleValue(); } if(j < 2) { throw new ArithmeticException("Too little data to estimate ID."); } return estimator.estimate(p, j); }
[ "protected", "double", "estimateID", "(", "DBIDRef", "ignore", ",", "DoubleDBIDListIter", "it", ",", "double", "[", "]", "p", ")", "{", "int", "j", "=", "0", ";", "for", "(", "it", ".", "seek", "(", "0", ")", ";", "it", ".", "valid", "(", ")", ";...
Estimate the local intrinsic dimensionality. @param ignore Object to ignore @param it Iterator @param p Scratch array @return ID estimate
[ "Estimate", "the", "local", "intrinsic", "dimensionality", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/intrinsic/ISOS.java#L194-L206
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/ExponentialDistribution.java
ExponentialDistribution.logpdf
public static double logpdf(double val, double rate) { return val < 0. ? Double.NEGATIVE_INFINITY : FastMath.log(rate) - rate * val; }
java
public static double logpdf(double val, double rate) { return val < 0. ? Double.NEGATIVE_INFINITY : FastMath.log(rate) - rate * val; }
[ "public", "static", "double", "logpdf", "(", "double", "val", ",", "double", "rate", ")", "{", "return", "val", "<", "0.", "?", "Double", ".", "NEGATIVE_INFINITY", ":", "FastMath", ".", "log", "(", "rate", ")", "-", "rate", "*", "val", ";", "}" ]
log PDF, static version @param val Value to compute PDF at @param rate Rate parameter (1/scale) @return probability density
[ "log", "PDF", "static", "version" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/ExponentialDistribution.java#L149-L151
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/ExponentialDistribution.java
ExponentialDistribution.quantile
public static double quantile(double val, double rate) { return val >= 0 && val <= 1 ? -FastMath.log(1 - val) / rate : Double.NaN; }
java
public static double quantile(double val, double rate) { return val >= 0 && val <= 1 ? -FastMath.log(1 - val) / rate : Double.NaN; }
[ "public", "static", "double", "quantile", "(", "double", "val", ",", "double", "rate", ")", "{", "return", "val", ">=", "0", "&&", "val", "<=", "1", "?", "-", "FastMath", ".", "log", "(", "1", "-", "val", ")", "/", "rate", ":", "Double", ".", "Na...
Quantile function, static version @param val Value to compute quantile for @param rate Rate parameter @return Quantile
[ "Quantile", "function", "static", "version" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/ExponentialDistribution.java#L181-L183
train
elki-project/elki
elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java
MarkdownDocStream.pendingBreak
private MarkdownDocStream pendingBreak() { if(newline == Newline.NONE) { return this; } out.append(newline == Newline.BREAK ? "\\\n" : newline == Newline.PAR ? "\n\n" : "\n"); for(int i = indent, j = i; i > 0; i -= j) { out.append(WHITESPACES, 0, (j = i > WHITESPACES.length() ? WHITESPACES.length() : i)); } newline = Newline.NONE; return this; }
java
private MarkdownDocStream pendingBreak() { if(newline == Newline.NONE) { return this; } out.append(newline == Newline.BREAK ? "\\\n" : newline == Newline.PAR ? "\n\n" : "\n"); for(int i = indent, j = i; i > 0; i -= j) { out.append(WHITESPACES, 0, (j = i > WHITESPACES.length() ? WHITESPACES.length() : i)); } newline = Newline.NONE; return this; }
[ "private", "MarkdownDocStream", "pendingBreak", "(", ")", "{", "if", "(", "newline", "==", "Newline", ".", "NONE", ")", "{", "return", "this", ";", "}", "out", ".", "append", "(", "newline", "==", "Newline", ".", "BREAK", "?", "\"\\\\\\n\"", ":", "newlin...
Output any pending line breaks. @return {@code this}
[ "Output", "any", "pending", "line", "breaks", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java#L78-L88
train
elki-project/elki
elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java
MarkdownDocStream.append
public MarkdownDocStream append(char c) { if(c == '\n') { newline = newline == Newline.NONE ? Newline.NEWLINE : Newline.PAR; return this; } pendingBreak(); out.append(c); return this; }
java
public MarkdownDocStream append(char c) { if(c == '\n') { newline = newline == Newline.NONE ? Newline.NEWLINE : Newline.PAR; return this; } pendingBreak(); out.append(c); return this; }
[ "public", "MarkdownDocStream", "append", "(", "char", "c", ")", "{", "if", "(", "c", "==", "'", "'", ")", "{", "newline", "=", "newline", "==", "Newline", ".", "NONE", "?", "Newline", ".", "NEWLINE", ":", "Newline", ".", "PAR", ";", "return", "this",...
Append a single character. @param c Char @return {@code this}
[ "Append", "a", "single", "character", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java#L96-L104
train
elki-project/elki
elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java
MarkdownDocStream.append
public MarkdownDocStream append(CharSequence p, int start, int end) { for(int pos = start; pos < end; ++pos) { final char c = p.charAt(pos); if(c == '\r') { continue; } append(c); // Uses \n magic. } return this; }
java
public MarkdownDocStream append(CharSequence p, int start, int end) { for(int pos = start; pos < end; ++pos) { final char c = p.charAt(pos); if(c == '\r') { continue; } append(c); // Uses \n magic. } return this; }
[ "public", "MarkdownDocStream", "append", "(", "CharSequence", "p", ",", "int", "start", ",", "int", "end", ")", "{", "for", "(", "int", "pos", "=", "start", ";", "pos", "<", "end", ";", "++", "pos", ")", "{", "final", "char", "c", "=", "p", ".", ...
Output part of a string. @param p String @param start Begin @param end End @return {@code this}
[ "Output", "part", "of", "a", "string", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java#L124-L133
train
elki-project/elki
elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java
MarkdownDocStream.indent
public MarkdownDocStream indent(int newindent) { if(newindent < indent) { newline = newline == Newline.BREAK ? Newline.NEWLINE : Newline.PAR; } indent = newindent; return this; }
java
public MarkdownDocStream indent(int newindent) { if(newindent < indent) { newline = newline == Newline.BREAK ? Newline.NEWLINE : Newline.PAR; } indent = newindent; return this; }
[ "public", "MarkdownDocStream", "indent", "(", "int", "newindent", ")", "{", "if", "(", "newindent", "<", "indent", ")", "{", "newline", "=", "newline", "==", "Newline", ".", "BREAK", "?", "Newline", ".", "NEWLINE", ":", "Newline", ".", "PAR", ";", "}", ...
Set the indent depth. @param newindent Indent depth @return {@code this}
[ "Set", "the", "indent", "depth", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/application/internal/MarkdownDocStream.java#L203-L209
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/AbstractSimpleOverlay.java
AbstractSimpleOverlay.render
public final void render(GL2 gl) { gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0, width, 0, height, -1, +1); gl.glColor4f(0f, 0f, 0f, .5f); // Fade background: gl.glBegin(GL2.GL_QUADS); gl.glVertex2f(0f, 0f); gl.glVertex2f(width, 0f); gl.glVertex2f(width, height); gl.glVertex2f(0f, height); gl.glEnd(); renderContents(gl); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPopMatrix(); }
java
public final void render(GL2 gl) { gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0, width, 0, height, -1, +1); gl.glColor4f(0f, 0f, 0f, .5f); // Fade background: gl.glBegin(GL2.GL_QUADS); gl.glVertex2f(0f, 0f); gl.glVertex2f(width, 0f); gl.glVertex2f(width, height); gl.glVertex2f(0f, height); gl.glEnd(); renderContents(gl); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPopMatrix(); }
[ "public", "final", "void", "render", "(", "GL2", "gl", ")", "{", "gl", ".", "glMatrixMode", "(", "GL2", ".", "GL_PROJECTION", ")", ";", "gl", ".", "glPushMatrix", "(", ")", ";", "gl", ".", "glLoadIdentity", "(", ")", ";", "gl", ".", "glMatrixMode", "...
Main render method @param gl GL context
[ "Main", "render", "method" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/AbstractSimpleOverlay.java#L49-L74
train
elki-project/elki
elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/AbstractStoringPageFile.java
AbstractStoringPageFile.setPageID
@Override public int setPageID(P page) { int pageID = page.getPageID(); if(pageID == -1) { pageID = getNextEmptyPageID(); if(pageID == -1) { pageID = nextPageID++; } page.setPageID(pageID); } return pageID; }
java
@Override public int setPageID(P page) { int pageID = page.getPageID(); if(pageID == -1) { pageID = getNextEmptyPageID(); if(pageID == -1) { pageID = nextPageID++; } page.setPageID(pageID); } return pageID; }
[ "@", "Override", "public", "int", "setPageID", "(", "P", "page", ")", "{", "int", "pageID", "=", "page", ".", "getPageID", "(", ")", ";", "if", "(", "pageID", "==", "-", "1", ")", "{", "pageID", "=", "getNextEmptyPageID", "(", ")", ";", "if", "(", ...
Sets the id of the given page. @param page the page to set the id
[ "Sets", "the", "id", "of", "the", "given", "page", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/AbstractStoringPageFile.java#L66-L77
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/Polygon.java
Polygon.appendToBuffer
public StringBuilder appendToBuffer(StringBuilder buf) { Iterator<double[]> iter = points.iterator(); while(iter.hasNext()) { double[] data = iter.next(); for(int i = 0; i < data.length; i++) { if(i > 0) { buf.append(','); } buf.append(data[i]); } if(iter.hasNext()) { buf.append(' '); } } return buf; }
java
public StringBuilder appendToBuffer(StringBuilder buf) { Iterator<double[]> iter = points.iterator(); while(iter.hasNext()) { double[] data = iter.next(); for(int i = 0; i < data.length; i++) { if(i > 0) { buf.append(','); } buf.append(data[i]); } if(iter.hasNext()) { buf.append(' '); } } return buf; }
[ "public", "StringBuilder", "appendToBuffer", "(", "StringBuilder", "buf", ")", "{", "Iterator", "<", "double", "[", "]", ">", "iter", "=", "points", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "double", "["...
Append the polygon to the buffer. @param buf Buffer to append to
[ "Append", "the", "polygon", "to", "the", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/Polygon.java#L113-L128
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/Polygon.java
Polygon.containsPoint2D
public boolean containsPoint2D(double[] v) { assert (v.length == 2); final double testx = v[0]; final double testy = v[1]; boolean c = false; Iterator<double[]> it = points.iterator(); double[] pre = points.get(points.size() - 1); while(it.hasNext()) { final double[] cur = it.next(); final double curx = cur[0], cury = cur[1]; final double prex = pre[0], prey = pre[1]; if(((cury > testy) != (prey > testy))) { if((testx < (prex - curx) * (testy - cury) / (prey - cury) + curx)) { c = !c; } } pre = cur; } return c; }
java
public boolean containsPoint2D(double[] v) { assert (v.length == 2); final double testx = v[0]; final double testy = v[1]; boolean c = false; Iterator<double[]> it = points.iterator(); double[] pre = points.get(points.size() - 1); while(it.hasNext()) { final double[] cur = it.next(); final double curx = cur[0], cury = cur[1]; final double prex = pre[0], prey = pre[1]; if(((cury > testy) != (prey > testy))) { if((testx < (prex - curx) * (testy - cury) / (prey - cury) + curx)) { c = !c; } } pre = cur; } return c; }
[ "public", "boolean", "containsPoint2D", "(", "double", "[", "]", "v", ")", "{", "assert", "(", "v", ".", "length", "==", "2", ")", ";", "final", "double", "testx", "=", "v", "[", "0", "]", ";", "final", "double", "testy", "=", "v", "[", "1", "]",...
Point in polygon test, based on http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by W. Randolph Franklin @param v Point to test @return True when contained.
[ "Point", "in", "polygon", "test", "based", "on" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/Polygon.java#L245-L265
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java
AffineTransformation.reorderAxesTransformation
public static AffineTransformation reorderAxesTransformation(int dim, int... axes) { double[][] m = zeroMatrix(dim + 1); // insert ones appropriately: for(int i = 0; i < axes.length; i++) { assert (0 < axes[i] && axes[i] <= dim); m[i][axes[i] - 1] = 1.0; } int useddim = 1; for(int i = axes.length; i < dim + 1; i++) { // find next "unused" dimension. { boolean search = true; while(search) { search = false; for(int a : axes) { if(a == useddim) { search = true; useddim++; break; } } } } m[i][useddim - 1] = 1.0; useddim++; } assert (useddim - 2 == dim); return new AffineTransformation(dim, m, null); }
java
public static AffineTransformation reorderAxesTransformation(int dim, int... axes) { double[][] m = zeroMatrix(dim + 1); // insert ones appropriately: for(int i = 0; i < axes.length; i++) { assert (0 < axes[i] && axes[i] <= dim); m[i][axes[i] - 1] = 1.0; } int useddim = 1; for(int i = axes.length; i < dim + 1; i++) { // find next "unused" dimension. { boolean search = true; while(search) { search = false; for(int a : axes) { if(a == useddim) { search = true; useddim++; break; } } } } m[i][useddim - 1] = 1.0; useddim++; } assert (useddim - 2 == dim); return new AffineTransformation(dim, m, null); }
[ "public", "static", "AffineTransformation", "reorderAxesTransformation", "(", "int", "dim", ",", "int", "...", "axes", ")", "{", "double", "[", "]", "[", "]", "m", "=", "zeroMatrix", "(", "dim", "+", "1", ")", ";", "// insert ones appropriately:", "for", "("...
Generate a transformation that reorders axes in the given way. The list of axes to be used should not contain duplicates, or the resulting matrix will not be invertible. It does not have to be complete however, in particular an empty list will result in the identity transform: unmentioned axes will be appended in their original order. @param dim Dimensionality of vector space (resulting Matrix will be dim+1 x dim+1) @param axes (Partial) list of axes @return new transformation to do the requested reordering
[ "Generate", "a", "transformation", "that", "reorders", "axes", "in", "the", "given", "way", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java#L101-L129
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java
AffineTransformation.addTranslation
public void addTranslation(double[] v) { assert (v.length == dim); // reset inverse transformation - needs recomputation. inv = null; double[][] homTrans = unitMatrix(dim + 1); for(int i = 0; i < dim; i++) { homTrans[i][dim] = v[i]; } trans = times(homTrans, trans); }
java
public void addTranslation(double[] v) { assert (v.length == dim); // reset inverse transformation - needs recomputation. inv = null; double[][] homTrans = unitMatrix(dim + 1); for(int i = 0; i < dim; i++) { homTrans[i][dim] = v[i]; } trans = times(homTrans, trans); }
[ "public", "void", "addTranslation", "(", "double", "[", "]", "v", ")", "{", "assert", "(", "v", ".", "length", "==", "dim", ")", ";", "// reset inverse transformation - needs recomputation.", "inv", "=", "null", ";", "double", "[", "]", "[", "]", "homTrans",...
Add a translation operation to the matrix @param v translation vector
[ "Add", "a", "translation", "operation", "to", "the", "matrix" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java#L145-L156
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java
AffineTransformation.addMatrix
public void addMatrix(double[][] m) { assert (m.length == dim); assert (m[0].length == dim); // reset inverse transformation - needs recomputation. inv = null; // extend the matrix with an extra row and column double[][] ht = new double[dim + 1][dim + 1]; for(int i = 0; i < dim; i++) { for(int j = 0; j < dim; j++) { ht[i][j] = m[i][j]; } } // the other cells default to identity matrix ht[dim][dim] = 1.0; // Multiply from left. trans = times(ht, trans); }
java
public void addMatrix(double[][] m) { assert (m.length == dim); assert (m[0].length == dim); // reset inverse transformation - needs recomputation. inv = null; // extend the matrix with an extra row and column double[][] ht = new double[dim + 1][dim + 1]; for(int i = 0; i < dim; i++) { for(int j = 0; j < dim; j++) { ht[i][j] = m[i][j]; } } // the other cells default to identity matrix ht[dim][dim] = 1.0; // Multiply from left. trans = times(ht, trans); }
[ "public", "void", "addMatrix", "(", "double", "[", "]", "[", "]", "m", ")", "{", "assert", "(", "m", ".", "length", "==", "dim", ")", ";", "assert", "(", "m", "[", "0", "]", ".", "length", "==", "dim", ")", ";", "// reset inverse transformation - nee...
Add a matrix operation to the matrix. Be careful to use only invertible matrices if you want an invertible affine transformation. @param m matrix (should be invertible)
[ "Add", "a", "matrix", "operation", "to", "the", "matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java#L166-L184
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java
AffineTransformation.addRotation
public void addRotation(int axis1, int axis2, double angle) { // TODO: throw an exception instead of using assert assert (axis1 >= 0); assert (axis1 < dim); assert (axis1 >= 0); assert (axis2 < dim); assert (axis1 != axis2); // reset inverse transformation - needs recomputation. inv = null; double[][] ht = new double[dim + 1][dim + 1]; // identity matrix for(int i = 0; i < dim + 1; i++) { ht[i][i] = 1.0; } // insert rotation values final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine double s = FastMath.sinAndCos(angle, tmp), c = tmp.value; ht[axis1][axis1] = +c; ht[axis1][axis2] = -s; ht[axis2][axis1] = +s; ht[axis2][axis2] = +c; // Multiply from left trans = times(ht, trans); }
java
public void addRotation(int axis1, int axis2, double angle) { // TODO: throw an exception instead of using assert assert (axis1 >= 0); assert (axis1 < dim); assert (axis1 >= 0); assert (axis2 < dim); assert (axis1 != axis2); // reset inverse transformation - needs recomputation. inv = null; double[][] ht = new double[dim + 1][dim + 1]; // identity matrix for(int i = 0; i < dim + 1; i++) { ht[i][i] = 1.0; } // insert rotation values final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine double s = FastMath.sinAndCos(angle, tmp), c = tmp.value; ht[axis1][axis1] = +c; ht[axis1][axis2] = -s; ht[axis2][axis1] = +s; ht[axis2][axis2] = +c; // Multiply from left trans = times(ht, trans); }
[ "public", "void", "addRotation", "(", "int", "axis1", ",", "int", "axis2", ",", "double", "angle", ")", "{", "// TODO: throw an exception instead of using assert", "assert", "(", "axis1", ">=", "0", ")", ";", "assert", "(", "axis1", "<", "dim", ")", ";", "as...
Convenience function to apply a rotation in 2 dimensions. @param axis1 first dimension @param axis2 second dimension @param angle rotation angle in radians.
[ "Convenience", "function", "to", "apply", "a", "rotation", "in", "2", "dimensions", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java#L193-L218
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java
AffineTransformation.addAxisReflection
public void addAxisReflection(int axis) { assert (0 < axis && axis <= dim); // reset inverse transformation - needs recomputation. inv = null; // Formal: // Matrix homTrans = Matrix.unitMatrix(dim + 1); // homTrans[axis - 1][axis - 1] = -1; // trans = homTrans.times(trans); // Faster: for(int i = 0; i <= dim; i++) { trans[axis - 1][i] = -trans[axis - 1][i]; } }
java
public void addAxisReflection(int axis) { assert (0 < axis && axis <= dim); // reset inverse transformation - needs recomputation. inv = null; // Formal: // Matrix homTrans = Matrix.unitMatrix(dim + 1); // homTrans[axis - 1][axis - 1] = -1; // trans = homTrans.times(trans); // Faster: for(int i = 0; i <= dim; i++) { trans[axis - 1][i] = -trans[axis - 1][i]; } }
[ "public", "void", "addAxisReflection", "(", "int", "axis", ")", "{", "assert", "(", "0", "<", "axis", "&&", "axis", "<=", "dim", ")", ";", "// reset inverse transformation - needs recomputation.", "inv", "=", "null", ";", "// Formal:", "// Matrix homTrans = Matrix.u...
Add a reflection along the given axis. @param axis Axis number to do the reflection at.
[ "Add", "a", "reflection", "along", "the", "given", "axis", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java#L225-L238
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java
AffineTransformation.homogeneVector
public double[] homogeneVector(double[] v) { assert (v.length == dim); double[] dv = Arrays.copyOf(v, dim + 1); dv[dim] = 1.0; return dv; }
java
public double[] homogeneVector(double[] v) { assert (v.length == dim); double[] dv = Arrays.copyOf(v, dim + 1); dv[dim] = 1.0; return dv; }
[ "public", "double", "[", "]", "homogeneVector", "(", "double", "[", "]", "v", ")", "{", "assert", "(", "v", ".", "length", "==", "dim", ")", ";", "double", "[", "]", "dv", "=", "Arrays", ".", "copyOf", "(", "v", ",", "dim", "+", "1", ")", ";", ...
Transform an absolute vector into homogeneous coordinates. @param v initial vector @return vector of dim+1, with new column having the value 1.0
[ "Transform", "an", "absolute", "vector", "into", "homogeneous", "coordinates", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java#L292-L297
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java
AffineTransformation.homogeneRelativeVector
public double[] homogeneRelativeVector(double[] v) { assert (v.length == dim); // TODO: this only works properly when trans[dim][dim] == 1.0, right? double[] dv = Arrays.copyOf(v, dim + 1); dv[dim] = 0.0; return dv; }
java
public double[] homogeneRelativeVector(double[] v) { assert (v.length == dim); // TODO: this only works properly when trans[dim][dim] == 1.0, right? double[] dv = Arrays.copyOf(v, dim + 1); dv[dim] = 0.0; return dv; }
[ "public", "double", "[", "]", "homogeneRelativeVector", "(", "double", "[", "]", "v", ")", "{", "assert", "(", "v", ".", "length", "==", "dim", ")", ";", "// TODO: this only works properly when trans[dim][dim] == 1.0, right?", "double", "[", "]", "dv", "=", "Arr...
Transform a relative vector into homogeneous coordinates. @param v initial vector @return vector of dim+1, with new column having the value 0.0
[ "Transform", "a", "relative", "vector", "into", "homogeneous", "coordinates", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/AffineTransformation.java#L305-L311
train
elki-project/elki
addons/uncertain/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/uncertain/RepresentativeUncertainClustering.java
RepresentativeUncertainClustering.computeConfidence
private double computeConfidence(int support, int samples) { final double z = NormalDistribution.standardNormalQuantile(alpha); final double eprob = support / (double) samples; return Math.max(0., eprob - z * FastMath.sqrt((eprob * (1 - eprob)) / samples)); }
java
private double computeConfidence(int support, int samples) { final double z = NormalDistribution.standardNormalQuantile(alpha); final double eprob = support / (double) samples; return Math.max(0., eprob - z * FastMath.sqrt((eprob * (1 - eprob)) / samples)); }
[ "private", "double", "computeConfidence", "(", "int", "support", ",", "int", "samples", ")", "{", "final", "double", "z", "=", "NormalDistribution", ".", "standardNormalQuantile", "(", "alpha", ")", ";", "final", "double", "eprob", "=", "support", "/", "(", ...
Estimate the confidence probability of a clustering. @param support Number of supporting samples @param samples Total samples @return Probability
[ "Estimate", "the", "confidence", "probability", "of", "a", "clustering", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/uncertain/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/uncertain/RepresentativeUncertainClustering.java#L294-L298
train
elki-project/elki
addons/uncertain/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/uncertain/RepresentativeUncertainClustering.java
RepresentativeUncertainClustering.runClusteringAlgorithm
protected Clustering<?> runClusteringAlgorithm(ResultHierarchy hierarchy, Result parent, DBIDs ids, DataStore<DoubleVector> store, int dim, String title) { SimpleTypeInformation<DoubleVector> t = new VectorFieldTypeInformation<>(DoubleVector.FACTORY, dim); Relation<DoubleVector> sample = new MaterializedRelation<>(t, ids, title, store); ProxyDatabase d = new ProxyDatabase(ids, sample); Clustering<?> clusterResult = samplesAlgorithm.run(d); d.getHierarchy().remove(sample); d.getHierarchy().remove(clusterResult); hierarchy.add(parent, sample); hierarchy.add(sample, clusterResult); return clusterResult; }
java
protected Clustering<?> runClusteringAlgorithm(ResultHierarchy hierarchy, Result parent, DBIDs ids, DataStore<DoubleVector> store, int dim, String title) { SimpleTypeInformation<DoubleVector> t = new VectorFieldTypeInformation<>(DoubleVector.FACTORY, dim); Relation<DoubleVector> sample = new MaterializedRelation<>(t, ids, title, store); ProxyDatabase d = new ProxyDatabase(ids, sample); Clustering<?> clusterResult = samplesAlgorithm.run(d); d.getHierarchy().remove(sample); d.getHierarchy().remove(clusterResult); hierarchy.add(parent, sample); hierarchy.add(sample, clusterResult); return clusterResult; }
[ "protected", "Clustering", "<", "?", ">", "runClusteringAlgorithm", "(", "ResultHierarchy", "hierarchy", ",", "Result", "parent", ",", "DBIDs", "ids", ",", "DataStore", "<", "DoubleVector", ">", "store", ",", "int", "dim", ",", "String", "title", ")", "{", "...
Run a clustering algorithm on a single instance. @param parent Parent result to attach to @param ids Object IDs to process @param store Input data @param dim Dimensionality @param title Title of relation @return Clustering result
[ "Run", "a", "clustering", "algorithm", "on", "a", "single", "instance", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/uncertain/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/uncertain/RepresentativeUncertainClustering.java#L310-L320
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ELKIServiceLoader.java
ELKIServiceLoader.load
public static void load(Class<?> parent, ClassLoader cl) { char[] buf = new char[0x4000]; try { String fullName = RESOURCE_PREFIX + parent.getName(); Enumeration<URL> configfiles = cl.getResources(fullName); while(configfiles.hasMoreElements()) { URL nextElement = configfiles.nextElement(); URLConnection conn = nextElement.openConnection(); conn.setUseCaches(false); try ( InputStreamReader is = new InputStreamReader(conn.getInputStream(), "UTF-8");) { int start = 0, cur = 0, valid = is.read(buf, 0, buf.length); char c; while(cur < valid) { // Find newline or end while(cur < valid && (c = buf[cur]) != '\n' && c != '\r') { cur++; } if(cur == valid && is.ready()) { // Move consumed buffer contents: if(start > 0) { System.arraycopy(buf, start, buf, 0, valid - start); valid -= start; cur -= start; start = 0; } else if(valid == buf.length) { throw new IOException("Buffer size exceeded. Maximum line length in service files is: " + buf.length + " in file: " + fullName); } valid = is.read(buf, valid, buf.length - valid); continue; } parseLine(parent, buf, start, cur); while(cur < valid && ((c = buf[cur]) == '\n' || c == '\r')) { cur++; } start = cur; } } catch(IOException x) { throw new AbortException("Error reading configuration file", x); } } } catch(IOException x) { throw new AbortException("Could not load service configuration files.", x); } }
java
public static void load(Class<?> parent, ClassLoader cl) { char[] buf = new char[0x4000]; try { String fullName = RESOURCE_PREFIX + parent.getName(); Enumeration<URL> configfiles = cl.getResources(fullName); while(configfiles.hasMoreElements()) { URL nextElement = configfiles.nextElement(); URLConnection conn = nextElement.openConnection(); conn.setUseCaches(false); try ( InputStreamReader is = new InputStreamReader(conn.getInputStream(), "UTF-8");) { int start = 0, cur = 0, valid = is.read(buf, 0, buf.length); char c; while(cur < valid) { // Find newline or end while(cur < valid && (c = buf[cur]) != '\n' && c != '\r') { cur++; } if(cur == valid && is.ready()) { // Move consumed buffer contents: if(start > 0) { System.arraycopy(buf, start, buf, 0, valid - start); valid -= start; cur -= start; start = 0; } else if(valid == buf.length) { throw new IOException("Buffer size exceeded. Maximum line length in service files is: " + buf.length + " in file: " + fullName); } valid = is.read(buf, valid, buf.length - valid); continue; } parseLine(parent, buf, start, cur); while(cur < valid && ((c = buf[cur]) == '\n' || c == '\r')) { cur++; } start = cur; } } catch(IOException x) { throw new AbortException("Error reading configuration file", x); } } } catch(IOException x) { throw new AbortException("Could not load service configuration files.", x); } }
[ "public", "static", "void", "load", "(", "Class", "<", "?", ">", "parent", ",", "ClassLoader", "cl", ")", "{", "char", "[", "]", "buf", "=", "new", "char", "[", "0x4000", "]", ";", "try", "{", "String", "fullName", "=", "RESOURCE_PREFIX", "+", "paren...
Load the service file.
[ "Load", "the", "service", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ELKIServiceLoader.java#L75-L122
train