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-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(float[] f) { return (f == null) ? "null" : (f.length == 0) ? "" : // formatTo(new StringBuilder(), f, ", ").toString(); }
java
public static String format(float[] f) { return (f == null) ? "null" : (f.length == 0) ? "" : // formatTo(new StringBuilder(), f, ", ").toString(); }
[ "public", "static", "String", "format", "(", "float", "[", "]", "f", ")", "{", "return", "(", "f", "==", "null", ")", "?", "\"null\"", ":", "(", "f", ".", "length", "==", "0", ")", "?", "\"\"", ":", "//", "formatTo", "(", "new", "StringBuilder", ...
Formats the float array f with ',' as separator and default precision. @param f the float array to be formatted @return a String representing the float array f
[ "Formats", "the", "float", "array", "f", "with", "as", "separator", "and", "default", "precision", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L512-L515
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(int[] a, String sep) { return (a == null) ? "null" : (a.length == 0) ? "" : // formatTo(new StringBuilder(), a, sep).toString(); }
java
public static String format(int[] a, String sep) { return (a == null) ? "null" : (a.length == 0) ? "" : // formatTo(new StringBuilder(), a, sep).toString(); }
[ "public", "static", "String", "format", "(", "int", "[", "]", "a", ",", "String", "sep", ")", "{", "return", "(", "a", "==", "null", ")", "?", "\"null\"", ":", "(", "a", ".", "length", "==", "0", ")", "?", "\"\"", ":", "//", "formatTo", "(", "n...
Formats the int array a for printing purposes. @param a the int array to be formatted @param sep the separator between the single values of the array, e.g. ',' @return a String representing the int array a
[ "Formats", "the", "int", "array", "a", "for", "printing", "purposes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L524-L527
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(boolean[] b, final String sep) { return (b == null) ? "null" : (b.length == 0) ? "" : // formatTo(new StringBuilder(), b, ", ").toString(); }
java
public static String format(boolean[] b, final String sep) { return (b == null) ? "null" : (b.length == 0) ? "" : // formatTo(new StringBuilder(), b, ", ").toString(); }
[ "public", "static", "String", "format", "(", "boolean", "[", "]", "b", ",", "final", "String", "sep", ")", "{", "return", "(", "b", "==", "null", ")", "?", "\"null\"", ":", "(", "b", ".", "length", "==", "0", ")", "?", "\"\"", ":", "//", "formatT...
Formats the boolean array b with ',' as separator. @param b the boolean array to be formatted @param sep separator between the single values of the array, e.g. ',' @return a String representing the boolean array b
[ "Formats", "the", "boolean", "array", "b", "with", "as", "separator", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L569-L572
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(double[][] d) { return d == null ? "null" : (d.length == 0) ? "[]" : // formatTo(new StringBuilder().append("[\n"), d, " [", "]\n", ", ", NF2).append(']').toString(); }
java
public static String format(double[][] d) { return d == null ? "null" : (d.length == 0) ? "[]" : // formatTo(new StringBuilder().append("[\n"), d, " [", "]\n", ", ", NF2).append(']').toString(); }
[ "public", "static", "String", "format", "(", "double", "[", "]", "[", "]", "d", ")", "{", "return", "d", "==", "null", "?", "\"null\"", ":", "(", "d", ".", "length", "==", "0", ")", "?", "\"[]\"", ":", "//", "formatTo", "(", "new", "StringBuilder",...
Formats the double array d with ',' as separator and 2 fraction digits. @param d the double array to be formatted @return a String representing the double array d
[ "Formats", "the", "double", "array", "d", "with", "as", "separator", "and", "2", "fraction", "digits", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L615-L618
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(double[][] m, int w, int d, String pre, String pos, String csep) { DecimalFormat format = new DecimalFormat(); format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); format.setMinimumIntegerDigits(1); format.setMaximumFractionDigits(d); format.setMinimumFractionDigits(d); format.setGroupingUsed(false); StringBuilder msg = new StringBuilder(); for(int i = 0; i < m.length; i++) { double[] row = m[i]; msg.append(pre); for(int j = 0; j < row.length; j++) { if(j > 0) { msg.append(csep); } String s = format.format(row[j]); // format the number whitespace(msg, w - s.length()).append(s); } msg.append(pos); } return msg.toString(); }
java
public static String format(double[][] m, int w, int d, String pre, String pos, String csep) { DecimalFormat format = new DecimalFormat(); format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); format.setMinimumIntegerDigits(1); format.setMaximumFractionDigits(d); format.setMinimumFractionDigits(d); format.setGroupingUsed(false); StringBuilder msg = new StringBuilder(); for(int i = 0; i < m.length; i++) { double[] row = m[i]; msg.append(pre); for(int j = 0; j < row.length; j++) { if(j > 0) { msg.append(csep); } String s = format.format(row[j]); // format the number whitespace(msg, w - s.length()).append(s); } msg.append(pos); } return msg.toString(); }
[ "public", "static", "String", "format", "(", "double", "[", "]", "[", "]", "m", ",", "int", "w", ",", "int", "d", ",", "String", "pre", ",", "String", "pos", ",", "String", "csep", ")", "{", "DecimalFormat", "format", "=", "new", "DecimalFormat", "("...
Returns a string representation of this matrix. @param w column width @param d number of digits after the decimal @param pre Row prefix (e.g. " [") @param pos Row postfix (e.g. "]\n") @param csep Column separator (e.g. ", ") @return a string representation of this matrix
[ "Returns", "a", "string", "representation", "of", "this", "matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L646-L668
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(double[][] m, NumberFormat nf) { return formatTo(new StringBuilder().append("[\n"), m, " [", "]\n", ", ", nf).append("]").toString(); }
java
public static String format(double[][] m, NumberFormat nf) { return formatTo(new StringBuilder().append("[\n"), m, " [", "]\n", ", ", nf).append("]").toString(); }
[ "public", "static", "String", "format", "(", "double", "[", "]", "[", "]", "m", ",", "NumberFormat", "nf", ")", "{", "return", "formatTo", "(", "new", "StringBuilder", "(", ")", ".", "append", "(", "\"[\\n\"", ")", ",", "m", ",", "\" [\"", ",", "\"]\...
returns String-representation of Matrix. @param nf NumberFormat to specify output precision @return String representation of this Matrix in precision as specified by given NumberFormat
[ "returns", "String", "-", "representation", "of", "Matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L693-L695
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(Collection<String> d, String sep) { if(d == null) { return "null"; } if(d.isEmpty()) { return ""; } if(d.size() == 1) { return d.iterator().next(); } int len = sep.length() * (d.size() - 1); for(String s : d) { len += s.length(); } Iterator<String> it = d.iterator(); StringBuilder buffer = new StringBuilder(len) // .append(it.next()); while(it.hasNext()) { buffer.append(sep).append(it.next()); } return buffer.toString(); }
java
public static String format(Collection<String> d, String sep) { if(d == null) { return "null"; } if(d.isEmpty()) { return ""; } if(d.size() == 1) { return d.iterator().next(); } int len = sep.length() * (d.size() - 1); for(String s : d) { len += s.length(); } Iterator<String> it = d.iterator(); StringBuilder buffer = new StringBuilder(len) // .append(it.next()); while(it.hasNext()) { buffer.append(sep).append(it.next()); } return buffer.toString(); }
[ "public", "static", "String", "format", "(", "Collection", "<", "String", ">", "d", ",", "String", "sep", ")", "{", "if", "(", "d", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "if", "(", "d", ".", "isEmpty", "(", ")", ")", "{", "retur...
Formats the String collection with the specified separator. @param d the String collection to format @param sep separator between the single values of the array, e.g. ' ' @return a String representing the String Collection d
[ "Formats", "the", "String", "collection", "with", "the", "specified", "separator", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L704-L725
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(String[] d, String sep) { if(d == null) { return "null"; } if(d.length == 0) { return ""; } if(d.length == 1) { return d[0]; } int len = sep.length() * (d.length - 1); for(String s : d) { len += s.length(); } StringBuilder buffer = new StringBuilder(len)// .append(d[0]); for(int i = 1; i < d.length; i++) { buffer.append(sep).append(d[i]); } return buffer.toString(); }
java
public static String format(String[] d, String sep) { if(d == null) { return "null"; } if(d.length == 0) { return ""; } if(d.length == 1) { return d[0]; } int len = sep.length() * (d.length - 1); for(String s : d) { len += s.length(); } StringBuilder buffer = new StringBuilder(len)// .append(d[0]); for(int i = 1; i < d.length; i++) { buffer.append(sep).append(d[i]); } return buffer.toString(); }
[ "public", "static", "String", "format", "(", "String", "[", "]", "d", ",", "String", "sep", ")", "{", "if", "(", "d", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "if", "(", "d", ".", "length", "==", "0", ")", "{", "return", "\"\"", ...
Formats the string array d with the specified separator. @param d the string array to be formatted @param sep separator between the single values of the array, e.g. ',' @return a String representing the string array d
[ "Formats", "the", "string", "array", "d", "with", "the", "specified", "separator", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L734-L754
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.findSplitpoint
public static int findSplitpoint(String s, int width) { // the newline (or EOS) is the fallback split position. int in = s.indexOf(NEWLINE); in = in < 0 ? s.length() : in; // Good enough? if(in < width) { return in; } // otherwise, search for whitespace int iw = s.lastIndexOf(' ', width); // good whitespace found? if(iw >= 0 && iw < width) { return iw; } // sub-optimal splitpoint - retry AFTER the given position int bp = nextPosition(s.indexOf(' ', width), s.indexOf(NEWLINE, width)); if(bp >= 0) { return bp; } // even worse - can't split! return s.length(); }
java
public static int findSplitpoint(String s, int width) { // the newline (or EOS) is the fallback split position. int in = s.indexOf(NEWLINE); in = in < 0 ? s.length() : in; // Good enough? if(in < width) { return in; } // otherwise, search for whitespace int iw = s.lastIndexOf(' ', width); // good whitespace found? if(iw >= 0 && iw < width) { return iw; } // sub-optimal splitpoint - retry AFTER the given position int bp = nextPosition(s.indexOf(' ', width), s.indexOf(NEWLINE, width)); if(bp >= 0) { return bp; } // even worse - can't split! return s.length(); }
[ "public", "static", "int", "findSplitpoint", "(", "String", "s", ",", "int", "width", ")", "{", "// the newline (or EOS) is the fallback split position.", "int", "in", "=", "s", ".", "indexOf", "(", "NEWLINE", ")", ";", "in", "=", "in", "<", "0", "?", "s", ...
Find the first space before position w or if there is none after w. @param s String @param width Width @return index of best whitespace or <code>-1</code> if no whitespace was found.
[ "Find", "the", "first", "space", "before", "position", "w", "or", "if", "there", "is", "none", "after", "w", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L764-L785
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.splitAtLastBlank
public static List<String> splitAtLastBlank(String s, int width) { List<String> chunks = new ArrayList<>(); String tmp = s; while(tmp.length() > 0) { int index = findSplitpoint(tmp, width); // store first part chunks.add(tmp.substring(0, index)); // skip whitespace at beginning of line while(index < tmp.length() && tmp.charAt(index) == ' ') { index += 1; } // remove a newline if(index < tmp.length() && tmp.regionMatches(index, NEWLINE, 0, NEWLINE.length())) { index += NEWLINE.length(); } if(index >= tmp.length()) { break; } tmp = tmp.substring(index); } return chunks; }
java
public static List<String> splitAtLastBlank(String s, int width) { List<String> chunks = new ArrayList<>(); String tmp = s; while(tmp.length() > 0) { int index = findSplitpoint(tmp, width); // store first part chunks.add(tmp.substring(0, index)); // skip whitespace at beginning of line while(index < tmp.length() && tmp.charAt(index) == ' ') { index += 1; } // remove a newline if(index < tmp.length() && tmp.regionMatches(index, NEWLINE, 0, NEWLINE.length())) { index += NEWLINE.length(); } if(index >= tmp.length()) { break; } tmp = tmp.substring(index); } return chunks; }
[ "public", "static", "List", "<", "String", ">", "splitAtLastBlank", "(", "String", "s", ",", "int", "width", ")", "{", "List", "<", "String", ">", "chunks", "=", "new", "ArrayList", "<>", "(", ")", ";", "String", "tmp", "=", "s", ";", "while", "(", ...
Splits the specified string at the last blank before width. If there is no blank before the given width, it is split at the next. @param s the string to be split @param width int @return string fragments
[ "Splits", "the", "specified", "string", "at", "the", "last", "blank", "before", "width", ".", "If", "there", "is", "no", "blank", "before", "the", "given", "width", "it", "is", "split", "at", "the", "next", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L808-L831
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.pad
public static String pad(String o, int len) { return o.length() >= len ? o : (o + whitespace(len - o.length())); }
java
public static String pad(String o, int len) { return o.length() >= len ? o : (o + whitespace(len - o.length())); }
[ "public", "static", "String", "pad", "(", "String", "o", ",", "int", "len", ")", "{", "return", "o", ".", "length", "(", ")", ">=", "len", "?", "o", ":", "(", "o", "+", "whitespace", "(", "len", "-", "o", ".", "length", "(", ")", ")", ")", ";...
Pad a string to a given length by adding whitespace to the right. @param o original string @param len destination length @return padded string of at least length len (and o otherwise)
[ "Pad", "a", "string", "to", "a", "given", "length", "by", "adding", "whitespace", "to", "the", "right", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L869-L871
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.padRightAligned
public static String padRightAligned(String o, int len) { return o.length() >= len ? o : (whitespace(len - o.length()) + o); }
java
public static String padRightAligned(String o, int len) { return o.length() >= len ? o : (whitespace(len - o.length()) + o); }
[ "public", "static", "String", "padRightAligned", "(", "String", "o", ",", "int", "len", ")", "{", "return", "o", ".", "length", "(", ")", ">=", "len", "?", "o", ":", "(", "whitespace", "(", "len", "-", "o", ".", "length", "(", ")", ")", "+", "o",...
Pad a string to a given length by adding whitespace to the left. @param o original string @param len destination length @return padded string of at least length len (and o otherwise)
[ "Pad", "a", "string", "to", "a", "given", "length", "by", "adding", "whitespace", "to", "the", "left", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L880-L882
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.formatTimeDelta
public static String formatTimeDelta(long time, CharSequence sep) { final StringBuilder sb = new StringBuilder(); final Formatter fmt = new Formatter(sb); for(int i = TIME_UNIT_SIZES.length - 1; i >= 0; --i) { // We do not include ms if we are in the order of minutes. if(i == 0 && sb.length() > 4) { continue; } // Separator if(sb.length() > 0) { sb.append(sep); } final long acValue = time / TIME_UNIT_SIZES[i]; time = time % TIME_UNIT_SIZES[i]; if(!(acValue == 0 && sb.length() == 0)) { fmt.format("%0" + TIME_UNIT_DIGITS[i] + "d%s", Long.valueOf(acValue), TIME_UNIT_NAMES[i]); } } fmt.close(); return sb.toString(); }
java
public static String formatTimeDelta(long time, CharSequence sep) { final StringBuilder sb = new StringBuilder(); final Formatter fmt = new Formatter(sb); for(int i = TIME_UNIT_SIZES.length - 1; i >= 0; --i) { // We do not include ms if we are in the order of minutes. if(i == 0 && sb.length() > 4) { continue; } // Separator if(sb.length() > 0) { sb.append(sep); } final long acValue = time / TIME_UNIT_SIZES[i]; time = time % TIME_UNIT_SIZES[i]; if(!(acValue == 0 && sb.length() == 0)) { fmt.format("%0" + TIME_UNIT_DIGITS[i] + "d%s", Long.valueOf(acValue), TIME_UNIT_NAMES[i]); } } fmt.close(); return sb.toString(); }
[ "public", "static", "String", "formatTimeDelta", "(", "long", "time", ",", "CharSequence", "sep", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "final", "Formatter", "fmt", "=", "new", "Formatter", "(", "sb", ")", ";...
Formats a time delta in human readable format. @param time time delta in ms @return Formatted string
[ "Formats", "a", "time", "delta", "in", "human", "readable", "format", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L935-L956
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.appendZeros
public static StringBuilder appendZeros(StringBuilder buf, int zeros) { for(int i = zeros; i > 0; i -= ZEROPADDING.length) { buf.append(ZEROPADDING, 0, i < ZEROPADDING.length ? i : ZEROPADDING.length); } return buf; }
java
public static StringBuilder appendZeros(StringBuilder buf, int zeros) { for(int i = zeros; i > 0; i -= ZEROPADDING.length) { buf.append(ZEROPADDING, 0, i < ZEROPADDING.length ? i : ZEROPADDING.length); } return buf; }
[ "public", "static", "StringBuilder", "appendZeros", "(", "StringBuilder", "buf", ",", "int", "zeros", ")", "{", "for", "(", "int", "i", "=", "zeros", ";", "i", ">", "0", ";", "i", "-=", "ZEROPADDING", ".", "length", ")", "{", "buf", ".", "append", "(...
Append zeros to a buffer. @param buf Buffer to append to @param zeros Number of zeros to append. @return Buffer
[ "Append", "zeros", "to", "a", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L975-L980
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.appendSpace
public static StringBuilder appendSpace(StringBuilder buf, int spaces) { for(int i = spaces; i > 0; i -= SPACEPADDING.length) { buf.append(SPACEPADDING, 0, i < SPACEPADDING.length ? i : SPACEPADDING.length); } return buf; }
java
public static StringBuilder appendSpace(StringBuilder buf, int spaces) { for(int i = spaces; i > 0; i -= SPACEPADDING.length) { buf.append(SPACEPADDING, 0, i < SPACEPADDING.length ? i : SPACEPADDING.length); } return buf; }
[ "public", "static", "StringBuilder", "appendSpace", "(", "StringBuilder", "buf", ",", "int", "spaces", ")", "{", "for", "(", "int", "i", "=", "spaces", ";", "i", ">", "0", ";", "i", "-=", "SPACEPADDING", ".", "length", ")", "{", "buf", ".", "append", ...
Append whitespace to a buffer. @param buf Buffer to append to @param spaces Number of spaces to append. @return Buffer
[ "Append", "whitespace", "to", "a", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L989-L994
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/optics/AbstractOPTICSVisualization.java
AbstractOPTICSVisualization.makeLayerElement
protected void makeLayerElement() { plotwidth = StyleLibrary.SCALE; plotheight = StyleLibrary.SCALE / optics.getOPTICSPlot(context).getRatio(); final double margin = context.getStyleLibrary().getSize(StyleLibrary.MARGIN); layer = SVGUtil.svgElement(svgp.getDocument(), SVGConstants.SVG_G_TAG); final String transform = SVGUtil.makeMarginTransform(getWidth(), getHeight(), plotwidth, plotheight, margin * .5, margin * .5, margin * 1.5, margin * .5); SVGUtil.setAtt(layer, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, transform); }
java
protected void makeLayerElement() { plotwidth = StyleLibrary.SCALE; plotheight = StyleLibrary.SCALE / optics.getOPTICSPlot(context).getRatio(); final double margin = context.getStyleLibrary().getSize(StyleLibrary.MARGIN); layer = SVGUtil.svgElement(svgp.getDocument(), SVGConstants.SVG_G_TAG); final String transform = SVGUtil.makeMarginTransform(getWidth(), getHeight(), plotwidth, plotheight, margin * .5, margin * .5, margin * 1.5, margin * .5); SVGUtil.setAtt(layer, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, transform); }
[ "protected", "void", "makeLayerElement", "(", ")", "{", "plotwidth", "=", "StyleLibrary", ".", "SCALE", ";", "plotheight", "=", "StyleLibrary", ".", "SCALE", "/", "optics", ".", "getOPTICSPlot", "(", "context", ")", ".", "getRatio", "(", ")", ";", "final", ...
Produce a new layer element.
[ "Produce", "a", "new", "layer", "element", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/optics/AbstractOPTICSVisualization.java#L77-L84
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/transform/LinearDiscriminantAnalysisFilter.java
LinearDiscriminantAnalysisFilter.computeCentroids
protected List<Centroid> computeCentroids(int dim, List<V> vectorcolumn, List<ClassLabel> keys, Map<ClassLabel, IntList> classes) { final int numc = keys.size(); List<Centroid> centroids = new ArrayList<>(numc); for(int i = 0; i < numc; i++) { Centroid c = new Centroid(dim); for(IntIterator it = classes.get(keys.get(i)).iterator(); it.hasNext();) { c.put(vectorcolumn.get(it.nextInt())); } centroids.add(c); } return centroids; }
java
protected List<Centroid> computeCentroids(int dim, List<V> vectorcolumn, List<ClassLabel> keys, Map<ClassLabel, IntList> classes) { final int numc = keys.size(); List<Centroid> centroids = new ArrayList<>(numc); for(int i = 0; i < numc; i++) { Centroid c = new Centroid(dim); for(IntIterator it = classes.get(keys.get(i)).iterator(); it.hasNext();) { c.put(vectorcolumn.get(it.nextInt())); } centroids.add(c); } return centroids; }
[ "protected", "List", "<", "Centroid", ">", "computeCentroids", "(", "int", "dim", ",", "List", "<", "V", ">", "vectorcolumn", ",", "List", "<", "ClassLabel", ">", "keys", ",", "Map", "<", "ClassLabel", ",", "IntList", ">", "classes", ")", "{", "final", ...
Compute the centroid for each class. @param dim Dimensionality @param vectorcolumn Vector column @param keys Key index @param classes Classes @return Centroids for each class.
[ "Compute", "the", "centroid", "for", "each", "class", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/transform/LinearDiscriminantAnalysisFilter.java#L126-L137
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkmax/MkMaxTreeNode.java
MkMaxTreeNode.kNNDistance
protected double kNNDistance() { double knnDist = 0.; for(int i = 0; i < getNumEntries(); i++) { MkMaxEntry entry = getEntry(i); knnDist = Math.max(knnDist, entry.getKnnDistance()); } return knnDist; }
java
protected double kNNDistance() { double knnDist = 0.; for(int i = 0; i < getNumEntries(); i++) { MkMaxEntry entry = getEntry(i); knnDist = Math.max(knnDist, entry.getKnnDistance()); } return knnDist; }
[ "protected", "double", "kNNDistance", "(", ")", "{", "double", "knnDist", "=", "0.", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getNumEntries", "(", ")", ";", "i", "++", ")", "{", "MkMaxEntry", "entry", "=", "getEntry", "(", "i", ")", ...
Determines and returns the k-nearest neighbor distance of this node as the maximum of the k-nearest neighbor distances of all entries. @return the knn distance of this node
[ "Determines", "and", "returns", "the", "k", "-", "nearest", "neighbor", "distance", "of", "this", "node", "as", "the", "maximum", "of", "the", "k", "-", "nearest", "neighbor", "distances", "of", "all", "entries", "." ]
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/mkmax/MkMaxTreeNode.java#L67-L74
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkmax/MkMaxTreeNode.java
MkMaxTreeNode.adjustEntry
@Override public boolean adjustEntry(MkMaxEntry entry, DBID routingObjectID, double parentDistance, AbstractMTree<O, MkMaxTreeNode<O>, MkMaxEntry, ?> mTree) { super.adjustEntry(entry, routingObjectID, parentDistance, mTree); // adjust knn distance entry.setKnnDistance(kNNDistance()); return true; // TODO: improve }
java
@Override public boolean adjustEntry(MkMaxEntry entry, DBID routingObjectID, double parentDistance, AbstractMTree<O, MkMaxTreeNode<O>, MkMaxEntry, ?> mTree) { super.adjustEntry(entry, routingObjectID, parentDistance, mTree); // adjust knn distance entry.setKnnDistance(kNNDistance()); return true; // TODO: improve }
[ "@", "Override", "public", "boolean", "adjustEntry", "(", "MkMaxEntry", "entry", ",", "DBID", "routingObjectID", ",", "double", "parentDistance", ",", "AbstractMTree", "<", "O", ",", "MkMaxTreeNode", "<", "O", ">", ",", "MkMaxEntry", ",", "?", ">", "mTree", ...
Calls the super method and adjust additionally the k-nearest neighbor distance of this node as the maximum of the k-nearest neighbor distances of all its entries.
[ "Calls", "the", "super", "method", "and", "adjust", "additionally", "the", "k", "-", "nearest", "neighbor", "distance", "of", "this", "node", "as", "the", "maximum", "of", "the", "k", "-", "nearest", "neighbor", "distances", "of", "all", "its", "entries", ...
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/mkmax/MkMaxTreeNode.java#L81-L87
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkmax/MkMaxTreeNode.java
MkMaxTreeNode.integrityCheckParameters
@Override protected void integrityCheckParameters(MkMaxEntry parentEntry, MkMaxTreeNode<O> parent, int index, AbstractMTree<O, MkMaxTreeNode<O>, MkMaxEntry, ?> mTree) { super.integrityCheckParameters(parentEntry, parent, index, mTree); // test if knn distance is correctly set MkMaxEntry entry = parent.getEntry(index); double knnDistance = kNNDistance(); if(Math.abs(entry.getKnnDistance() - knnDistance) > 0) { throw new RuntimeException("Wrong knnDistance in node " + parent.getPageID() + " at index " + index + " (child " + entry + ")" + "\nsoll: " + knnDistance + ",\n ist: " + entry.getKnnDistance()); } }
java
@Override protected void integrityCheckParameters(MkMaxEntry parentEntry, MkMaxTreeNode<O> parent, int index, AbstractMTree<O, MkMaxTreeNode<O>, MkMaxEntry, ?> mTree) { super.integrityCheckParameters(parentEntry, parent, index, mTree); // test if knn distance is correctly set MkMaxEntry entry = parent.getEntry(index); double knnDistance = kNNDistance(); if(Math.abs(entry.getKnnDistance() - knnDistance) > 0) { throw new RuntimeException("Wrong knnDistance in node " + parent.getPageID() + " at index " + index + " (child " + entry + ")" + "\nsoll: " + knnDistance + ",\n ist: " + entry.getKnnDistance()); } }
[ "@", "Override", "protected", "void", "integrityCheckParameters", "(", "MkMaxEntry", "parentEntry", ",", "MkMaxTreeNode", "<", "O", ">", "parent", ",", "int", "index", ",", "AbstractMTree", "<", "O", ",", "MkMaxTreeNode", "<", "O", ">", ",", "MkMaxEntry", ",",...
Calls the super method and tests if the k-nearest neighbor distance of this node is correctly set.
[ "Calls", "the", "super", "method", "and", "tests", "if", "the", "k", "-", "nearest", "neighbor", "distance", "of", "this", "node", "is", "correctly", "set", "." ]
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/mkmax/MkMaxTreeNode.java#L93-L102
train
elki-project/elki
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/StaticArrayDatabase.java
StaticArrayDatabase.initialize
@Override public void initialize() { if(databaseConnection == null) { return; // Supposedly we initialized already. } if(LOG.isDebugging()) { LOG.debugFine("Loading data from database connection."); } MultipleObjectsBundle bundle = databaseConnection.loadData(); // Run at most once. databaseConnection = null; // Find DBIDs for bundle { DBIDs bids = bundle.getDBIDs(); if(bids instanceof ArrayStaticDBIDs) { this.ids = (ArrayStaticDBIDs) bids; } else if(bids == null) { this.ids = DBIDUtil.generateStaticDBIDRange(bundle.dataLength()); } else { this.ids = (ArrayStaticDBIDs) DBIDUtil.makeUnmodifiable(DBIDUtil.ensureArray(bids)); } } // Replace id representation (it would be nicer if we would not need // DBIDView at all) this.idrep = new DBIDView(this.ids); relations.add(this.idrep); getHierarchy().add(this, idrep); DBIDArrayIter it = this.ids.iter(); int numrel = bundle.metaLength(); for(int i = 0; i < numrel; i++) { SimpleTypeInformation<?> meta = bundle.meta(i); @SuppressWarnings("unchecked") SimpleTypeInformation<Object> ometa = (SimpleTypeInformation<Object>) meta; WritableDataStore<Object> store = DataStoreUtil.makeStorage(ids, DataStoreFactory.HINT_DB, ometa.getRestrictionClass()); for(it.seek(0); it.valid(); it.advance()) { store.put(it, bundle.data(it.getOffset(), i)); } Relation<?> relation = new MaterializedRelation<>(ometa, ids, null, store); relations.add(relation); getHierarchy().add(this, relation); // Try to add indexes where appropriate for(IndexFactory<?> factory : indexFactories) { if(factory.getInputTypeRestriction().isAssignableFromType(ometa)) { @SuppressWarnings("unchecked") final IndexFactory<Object> ofact = (IndexFactory<Object>) factory; @SuppressWarnings("unchecked") final Relation<Object> orep = (Relation<Object>) relation; final Index index = ofact.instantiate(orep); Duration duration = LOG.isStatistics() ? LOG.newDuration(index.getClass().getName() + ".construction").begin() : null; index.initialize(); if(duration != null) { LOG.statistics(duration.end()); } getHierarchy().add(relation, index); } } } // fire insertion event eventManager.fireObjectsInserted(ids); }
java
@Override public void initialize() { if(databaseConnection == null) { return; // Supposedly we initialized already. } if(LOG.isDebugging()) { LOG.debugFine("Loading data from database connection."); } MultipleObjectsBundle bundle = databaseConnection.loadData(); // Run at most once. databaseConnection = null; // Find DBIDs for bundle { DBIDs bids = bundle.getDBIDs(); if(bids instanceof ArrayStaticDBIDs) { this.ids = (ArrayStaticDBIDs) bids; } else if(bids == null) { this.ids = DBIDUtil.generateStaticDBIDRange(bundle.dataLength()); } else { this.ids = (ArrayStaticDBIDs) DBIDUtil.makeUnmodifiable(DBIDUtil.ensureArray(bids)); } } // Replace id representation (it would be nicer if we would not need // DBIDView at all) this.idrep = new DBIDView(this.ids); relations.add(this.idrep); getHierarchy().add(this, idrep); DBIDArrayIter it = this.ids.iter(); int numrel = bundle.metaLength(); for(int i = 0; i < numrel; i++) { SimpleTypeInformation<?> meta = bundle.meta(i); @SuppressWarnings("unchecked") SimpleTypeInformation<Object> ometa = (SimpleTypeInformation<Object>) meta; WritableDataStore<Object> store = DataStoreUtil.makeStorage(ids, DataStoreFactory.HINT_DB, ometa.getRestrictionClass()); for(it.seek(0); it.valid(); it.advance()) { store.put(it, bundle.data(it.getOffset(), i)); } Relation<?> relation = new MaterializedRelation<>(ometa, ids, null, store); relations.add(relation); getHierarchy().add(this, relation); // Try to add indexes where appropriate for(IndexFactory<?> factory : indexFactories) { if(factory.getInputTypeRestriction().isAssignableFromType(ometa)) { @SuppressWarnings("unchecked") final IndexFactory<Object> ofact = (IndexFactory<Object>) factory; @SuppressWarnings("unchecked") final Relation<Object> orep = (Relation<Object>) relation; final Index index = ofact.instantiate(orep); Duration duration = LOG.isStatistics() ? LOG.newDuration(index.getClass().getName() + ".construction").begin() : null; index.initialize(); if(duration != null) { LOG.statistics(duration.end()); } getHierarchy().add(relation, index); } } } // fire insertion event eventManager.fireObjectsInserted(ids); }
[ "@", "Override", "public", "void", "initialize", "(", ")", "{", "if", "(", "databaseConnection", "==", "null", ")", "{", "return", ";", "// Supposedly we initialized already.", "}", "if", "(", "LOG", ".", "isDebugging", "(", ")", ")", "{", "LOG", ".", "deb...
Initialize the database by getting the initial data from the database connection.
[ "Initialize", "the", "database", "by", "getting", "the", "initial", "data", "from", "the", "database", "connection", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/StaticArrayDatabase.java#L114-L180
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/spacefillingcurves/ZCurveSpatialSorter.java
ZCurveSpatialSorter.zSort
protected void zSort(List<? extends SpatialComparable> objs, int start, int end, double[] mms, int[] dims, int depth) { final int numdim = (dims != null) ? dims.length : (mms.length >> 1); final int edim = (dims != null) ? dims[depth] : depth; // Find the splitting points. final double min = mms[2 * edim], max = mms[2 * edim + 1]; double spos = (min + max) / 2.; // Safeguard against duplicate points: if(max - spos < STOPVAL || spos - min < STOPVAL) { boolean ok = false; for(int d = 0; d < numdim; d++) { int d2 = ((dims != null) ? dims[d] : d) << 1; if(mms[d2 + 1] - mms[d2] >= STOPVAL) { ok = true; break; } } if(!ok) { return; } } int split = pivotizeList1D(objs, start, end, edim, spos, false); assert (start <= split && split <= end); int nextdim = (depth + 1) % numdim; if(start < split - 1) { mms[2 * edim] = min; mms[2 * edim + 1] = spos; zSort(objs, start, split, mms, dims, nextdim); } if(split < end - 1) { mms[2 * edim] = spos; mms[2 * edim + 1] = max; zSort(objs, split, end, mms, dims, nextdim); } // Restore ranges mms[2 * edim] = min; mms[2 * edim + 1] = max; }
java
protected void zSort(List<? extends SpatialComparable> objs, int start, int end, double[] mms, int[] dims, int depth) { final int numdim = (dims != null) ? dims.length : (mms.length >> 1); final int edim = (dims != null) ? dims[depth] : depth; // Find the splitting points. final double min = mms[2 * edim], max = mms[2 * edim + 1]; double spos = (min + max) / 2.; // Safeguard against duplicate points: if(max - spos < STOPVAL || spos - min < STOPVAL) { boolean ok = false; for(int d = 0; d < numdim; d++) { int d2 = ((dims != null) ? dims[d] : d) << 1; if(mms[d2 + 1] - mms[d2] >= STOPVAL) { ok = true; break; } } if(!ok) { return; } } int split = pivotizeList1D(objs, start, end, edim, spos, false); assert (start <= split && split <= end); int nextdim = (depth + 1) % numdim; if(start < split - 1) { mms[2 * edim] = min; mms[2 * edim + 1] = spos; zSort(objs, start, split, mms, dims, nextdim); } if(split < end - 1) { mms[2 * edim] = spos; mms[2 * edim + 1] = max; zSort(objs, split, end, mms, dims, nextdim); } // Restore ranges mms[2 * edim] = min; mms[2 * edim + 1] = max; }
[ "protected", "void", "zSort", "(", "List", "<", "?", "extends", "SpatialComparable", ">", "objs", ",", "int", "start", ",", "int", "end", ",", "double", "[", "]", "mms", ",", "int", "[", "]", "dims", ",", "int", "depth", ")", "{", "final", "int", "...
The actual Z sorting function @param objs Objects to sort @param start Start @param end End @param mms Min-Max value ranges @param dims Dimensions to process @param depth Current dimension
[ "The", "actual", "Z", "sorting", "function" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/spacefillingcurves/ZCurveSpatialSorter.java#L68-L104
train
elki-project/elki
elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/ChangePoint.java
ChangePoint.appendTo
public StringBuilder appendTo(StringBuilder buf) { return buf.append(DBIDUtil.toString((DBIDRef) id)).append(" ").append(column).append(" ").append(score); }
java
public StringBuilder appendTo(StringBuilder buf) { return buf.append(DBIDUtil.toString((DBIDRef) id)).append(" ").append(column).append(" ").append(score); }
[ "public", "StringBuilder", "appendTo", "(", "StringBuilder", "buf", ")", "{", "return", "buf", ".", "append", "(", "DBIDUtil", ".", "toString", "(", "(", "DBIDRef", ")", "id", ")", ")", ".", "append", "(", "\" \"", ")", ".", "append", "(", "column", ")...
Append to a text buffer. @param buf Text buffer @return Text buffer
[ "Append", "to", "a", "text", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/ChangePoint.java#L69-L71
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/DOC.java
DOC.runDOC
protected Cluster<SubspaceModel> runDOC(Database database, Relation<V> relation, ArrayModifiableDBIDs S, final int d, int n, int m, int r, int minClusterSize) { // Best cluster for the current run. DBIDs C = null; // Relevant attributes for the best cluster. long[] D = null; // Quality of the best cluster. double quality = Double.NEGATIVE_INFINITY; // Bounds for our cluster. // ModifiableHyperBoundingBox bounds = new ModifiableHyperBoundingBox(new // double[d], new double[d]); // Inform the user about the progress in the current iteration. FiniteProgress iprogress = LOG.isVerbose() ? new FiniteProgress("Iteration progress for current cluster", m * n, LOG) : null; Random random = rnd.getSingleThreadedRandom(); DBIDArrayIter iter = S.iter(); for(int i = 0; i < n; ++i) { // Pick a random seed point. iter.seek(random.nextInt(S.size())); for(int j = 0; j < m; ++j) { // Choose a set of random points. DBIDs randomSet = DBIDUtil.randomSample(S, r, random); // Initialize cluster info. long[] nD = BitsUtil.zero(d); // Test each dimension and build bounding box. for(int k = 0; k < d; ++k) { if(dimensionIsRelevant(k, relation, randomSet)) { BitsUtil.setI(nD, k); } } if(BitsUtil.cardinality(nD) > 0) { DBIDs nC = findNeighbors(iter, nD, S, relation); if(LOG.isDebuggingFiner()) { LOG.finer("Testing a cluster candidate, |C| = " + nC.size() + ", |D| = " + BitsUtil.cardinality(nD)); } // Is the cluster large enough? if(nC.size() < minClusterSize) { // Too small. if(LOG.isDebuggingFiner()) { LOG.finer("... but it's too small."); } continue; } // Better cluster than before? double nQuality = computeClusterQuality(nC.size(), BitsUtil.cardinality(nD)); if(nQuality > quality) { if(LOG.isDebuggingFiner()) { LOG.finer("... and it's the best so far: " + nQuality + " vs. " + quality); } C = nC; D = nD; quality = nQuality; } else { if(LOG.isDebuggingFiner()) { LOG.finer("... but we already have a better one."); } } } LOG.incrementProcessed(iprogress); } } LOG.ensureCompleted(iprogress); return (C != null) ? makeCluster(relation, C, D) : null; }
java
protected Cluster<SubspaceModel> runDOC(Database database, Relation<V> relation, ArrayModifiableDBIDs S, final int d, int n, int m, int r, int minClusterSize) { // Best cluster for the current run. DBIDs C = null; // Relevant attributes for the best cluster. long[] D = null; // Quality of the best cluster. double quality = Double.NEGATIVE_INFINITY; // Bounds for our cluster. // ModifiableHyperBoundingBox bounds = new ModifiableHyperBoundingBox(new // double[d], new double[d]); // Inform the user about the progress in the current iteration. FiniteProgress iprogress = LOG.isVerbose() ? new FiniteProgress("Iteration progress for current cluster", m * n, LOG) : null; Random random = rnd.getSingleThreadedRandom(); DBIDArrayIter iter = S.iter(); for(int i = 0; i < n; ++i) { // Pick a random seed point. iter.seek(random.nextInt(S.size())); for(int j = 0; j < m; ++j) { // Choose a set of random points. DBIDs randomSet = DBIDUtil.randomSample(S, r, random); // Initialize cluster info. long[] nD = BitsUtil.zero(d); // Test each dimension and build bounding box. for(int k = 0; k < d; ++k) { if(dimensionIsRelevant(k, relation, randomSet)) { BitsUtil.setI(nD, k); } } if(BitsUtil.cardinality(nD) > 0) { DBIDs nC = findNeighbors(iter, nD, S, relation); if(LOG.isDebuggingFiner()) { LOG.finer("Testing a cluster candidate, |C| = " + nC.size() + ", |D| = " + BitsUtil.cardinality(nD)); } // Is the cluster large enough? if(nC.size() < minClusterSize) { // Too small. if(LOG.isDebuggingFiner()) { LOG.finer("... but it's too small."); } continue; } // Better cluster than before? double nQuality = computeClusterQuality(nC.size(), BitsUtil.cardinality(nD)); if(nQuality > quality) { if(LOG.isDebuggingFiner()) { LOG.finer("... and it's the best so far: " + nQuality + " vs. " + quality); } C = nC; D = nD; quality = nQuality; } else { if(LOG.isDebuggingFiner()) { LOG.finer("... but we already have a better one."); } } } LOG.incrementProcessed(iprogress); } } LOG.ensureCompleted(iprogress); return (C != null) ? makeCluster(relation, C, D) : null; }
[ "protected", "Cluster", "<", "SubspaceModel", ">", "runDOC", "(", "Database", "database", ",", "Relation", "<", "V", ">", "relation", ",", "ArrayModifiableDBIDs", "S", ",", "final", "int", "d", ",", "int", "n", ",", "int", "m", ",", "int", "r", ",", "i...
Performs a single run of DOC, finding a single cluster. @param database Database context @param relation used to get actual values for DBIDs. @param S The set of points we're working on. @param d Dimensionality of the data set we're currently working on. @param r Size of random samples. @param m Number of inner iterations (per seed point). @param n Number of outer iterations (seed points). @param minClusterSize Minimum size a cluster must have to be accepted. @return a cluster, if one is found, else <code>null</code>.
[ "Performs", "a", "single", "run", "of", "DOC", "finding", "a", "single", "cluster", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/DOC.java#L197-L269
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/DOC.java
DOC.findNeighbors
protected DBIDs findNeighbors(DBIDRef q, long[] nD, ArrayModifiableDBIDs S, Relation<V> relation) { // Weights for distance (= rectangle query) DistanceQuery<V> dq = relation.getDistanceQuery(new SubspaceMaximumDistanceFunction(nD)); // TODO: add filtering capabilities into query API! // Until then, using the range query API will be unnecessarily slow. // RangeQuery<V> rq = relation.getRangeQuery(df, DatabaseQuery.HINT_SINGLE); ArrayModifiableDBIDs nC = DBIDUtil.newArray(); for(DBIDIter it = S.iter(); it.valid(); it.advance()) { if(dq.distance(q, it) <= w) { nC.add(it); } } return nC; }
java
protected DBIDs findNeighbors(DBIDRef q, long[] nD, ArrayModifiableDBIDs S, Relation<V> relation) { // Weights for distance (= rectangle query) DistanceQuery<V> dq = relation.getDistanceQuery(new SubspaceMaximumDistanceFunction(nD)); // TODO: add filtering capabilities into query API! // Until then, using the range query API will be unnecessarily slow. // RangeQuery<V> rq = relation.getRangeQuery(df, DatabaseQuery.HINT_SINGLE); ArrayModifiableDBIDs nC = DBIDUtil.newArray(); for(DBIDIter it = S.iter(); it.valid(); it.advance()) { if(dq.distance(q, it) <= w) { nC.add(it); } } return nC; }
[ "protected", "DBIDs", "findNeighbors", "(", "DBIDRef", "q", ",", "long", "[", "]", "nD", ",", "ArrayModifiableDBIDs", "S", ",", "Relation", "<", "V", ">", "relation", ")", "{", "// Weights for distance (= rectangle query)", "DistanceQuery", "<", "V", ">", "dq", ...
Find the neighbors of point q in the given subspace @param q Query point @param nD Subspace mask @param S Remaining data points @param relation Data relation @return Neighbors
[ "Find", "the", "neighbors", "of", "point", "q", "in", "the", "given", "subspace" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/DOC.java#L280-L294
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/DOC.java
DOC.makeCluster
protected Cluster<SubspaceModel> makeCluster(Relation<V> relation, DBIDs C, long[] D) { DBIDs ids = DBIDUtil.newHashSet(C); // copy, also to lose distance values! Cluster<SubspaceModel> cluster = new Cluster<>(ids); cluster.setModel(new SubspaceModel(new Subspace(D), Centroid.make(relation, ids).getArrayRef())); return cluster; }
java
protected Cluster<SubspaceModel> makeCluster(Relation<V> relation, DBIDs C, long[] D) { DBIDs ids = DBIDUtil.newHashSet(C); // copy, also to lose distance values! Cluster<SubspaceModel> cluster = new Cluster<>(ids); cluster.setModel(new SubspaceModel(new Subspace(D), Centroid.make(relation, ids).getArrayRef())); return cluster; }
[ "protected", "Cluster", "<", "SubspaceModel", ">", "makeCluster", "(", "Relation", "<", "V", ">", "relation", ",", "DBIDs", "C", ",", "long", "[", "]", "D", ")", "{", "DBIDs", "ids", "=", "DBIDUtil", ".", "newHashSet", "(", "C", ")", ";", "// copy, als...
Utility method to create a subspace cluster from a list of DBIDs and the relevant attributes. @param relation to compute a centroid. @param C the cluster points. @param D the relevant dimensions. @return an object representing the subspace cluster.
[ "Utility", "method", "to", "create", "a", "subspace", "cluster", "from", "a", "list", "of", "DBIDs", "and", "the", "relevant", "attributes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/DOC.java#L328-L333
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/KeyVisualization.java
KeyVisualization.findDepth
protected static <M extends Model> int[] findDepth(Clustering<M> c) { final Hierarchy<Cluster<M>> hier = c.getClusterHierarchy(); int[] size = { 0, 0 }; for(It<Cluster<M>> iter = c.iterToplevelClusters(); iter.valid(); iter.advance()) { findDepth(hier, iter.get(), size); } return size; }
java
protected static <M extends Model> int[] findDepth(Clustering<M> c) { final Hierarchy<Cluster<M>> hier = c.getClusterHierarchy(); int[] size = { 0, 0 }; for(It<Cluster<M>> iter = c.iterToplevelClusters(); iter.valid(); iter.advance()) { findDepth(hier, iter.get(), size); } return size; }
[ "protected", "static", "<", "M", "extends", "Model", ">", "int", "[", "]", "findDepth", "(", "Clustering", "<", "M", ">", "c", ")", "{", "final", "Hierarchy", "<", "Cluster", "<", "M", ">", ">", "hier", "=", "c", ".", "getClusterHierarchy", "(", ")",...
Compute the size of the clustering. @param c Clustering @return Array storing the depth and the number of leaf nodes.
[ "Compute", "the", "size", "of", "the", "clustering", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/KeyVisualization.java#L93-L100
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/KeyVisualization.java
KeyVisualization.findDepth
private static <M extends Model> void findDepth(Hierarchy<Cluster<M>> hier, Cluster<M> cluster, int[] size) { if(hier.numChildren(cluster) > 0) { for(It<Cluster<M>> iter = hier.iterChildren(cluster); iter.valid(); iter.advance()) { findDepth(hier, iter.get(), size); } size[0] += 1; // Depth } else { size[1] += 1; // Leaves } }
java
private static <M extends Model> void findDepth(Hierarchy<Cluster<M>> hier, Cluster<M> cluster, int[] size) { if(hier.numChildren(cluster) > 0) { for(It<Cluster<M>> iter = hier.iterChildren(cluster); iter.valid(); iter.advance()) { findDepth(hier, iter.get(), size); } size[0] += 1; // Depth } else { size[1] += 1; // Leaves } }
[ "private", "static", "<", "M", "extends", "Model", ">", "void", "findDepth", "(", "Hierarchy", "<", "Cluster", "<", "M", ">", ">", "hier", ",", "Cluster", "<", "M", ">", "cluster", ",", "int", "[", "]", "size", ")", "{", "if", "(", "hier", ".", "...
Recursive depth computation. @param hier Hierarchy @param cluster Current cluster @param size Counting array.
[ "Recursive", "depth", "computation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/KeyVisualization.java#L109-L119
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/KeyVisualization.java
KeyVisualization.getPreferredColumns
protected static int getPreferredColumns(double width, double height, int numc, double maxwidth) { // Maximum width (compared to height) of labels - guess. // FIXME: do we really need to do this three-step computation? // Number of rows we'd use in a squared layout: final double rows = Math.ceil(FastMath.pow(numc * maxwidth, height / (width + height))); // Given this number of rows (plus one for header), use this many columns: return (int) Math.ceil(numc / (rows + 1)); }
java
protected static int getPreferredColumns(double width, double height, int numc, double maxwidth) { // Maximum width (compared to height) of labels - guess. // FIXME: do we really need to do this three-step computation? // Number of rows we'd use in a squared layout: final double rows = Math.ceil(FastMath.pow(numc * maxwidth, height / (width + height))); // Given this number of rows (plus one for header), use this many columns: return (int) Math.ceil(numc / (rows + 1)); }
[ "protected", "static", "int", "getPreferredColumns", "(", "double", "width", ",", "double", "height", ",", "int", "numc", ",", "double", "maxwidth", ")", "{", "// Maximum width (compared to height) of labels - guess.", "// FIXME: do we really need to do this three-step computat...
Compute the preferred number of columns. @param width Target width @param height Target height @param numc Number of clusters @param maxwidth Max width of entries @return Preferred number of columns
[ "Compute", "the", "preferred", "number", "of", "columns", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/KeyVisualization.java#L130-L137
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ELKIBuilder.java
ELKIBuilder.with
public ELKIBuilder<T> with(String opt, Object value) { p.addParameter(opt, value); return this; }
java
public ELKIBuilder<T> with(String opt, Object value) { p.addParameter(opt, value); return this; }
[ "public", "ELKIBuilder", "<", "T", ">", "with", "(", "String", "opt", ",", "Object", "value", ")", "{", "p", ".", "addParameter", "(", "opt", ",", "value", ")", ";", "return", "this", ";", "}" ]
Add an option to the builder. @param opt Option ID (usually found in the Parameterizer class) @param value Value @return The same builder
[ "Add", "an", "option", "to", "the", "builder", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ELKIBuilder.java#L130-L133
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ELKIBuilder.java
ELKIBuilder.build
@SuppressWarnings("unchecked") public <C extends T> C build() { if(p == null) { throw new AbortException("build() may be called only once."); } final T obj = ClassGenericsUtil.parameterizeOrAbort(clazz, p); if(p.hasUnusedParameters()) { LOG.warning("Unused parameters: " + p.getRemainingParameters()); } p = null; // Prevent build() from being called again. return (C) obj; }
java
@SuppressWarnings("unchecked") public <C extends T> C build() { if(p == null) { throw new AbortException("build() may be called only once."); } final T obj = ClassGenericsUtil.parameterizeOrAbort(clazz, p); if(p.hasUnusedParameters()) { LOG.warning("Unused parameters: " + p.getRemainingParameters()); } p = null; // Prevent build() from being called again. return (C) obj; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "C", "extends", "T", ">", "C", "build", "(", ")", "{", "if", "(", "p", "==", "null", ")", "{", "throw", "new", "AbortException", "(", "\"build() may be called only once.\"", ")", ";", "}", ...
Instantiate, consuming the parameter list. This will throw an {@link AbortException} if the parameters are incomplete, or {@code build()} is called twice. We lose some type safety here, for convenience. The type {@code <C>} is meant to be {@code <T>} with generics added only, which is necessary because generics are implemented by erasure in Java. @param <C> Output type @return Instance
[ "Instantiate", "consuming", "the", "parameter", "list", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ELKIBuilder.java#L159-L170
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/TSNE.java
TSNE.randomInitialSolution
protected static double[][] randomInitialSolution(final int size, final int dim, Random random) { double[][] sol = new double[size][dim]; for(int i = 0; i < size; i++) { for(int j = 0; j < dim; j++) { sol[i][j] = random.nextGaussian() * INITIAL_SOLUTION_SCALE; } } return sol; }
java
protected static double[][] randomInitialSolution(final int size, final int dim, Random random) { double[][] sol = new double[size][dim]; for(int i = 0; i < size; i++) { for(int j = 0; j < dim; j++) { sol[i][j] = random.nextGaussian() * INITIAL_SOLUTION_SCALE; } } return sol; }
[ "protected", "static", "double", "[", "]", "[", "]", "randomInitialSolution", "(", "final", "int", "size", ",", "final", "int", "dim", ",", "Random", "random", ")", "{", "double", "[", "]", "[", "]", "sol", "=", "new", "double", "[", "size", "]", "["...
Generate a random initial solution. @param size Data set size @param dim Output dimensionality @param random Random generator @return Initial solution matrix
[ "Generate", "a", "random", "initial", "solution", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/TSNE.java#L220-L228
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/TSNE.java
TSNE.sqDist
protected double sqDist(double[] v1, double[] v2) { assert (v1.length == v2.length) : "Lengths do not agree: " + v1.length + " " + v2.length; double sum = 0; for(int i = 0; i < v1.length; i++) { final double diff = v1[i] - v2[i]; sum += diff * diff; } ++projectedDistances; return sum; }
java
protected double sqDist(double[] v1, double[] v2) { assert (v1.length == v2.length) : "Lengths do not agree: " + v1.length + " " + v2.length; double sum = 0; for(int i = 0; i < v1.length; i++) { final double diff = v1[i] - v2[i]; sum += diff * diff; } ++projectedDistances; return sum; }
[ "protected", "double", "sqDist", "(", "double", "[", "]", "v1", ",", "double", "[", "]", "v2", ")", "{", "assert", "(", "v1", ".", "length", "==", "v2", ".", "length", ")", ":", "\"Lengths do not agree: \"", "+", "v1", ".", "length", "+", "\" \"", "+...
Squared distance, in projection space. @param v1 First vector @param v2 Second vector @return Squared distance
[ "Squared", "distance", "in", "projection", "space", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/TSNE.java#L296-L305
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/TSNE.java
TSNE.updateSolution
protected void updateSolution(double[][] sol, double[] meta, int it) { final double mom = (it < momentumSwitch && initialMomentum < finalMomentum) ? initialMomentum : finalMomentum; final int dim3 = dim * 3; for(int i = 0, off = 0; i < sol.length; i++, off += dim3) { final double[] sol_i = sol[i]; for(int k = 0; k < dim; k++) { // Indexes in meta array final int gradk = off + k, movk = gradk + dim, gaink = movk + dim; // Adjust learning rate: meta[gaink] = MathUtil.max(((meta[gradk] > 0) != (meta[movk] > 0)) ? (meta[gaink] + 0.2) : (meta[gaink] * 0.8), MIN_GAIN); meta[movk] *= mom; // Dampening the previous momentum meta[movk] -= learningRate * meta[gradk] * meta[gaink]; // Learn sol_i[k] += meta[movk]; } } }
java
protected void updateSolution(double[][] sol, double[] meta, int it) { final double mom = (it < momentumSwitch && initialMomentum < finalMomentum) ? initialMomentum : finalMomentum; final int dim3 = dim * 3; for(int i = 0, off = 0; i < sol.length; i++, off += dim3) { final double[] sol_i = sol[i]; for(int k = 0; k < dim; k++) { // Indexes in meta array final int gradk = off + k, movk = gradk + dim, gaink = movk + dim; // Adjust learning rate: meta[gaink] = MathUtil.max(((meta[gradk] > 0) != (meta[movk] > 0)) ? (meta[gaink] + 0.2) : (meta[gaink] * 0.8), MIN_GAIN); meta[movk] *= mom; // Dampening the previous momentum meta[movk] -= learningRate * meta[gradk] * meta[gaink]; // Learn sol_i[k] += meta[movk]; } } }
[ "protected", "void", "updateSolution", "(", "double", "[", "]", "[", "]", "sol", ",", "double", "[", "]", "meta", ",", "int", "it", ")", "{", "final", "double", "mom", "=", "(", "it", "<", "momentumSwitch", "&&", "initialMomentum", "<", "finalMomentum", ...
Update the current solution on iteration. @param sol Solution matrix @param meta Metadata array (gradient, momentum, learning rate) @param it Iteration number, to choose momentum factor.
[ "Update", "the", "current", "solution", "on", "iteration", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/TSNE.java#L345-L360
train
elki-project/elki
elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/distancematrix/PrecomputedSimilarityMatrix.java
PrecomputedSimilarityMatrix.getOffset
private int getOffset(int x, int y) { return (y < x) ? (triangleSize(x) + y) : (triangleSize(y) + x); }
java
private int getOffset(int x, int y) { return (y < x) ? (triangleSize(x) + y) : (triangleSize(y) + x); }
[ "private", "int", "getOffset", "(", "int", "x", ",", "int", "y", ")", "{", "return", "(", "y", "<", "x", ")", "?", "(", "triangleSize", "(", "x", ")", "+", "y", ")", ":", "(", "triangleSize", "(", "y", ")", "+", "x", ")", ";", "}" ]
Array offset computation. @param x X parameter @param y Y parameter @return Array offset
[ "Array", "offset", "computation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/distancematrix/PrecomputedSimilarityMatrix.java#L162-L164
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/weightfunctions/QuadraticStddevWeight.java
QuadraticStddevWeight.getWeight
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } double scaleddistance = distance / (scaling * stddev); // After this, the result would be negative. if(scaleddistance >= 1.0) { return 0.0; } return 1.0 - scaleddistance * scaleddistance; }
java
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } double scaleddistance = distance / (scaling * stddev); // After this, the result would be negative. if(scaleddistance >= 1.0) { return 0.0; } return 1.0 - scaleddistance * scaleddistance; }
[ "@", "Override", "public", "double", "getWeight", "(", "double", "distance", ",", "double", "max", ",", "double", "stddev", ")", "{", "if", "(", "stddev", "<=", "0", ")", "{", "return", "1", ";", "}", "double", "scaleddistance", "=", "distance", "/", "...
Evaluate weight function at given parameters. max is ignored.
[ "Evaluate", "weight", "function", "at", "given", "parameters", ".", "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/QuadraticStddevWeight.java#L43-L54
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/projector/OPTICSProjector.java
OPTICSProjector.getOPTICSPlot
public OPTICSPlot getOPTICSPlot(VisualizerContext context) { if(plot == null) { plot = OPTICSPlot.plotForClusterOrder(clusterOrder, context); } return plot; }
java
public OPTICSPlot getOPTICSPlot(VisualizerContext context) { if(plot == null) { plot = OPTICSPlot.plotForClusterOrder(clusterOrder, context); } return plot; }
[ "public", "OPTICSPlot", "getOPTICSPlot", "(", "VisualizerContext", "context", ")", "{", "if", "(", "plot", "==", "null", ")", "{", "plot", "=", "OPTICSPlot", ".", "plotForClusterOrder", "(", "clusterOrder", ",", "context", ")", ";", "}", "return", "plot", ";...
Get or produce the actual OPTICS plot. @param context Context to use @return Plot
[ "Get", "or", "produce", "the", "actual", "OPTICS", "plot", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/projector/OPTICSProjector.java#L93-L98
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Flag.java
Flag.setValue
public void setValue(boolean val) { try { super.setValue(Boolean.valueOf(val)); } catch(ParameterException e) { // We're pretty sure that any Boolean is okay, so this should never be // reached. throw new AbortException("Flag did not accept boolean value!", e); } }
java
public void setValue(boolean val) { try { super.setValue(Boolean.valueOf(val)); } catch(ParameterException e) { // We're pretty sure that any Boolean is okay, so this should never be // reached. throw new AbortException("Flag did not accept boolean value!", e); } }
[ "public", "void", "setValue", "(", "boolean", "val", ")", "{", "try", "{", "super", ".", "setValue", "(", "Boolean", ".", "valueOf", "(", "val", ")", ")", ";", "}", "catch", "(", "ParameterException", "e", ")", "{", "// We're pretty sure that any Boolean is ...
Convenience function using a native boolean, that doesn't require error handling. @param val boolean value
[ "Convenience", "function", "using", "a", "native", "boolean", "that", "doesn", "t", "require", "error", "handling", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/Flag.java#L109-L118
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LoOP.java
LoOP.run
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress(5) : null; Pair<KNNQuery<O>, KNNQuery<O>> pair = getKNNQueries(database, relation, stepprog); KNNQuery<O> knnComp = pair.getFirst(); KNNQuery<O> knnReach = pair.getSecond(); // Assert we got something if(knnComp == null) { throw new AbortException("No kNN queries supported by database for comparison distance function."); } if(knnReach == null) { throw new AbortException("No kNN queries supported by database for density estimation distance function."); } // FIXME: tie handling! // Probabilistic distances WritableDoubleDataStore pdists = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); LOG.beginStep(stepprog, 3, "Computing pdists"); computePDists(relation, knnReach, pdists); // Compute PLOF values. WritableDoubleDataStore plofs = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); LOG.beginStep(stepprog, 4, "Computing PLOF"); double nplof = computePLOFs(relation, knnComp, pdists, plofs); // Normalize the outlier scores. DoubleMinMax mm = new DoubleMinMax(); {// compute LOOP_SCORE of each db object LOG.beginStep(stepprog, 5, "Computing LoOP scores"); FiniteProgress progressLOOPs = LOG.isVerbose() ? new FiniteProgress("LoOP for objects", relation.size(), LOG) : null; final double norm = 1. / (nplof * MathUtil.SQRT2); for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { double loop = NormalDistribution.erf((plofs.doubleValue(iditer) - 1.) * norm); plofs.putDouble(iditer, loop); mm.put(loop); LOG.incrementProcessed(progressLOOPs); } LOG.ensureCompleted(progressLOOPs); } LOG.setCompleted(stepprog); // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Local Outlier Probabilities", "loop-outlier", plofs, relation.getDBIDs()); OutlierScoreMeta scoreMeta = new ProbabilisticOutlierScore(mm.getMin(), mm.getMax(), 0.); return new OutlierResult(scoreMeta, scoreResult); }
java
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress(5) : null; Pair<KNNQuery<O>, KNNQuery<O>> pair = getKNNQueries(database, relation, stepprog); KNNQuery<O> knnComp = pair.getFirst(); KNNQuery<O> knnReach = pair.getSecond(); // Assert we got something if(knnComp == null) { throw new AbortException("No kNN queries supported by database for comparison distance function."); } if(knnReach == null) { throw new AbortException("No kNN queries supported by database for density estimation distance function."); } // FIXME: tie handling! // Probabilistic distances WritableDoubleDataStore pdists = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); LOG.beginStep(stepprog, 3, "Computing pdists"); computePDists(relation, knnReach, pdists); // Compute PLOF values. WritableDoubleDataStore plofs = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); LOG.beginStep(stepprog, 4, "Computing PLOF"); double nplof = computePLOFs(relation, knnComp, pdists, plofs); // Normalize the outlier scores. DoubleMinMax mm = new DoubleMinMax(); {// compute LOOP_SCORE of each db object LOG.beginStep(stepprog, 5, "Computing LoOP scores"); FiniteProgress progressLOOPs = LOG.isVerbose() ? new FiniteProgress("LoOP for objects", relation.size(), LOG) : null; final double norm = 1. / (nplof * MathUtil.SQRT2); for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { double loop = NormalDistribution.erf((plofs.doubleValue(iditer) - 1.) * norm); plofs.putDouble(iditer, loop); mm.put(loop); LOG.incrementProcessed(progressLOOPs); } LOG.ensureCompleted(progressLOOPs); } LOG.setCompleted(stepprog); // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Local Outlier Probabilities", "loop-outlier", plofs, relation.getDBIDs()); OutlierScoreMeta scoreMeta = new ProbabilisticOutlierScore(mm.getMin(), mm.getMax(), 0.); return new OutlierResult(scoreMeta, scoreResult); }
[ "public", "OutlierResult", "run", "(", "Database", "database", ",", "Relation", "<", "O", ">", "relation", ")", "{", "StepProgress", "stepprog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "StepProgress", "(", "5", ")", ":", "null", ";", "Pair", ...
Performs the LoOP algorithm on the given database. @param database Database to process @param relation Relation to process @return Outlier result
[ "Performs", "the", "LoOP", "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/LoOP.java#L184-L232
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LoOP.java
LoOP.computePDists
protected void computePDists(Relation<O> relation, KNNQuery<O> knn, WritableDoubleDataStore pdists) { // computing PRDs FiniteProgress prdsProgress = LOG.isVerbose() ? new FiniteProgress("pdists", relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { final KNNList neighbors = knn.getKNNForDBID(iditer, kreach + 1); // + // query // point // use first kref neighbors as reference set int ks = 0; double ssum = 0.; for(DoubleDBIDListIter neighbor = neighbors.iter(); neighbor.valid() && ks < kreach; neighbor.advance()) { if(DBIDUtil.equal(neighbor, iditer)) { continue; } final double d = neighbor.doubleValue(); ssum += d * d; ks++; } double pdist = ks > 0 ? FastMath.sqrt(ssum / ks) : 0.; pdists.putDouble(iditer, pdist); LOG.incrementProcessed(prdsProgress); } LOG.ensureCompleted(prdsProgress); }
java
protected void computePDists(Relation<O> relation, KNNQuery<O> knn, WritableDoubleDataStore pdists) { // computing PRDs FiniteProgress prdsProgress = LOG.isVerbose() ? new FiniteProgress("pdists", relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { final KNNList neighbors = knn.getKNNForDBID(iditer, kreach + 1); // + // query // point // use first kref neighbors as reference set int ks = 0; double ssum = 0.; for(DoubleDBIDListIter neighbor = neighbors.iter(); neighbor.valid() && ks < kreach; neighbor.advance()) { if(DBIDUtil.equal(neighbor, iditer)) { continue; } final double d = neighbor.doubleValue(); ssum += d * d; ks++; } double pdist = ks > 0 ? FastMath.sqrt(ssum / ks) : 0.; pdists.putDouble(iditer, pdist); LOG.incrementProcessed(prdsProgress); } LOG.ensureCompleted(prdsProgress); }
[ "protected", "void", "computePDists", "(", "Relation", "<", "O", ">", "relation", ",", "KNNQuery", "<", "O", ">", "knn", ",", "WritableDoubleDataStore", "pdists", ")", "{", "// computing PRDs", "FiniteProgress", "prdsProgress", "=", "LOG", ".", "isVerbose", "(",...
Compute the probabilistic distances used by LoOP. @param relation Data relation @param knn kNN query @param pdists Storage for distances
[ "Compute", "the", "probabilistic", "distances", "used", "by", "LoOP", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LoOP.java#L241-L264
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LoOP.java
LoOP.computePLOFs
protected double computePLOFs(Relation<O> relation, KNNQuery<O> knn, WritableDoubleDataStore pdists, WritableDoubleDataStore plofs) { FiniteProgress progressPLOFs = LOG.isVerbose() ? new FiniteProgress("PLOFs for objects", relation.size(), LOG) : null; double nplof = 0.; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { final KNNList neighbors = knn.getKNNForDBID(iditer, kcomp + 1); // + query // point // use first kref neighbors as comparison set. int ks = 0; double sum = 0.; for(DBIDIter neighbor = neighbors.iter(); neighbor.valid() && ks < kcomp; neighbor.advance()) { if(DBIDUtil.equal(neighbor, iditer)) { continue; } sum += pdists.doubleValue(neighbor); ks++; } double plof = MathUtil.max(pdists.doubleValue(iditer) * ks / sum, 1.0); if(Double.isNaN(plof) || Double.isInfinite(plof)) { plof = 1.0; } plofs.putDouble(iditer, plof); nplof += (plof - 1.0) * (plof - 1.0); LOG.incrementProcessed(progressPLOFs); } LOG.ensureCompleted(progressPLOFs); nplof = lambda * FastMath.sqrt(nplof / relation.size()); if(LOG.isDebuggingFine()) { LOG.debugFine("nplof normalization factor is " + nplof); } return nplof > 0. ? nplof : 1.; }
java
protected double computePLOFs(Relation<O> relation, KNNQuery<O> knn, WritableDoubleDataStore pdists, WritableDoubleDataStore plofs) { FiniteProgress progressPLOFs = LOG.isVerbose() ? new FiniteProgress("PLOFs for objects", relation.size(), LOG) : null; double nplof = 0.; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { final KNNList neighbors = knn.getKNNForDBID(iditer, kcomp + 1); // + query // point // use first kref neighbors as comparison set. int ks = 0; double sum = 0.; for(DBIDIter neighbor = neighbors.iter(); neighbor.valid() && ks < kcomp; neighbor.advance()) { if(DBIDUtil.equal(neighbor, iditer)) { continue; } sum += pdists.doubleValue(neighbor); ks++; } double plof = MathUtil.max(pdists.doubleValue(iditer) * ks / sum, 1.0); if(Double.isNaN(plof) || Double.isInfinite(plof)) { plof = 1.0; } plofs.putDouble(iditer, plof); nplof += (plof - 1.0) * (plof - 1.0); LOG.incrementProcessed(progressPLOFs); } LOG.ensureCompleted(progressPLOFs); nplof = lambda * FastMath.sqrt(nplof / relation.size()); if(LOG.isDebuggingFine()) { LOG.debugFine("nplof normalization factor is " + nplof); } return nplof > 0. ? nplof : 1.; }
[ "protected", "double", "computePLOFs", "(", "Relation", "<", "O", ">", "relation", ",", "KNNQuery", "<", "O", ">", "knn", ",", "WritableDoubleDataStore", "pdists", ",", "WritableDoubleDataStore", "plofs", ")", "{", "FiniteProgress", "progressPLOFs", "=", "LOG", ...
Compute the LOF values, using the pdist distances. @param relation Data relation @param knn kNN query @param pdists Precomputed distances @param plofs Storage for PLOFs. @return Normalization factor.
[ "Compute", "the", "LOF", "values", "using", "the", "pdist", "distances", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/LoOP.java#L275-L307
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java
TextWriterWriterInterface.writeObject
@SuppressWarnings("unchecked") public final void writeObject(TextWriterStream out, String label, Object object) throws IOException { write(out, label, (O) object); }
java
@SuppressWarnings("unchecked") public final void writeObject(TextWriterStream out, String label, Object object) throws IOException { write(out, label, (O) object); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "final", "void", "writeObject", "(", "TextWriterStream", "out", ",", "String", "label", ",", "Object", "object", ")", "throws", "IOException", "{", "write", "(", "out", ",", "label", ",", "(", "O"...
Non-type-checking version. @param out Output stream @param label Label to prefix @param object object to output @throws IOException on IO errors
[ "Non", "-", "type", "-", "checking", "version", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java#L52-L55
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/filter/ProgressiveEigenPairFilter.java
ProgressiveEigenPairFilter.filter
@Override public int filter(double[] eigenValues) { // determine sum of eigenvalues double totalSum = 0; for(int i = 0; i < eigenValues.length; i++) { totalSum += eigenValues[i]; } double expectedVariance = totalSum / eigenValues.length * walpha; // determine strong and weak eigenpairs double currSum = 0; for(int i = 0; i < eigenValues.length - 1; i++) { // weak Eigenvector? if(eigenValues[i] < expectedVariance) { break; } currSum += eigenValues[i]; // calculate progressive alpha level double alpha = 1.0 - (1.0 - palpha) * (1.0 - (i + 1) / (double) eigenValues.length); if(currSum / totalSum >= alpha) { return i + 1; } } // the code using this method doesn't expect an empty strong set, // if we didn't find any strong ones, we make all vectors strong return eigenValues.length; }
java
@Override public int filter(double[] eigenValues) { // determine sum of eigenvalues double totalSum = 0; for(int i = 0; i < eigenValues.length; i++) { totalSum += eigenValues[i]; } double expectedVariance = totalSum / eigenValues.length * walpha; // determine strong and weak eigenpairs double currSum = 0; for(int i = 0; i < eigenValues.length - 1; i++) { // weak Eigenvector? if(eigenValues[i] < expectedVariance) { break; } currSum += eigenValues[i]; // calculate progressive alpha level double alpha = 1.0 - (1.0 - palpha) * (1.0 - (i + 1) / (double) eigenValues.length); if(currSum / totalSum >= alpha) { return i + 1; } } // the code using this method doesn't expect an empty strong set, // if we didn't find any strong ones, we make all vectors strong return eigenValues.length; }
[ "@", "Override", "public", "int", "filter", "(", "double", "[", "]", "eigenValues", ")", "{", "// determine sum of eigenvalues", "double", "totalSum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "eigenValues", ".", "length", ";", "i",...
Filter eigenpairs.
[ "Filter", "eigenpairs", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/filter/ProgressiveEigenPairFilter.java#L114-L141
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java
OutlierResult.getOutlierResults
public static List<OutlierResult> getOutlierResults(Result r) { if(r instanceof OutlierResult) { List<OutlierResult> ors = new ArrayList<>(1); ors.add((OutlierResult) r); return ors; } if(r instanceof HierarchicalResult) { return ResultUtil.filterResults(((HierarchicalResult) r).getHierarchy(), r, OutlierResult.class); } return Collections.emptyList(); }
java
public static List<OutlierResult> getOutlierResults(Result r) { if(r instanceof OutlierResult) { List<OutlierResult> ors = new ArrayList<>(1); ors.add((OutlierResult) r); return ors; } if(r instanceof HierarchicalResult) { return ResultUtil.filterResults(((HierarchicalResult) r).getHierarchy(), r, OutlierResult.class); } return Collections.emptyList(); }
[ "public", "static", "List", "<", "OutlierResult", ">", "getOutlierResults", "(", "Result", "r", ")", "{", "if", "(", "r", "instanceof", "OutlierResult", ")", "{", "List", "<", "OutlierResult", ">", "ors", "=", "new", "ArrayList", "<>", "(", "1", ")", ";"...
Collect all outlier results from a Result @param r Result @return List of outlier results
[ "Collect", "all", "outlier", "results", "from", "a", "Result" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java#L111-L121
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java
OutlierResult.evaluateBy
double evaluateBy(ScoreEvaluation eval) { return eval.evaluate(new DBIDsTest(DBIDUtil.ensureSet(scores.getDBIDs())), new OutlierScoreAdapter(this)); }
java
double evaluateBy(ScoreEvaluation eval) { return eval.evaluate(new DBIDsTest(DBIDUtil.ensureSet(scores.getDBIDs())), new OutlierScoreAdapter(this)); }
[ "double", "evaluateBy", "(", "ScoreEvaluation", "eval", ")", "{", "return", "eval", ".", "evaluate", "(", "new", "DBIDsTest", "(", "DBIDUtil", ".", "ensureSet", "(", "scores", ".", "getDBIDs", "(", ")", ")", ")", ",", "new", "OutlierScoreAdapter", "(", "th...
Evaluate given a set of positives and a scoring. @param eval Evaluation measure @return Score
[ "Evaluate", "given", "a", "set", "of", "positives", "and", "a", "scoring", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java#L129-L131
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/minkowski/SquaredEuclideanDistanceFunction.java
SquaredEuclideanDistanceFunction.distance
public double distance(double[] v1, double[] v2) { final int dim1 = v1.length, dim2 = v2.length; final int mindim = dim1 < dim2 ? dim1 : dim2; double agg = preDistance(v1, v2, 0, mindim); if(dim1 > mindim) { agg += preNorm(v1, mindim, dim1); } else if(dim2 > mindim) { agg += preNorm(v2, mindim, dim2); } return agg; }
java
public double distance(double[] v1, double[] v2) { final int dim1 = v1.length, dim2 = v2.length; final int mindim = dim1 < dim2 ? dim1 : dim2; double agg = preDistance(v1, v2, 0, mindim); if(dim1 > mindim) { agg += preNorm(v1, mindim, dim1); } else if(dim2 > mindim) { agg += preNorm(v2, mindim, dim2); } return agg; }
[ "public", "double", "distance", "(", "double", "[", "]", "v1", ",", "double", "[", "]", "v2", ")", "{", "final", "int", "dim1", "=", "v1", ".", "length", ",", "dim2", "=", "v2", ".", "length", ";", "final", "int", "mindim", "=", "dim1", "<", "dim...
Special version for double arrays.
[ "Special", "version", "for", "double", "arrays", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/minkowski/SquaredEuclideanDistanceFunction.java#L149-L160
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/SimpleCircularMSTLayout3DPC.java
SimpleCircularMSTLayout3DPC.computeWeights
private void computeWeights(Node node) { int wsum = 0; for(Node child : node.children) { computeWeights(child); wsum += child.weight; } node.weight = Math.max(1, wsum); }
java
private void computeWeights(Node node) { int wsum = 0; for(Node child : node.children) { computeWeights(child); wsum += child.weight; } node.weight = Math.max(1, wsum); }
[ "private", "void", "computeWeights", "(", "Node", "node", ")", "{", "int", "wsum", "=", "0", ";", "for", "(", "Node", "child", ":", "node", ".", "children", ")", "{", "computeWeights", "(", "child", ")", ";", "wsum", "+=", "child", ".", "weight", ";"...
Recursively assign node weights. @param node Node to start with.
[ "Recursively", "assign", "node", "weights", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/SimpleCircularMSTLayout3DPC.java#L96-L103
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/pairsegments/ClusterPairSegmentAnalysis.java
ClusterPairSegmentAnalysis.processNewResult
@Override public void processNewResult(ResultHierarchy hier, Result result) { // Get all new clusterings // TODO: handle clusterings added later, too. Can we update the result? List<Clustering<?>> clusterings = Clustering.getClusteringResults(result); // Abort if not enough clusterings to compare if(clusterings.size() < 2) { return; } // create segments Segments segments = new Segments(clusterings); hier.add(result, segments); }
java
@Override public void processNewResult(ResultHierarchy hier, Result result) { // Get all new clusterings // TODO: handle clusterings added later, too. Can we update the result? List<Clustering<?>> clusterings = Clustering.getClusteringResults(result); // Abort if not enough clusterings to compare if(clusterings.size() < 2) { return; } // create segments Segments segments = new Segments(clusterings); hier.add(result, segments); }
[ "@", "Override", "public", "void", "processNewResult", "(", "ResultHierarchy", "hier", ",", "Result", "result", ")", "{", "// Get all new clusterings", "// TODO: handle clusterings added later, too. Can we update the result?", "List", "<", "Clustering", "<", "?", ">", ">", ...
Perform clusterings evaluation
[ "Perform", "clusterings", "evaluation" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/pairsegments/ClusterPairSegmentAnalysis.java#L65-L79
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java
VALPNormDistance.getPartialMinDist
public double getPartialMinDist(int dimension, int vp) { final int qp = queryApprox.getApproximation(dimension); if(vp < qp) { return lookup[dimension][vp + 1]; } else if(vp > qp) { return lookup[dimension][vp]; } else { return 0.0; } }
java
public double getPartialMinDist(int dimension, int vp) { final int qp = queryApprox.getApproximation(dimension); if(vp < qp) { return lookup[dimension][vp + 1]; } else if(vp > qp) { return lookup[dimension][vp]; } else { return 0.0; } }
[ "public", "double", "getPartialMinDist", "(", "int", "dimension", ",", "int", "vp", ")", "{", "final", "int", "qp", "=", "queryApprox", ".", "getApproximation", "(", "dimension", ")", ";", "if", "(", "vp", "<", "qp", ")", "{", "return", "lookup", "[", ...
Get the minimum distance contribution of a single dimension. @param dimension Dimension @param vp Vector position @return Increment
[ "Get", "the", "minimum", "distance", "contribution", "of", "a", "single", "dimension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java#L70-L81
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java
VALPNormDistance.getMinDist
public double getMinDist(VectorApproximation vec) { final int dim = lookup.length; double minDist = 0; for(int d = 0; d < dim; d++) { final int vp = vec.getApproximation(d); minDist += getPartialMinDist(d, vp); } return FastMath.pow(minDist, onebyp); }
java
public double getMinDist(VectorApproximation vec) { final int dim = lookup.length; double minDist = 0; for(int d = 0; d < dim; d++) { final int vp = vec.getApproximation(d); minDist += getPartialMinDist(d, vp); } return FastMath.pow(minDist, onebyp); }
[ "public", "double", "getMinDist", "(", "VectorApproximation", "vec", ")", "{", "final", "int", "dim", "=", "lookup", ".", "length", ";", "double", "minDist", "=", "0", ";", "for", "(", "int", "d", "=", "0", ";", "d", "<", "dim", ";", "d", "++", ")"...
Get the minimum distance to approximated vector vec. @param vec Vector approximation @return Minimum distance
[ "Get", "the", "minimum", "distance", "to", "approximated", "vector", "vec", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java#L89-L97
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java
VALPNormDistance.getPartialMaxDist
public double getPartialMaxDist(int dimension, int vp) { final int qp = queryApprox.getApproximation(dimension); if(vp < qp) { return lookup[dimension][vp]; } else if(vp > qp) { return lookup[dimension][vp + 1]; } else { return Math.max(lookup[dimension][vp], lookup[dimension][vp + 1]); } }
java
public double getPartialMaxDist(int dimension, int vp) { final int qp = queryApprox.getApproximation(dimension); if(vp < qp) { return lookup[dimension][vp]; } else if(vp > qp) { return lookup[dimension][vp + 1]; } else { return Math.max(lookup[dimension][vp], lookup[dimension][vp + 1]); } }
[ "public", "double", "getPartialMaxDist", "(", "int", "dimension", ",", "int", "vp", ")", "{", "final", "int", "qp", "=", "queryApprox", ".", "getApproximation", "(", "dimension", ")", ";", "if", "(", "vp", "<", "qp", ")", "{", "return", "lookup", "[", ...
Get the maximum distance contribution of a single dimension. @param dimension Dimension @param vp Vector position @return Increment
[ "Get", "the", "maximum", "distance", "contribution", "of", "a", "single", "dimension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java#L106-L117
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java
VALPNormDistance.initializeLookupTable
private void initializeLookupTable(double[][] splitPositions, NumberVector query, double p) { final int dimensions = splitPositions.length; final int bordercount = splitPositions[0].length; lookup = new double[dimensions][bordercount]; for(int d = 0; d < dimensions; d++) { final double val = query.doubleValue(d); for(int i = 0; i < bordercount; i++) { lookup[d][i] = FastMath.pow(splitPositions[d][i] - val, p); } } }
java
private void initializeLookupTable(double[][] splitPositions, NumberVector query, double p) { final int dimensions = splitPositions.length; final int bordercount = splitPositions[0].length; lookup = new double[dimensions][bordercount]; for(int d = 0; d < dimensions; d++) { final double val = query.doubleValue(d); for(int i = 0; i < bordercount; i++) { lookup[d][i] = FastMath.pow(splitPositions[d][i] - val, p); } } }
[ "private", "void", "initializeLookupTable", "(", "double", "[", "]", "[", "]", "splitPositions", ",", "NumberVector", "query", ",", "double", "p", ")", "{", "final", "int", "dimensions", "=", "splitPositions", ".", "length", ";", "final", "int", "bordercount",...
Initialize the lookup table. @param splitPositions Split positions @param query Query vector @param p p
[ "Initialize", "the", "lookup", "table", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VALPNormDistance.java#L157-L167
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizerContext.java
VisualizerContext.makeStyleResult
protected void makeStyleResult(StyleLibrary stylelib) { final Database db = ResultUtil.findDatabase(hier); stylelibrary = stylelib; List<Clustering<? extends Model>> clusterings = Clustering.getClusteringResults(db); if(!clusterings.isEmpty()) { stylepolicy = new ClusterStylingPolicy(clusterings.get(0), stylelib); } else { Clustering<Model> c = generateDefaultClustering(); stylepolicy = new ClusterStylingPolicy(c, stylelib); } }
java
protected void makeStyleResult(StyleLibrary stylelib) { final Database db = ResultUtil.findDatabase(hier); stylelibrary = stylelib; List<Clustering<? extends Model>> clusterings = Clustering.getClusteringResults(db); if(!clusterings.isEmpty()) { stylepolicy = new ClusterStylingPolicy(clusterings.get(0), stylelib); } else { Clustering<Model> c = generateDefaultClustering(); stylepolicy = new ClusterStylingPolicy(c, stylelib); } }
[ "protected", "void", "makeStyleResult", "(", "StyleLibrary", "stylelib", ")", "{", "final", "Database", "db", "=", "ResultUtil", ".", "findDatabase", "(", "hier", ")", ";", "stylelibrary", "=", "stylelib", ";", "List", "<", "Clustering", "<", "?", "extends", ...
Generate a new style result for the given style library. @param stylelib Style library
[ "Generate", "a", "new", "style", "result", "for", "the", "given", "style", "library", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizerContext.java#L171-L182
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizerContext.java
VisualizerContext.contentChanged
@Override public void contentChanged(DataStoreEvent e) { for(int i = 0; i < listenerList.size(); i++) { listenerList.get(i).contentChanged(e); } }
java
@Override public void contentChanged(DataStoreEvent e) { for(int i = 0; i < listenerList.size(); i++) { listenerList.get(i).contentChanged(e); } }
[ "@", "Override", "public", "void", "contentChanged", "(", "DataStoreEvent", "e", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listenerList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "listenerList", ".", "get", "(", "i", ")", ...
Proxy datastore event to child listeners.
[ "Proxy", "datastore", "event", "to", "child", "listeners", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizerContext.java#L311-L316
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizerContext.java
VisualizerContext.notifyFactories
private void notifyFactories(Object item) { for(VisualizationProcessor f : factories) { try { f.processNewResult(this, item); } catch(Throwable e) { LOG.warning("VisFactory " + f.getClass().getCanonicalName() + " failed:", e); } } }
java
private void notifyFactories(Object item) { for(VisualizationProcessor f : factories) { try { f.processNewResult(this, item); } catch(Throwable e) { LOG.warning("VisFactory " + f.getClass().getCanonicalName() + " failed:", e); } } }
[ "private", "void", "notifyFactories", "(", "Object", "item", ")", "{", "for", "(", "VisualizationProcessor", "f", ":", "factories", ")", "{", "try", "{", "f", ".", "processNewResult", "(", "this", ",", "item", ")", ";", "}", "catch", "(", "Throwable", "e...
Notify factories of a change. @param item Item that has changed.
[ "Notify", "factories", "of", "a", "change", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizerContext.java#L399-L408
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/AbstractBulkSplit.java
AbstractBulkSplit.chooseBulkSplitPoint
protected int chooseBulkSplitPoint(int numEntries, int minEntries, int maxEntries) { if(numEntries < minEntries) { throw new IllegalArgumentException("numEntries < minEntries!"); } if(numEntries <= maxEntries) { return numEntries; } else if(numEntries < maxEntries + minEntries) { return (numEntries - minEntries); } else { return maxEntries; } }
java
protected int chooseBulkSplitPoint(int numEntries, int minEntries, int maxEntries) { if(numEntries < minEntries) { throw new IllegalArgumentException("numEntries < minEntries!"); } if(numEntries <= maxEntries) { return numEntries; } else if(numEntries < maxEntries + minEntries) { return (numEntries - minEntries); } else { return maxEntries; } }
[ "protected", "int", "chooseBulkSplitPoint", "(", "int", "numEntries", ",", "int", "minEntries", ",", "int", "maxEntries", ")", "{", "if", "(", "numEntries", "<", "minEntries", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"numEntries < minEntries!\"",...
Computes and returns the best split point. @param numEntries the number of entries to be split @param minEntries the number of minimum entries in the node to be split @param maxEntries number of maximum entries in the node to be split @return the best split point
[ "Computes", "and", "returns", "the", "best", "split", "point", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/AbstractBulkSplit.java#L47-L61
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/AbstractBulkSplit.java
AbstractBulkSplit.trivialPartition
protected <T> List<List<T>> trivialPartition(List<T> objects, int minEntries, int maxEntries) { // build partitions final int size = objects.size(); final int numberPartitions = (int) Math.ceil(((double) size) / maxEntries); List<List<T>> partitions = new ArrayList<>(numberPartitions); int start = 0; for(int pnum = 0; pnum < numberPartitions; pnum++) { int end = (int) ((pnum + 1.) * size / numberPartitions); if(pnum == numberPartitions - 1) { end = size; } assert ((end - start) >= minEntries && (end - start) <= maxEntries); partitions.add(objects.subList(start, end)); start = end; } return partitions; }
java
protected <T> List<List<T>> trivialPartition(List<T> objects, int minEntries, int maxEntries) { // build partitions final int size = objects.size(); final int numberPartitions = (int) Math.ceil(((double) size) / maxEntries); List<List<T>> partitions = new ArrayList<>(numberPartitions); int start = 0; for(int pnum = 0; pnum < numberPartitions; pnum++) { int end = (int) ((pnum + 1.) * size / numberPartitions); if(pnum == numberPartitions - 1) { end = size; } assert ((end - start) >= minEntries && (end - start) <= maxEntries); partitions.add(objects.subList(start, end)); start = end; } return partitions; }
[ "protected", "<", "T", ">", "List", "<", "List", "<", "T", ">", ">", "trivialPartition", "(", "List", "<", "T", ">", "objects", ",", "int", "minEntries", ",", "int", "maxEntries", ")", "{", "// build partitions", "final", "int", "size", "=", "objects", ...
Perform the trivial partitioning of the given list. @param objects Objects to partition @param minEntries Minimum number of objects per page @param maxEntries Maximum number of objects per page. @return List with partitions
[ "Perform", "the", "trivial", "partitioning", "of", "the", "given", "list", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/AbstractBulkSplit.java#L71-L87
train
elki-project/elki
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java
HashmapDatabase.alignColumns
protected Relation<?>[] alignColumns(ObjectBundle pack) { // align representations. Relation<?>[] targets = new Relation<?>[pack.metaLength()]; long[] used = BitsUtil.zero(relations.size()); for(int i = 0; i < targets.length; i++) { SimpleTypeInformation<?> meta = pack.meta(i); // TODO: aggressively try to match exact metas first? // Try to match unused representations only for(int j = BitsUtil.nextClearBit(used, 0); j >= 0 && j < relations.size(); j = BitsUtil.nextClearBit(used, j + 1)) { Relation<?> relation = relations.get(j); if(relation.getDataTypeInformation().isAssignableFromType(meta)) { targets[i] = relation; BitsUtil.setI(used, j); break; } } if(targets[i] == null) { targets[i] = addNewRelation(meta); BitsUtil.setI(used, relations.size() - 1); } } return targets; }
java
protected Relation<?>[] alignColumns(ObjectBundle pack) { // align representations. Relation<?>[] targets = new Relation<?>[pack.metaLength()]; long[] used = BitsUtil.zero(relations.size()); for(int i = 0; i < targets.length; i++) { SimpleTypeInformation<?> meta = pack.meta(i); // TODO: aggressively try to match exact metas first? // Try to match unused representations only for(int j = BitsUtil.nextClearBit(used, 0); j >= 0 && j < relations.size(); j = BitsUtil.nextClearBit(used, j + 1)) { Relation<?> relation = relations.get(j); if(relation.getDataTypeInformation().isAssignableFromType(meta)) { targets[i] = relation; BitsUtil.setI(used, j); break; } } if(targets[i] == null) { targets[i] = addNewRelation(meta); BitsUtil.setI(used, relations.size() - 1); } } return targets; }
[ "protected", "Relation", "<", "?", ">", "[", "]", "alignColumns", "(", "ObjectBundle", "pack", ")", "{", "// align representations.", "Relation", "<", "?", ">", "[", "]", "targets", "=", "new", "Relation", "<", "?", ">", "[", "pack", ".", "metaLength", "...
Find a mapping from package columns to database columns, eventually adding new database columns when needed. @param pack Package to process @return Column mapping
[ "Find", "a", "mapping", "from", "package", "columns", "to", "database", "columns", "eventually", "adding", "new", "database", "columns", "when", "needed", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java#L170-L192
train
elki-project/elki
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java
HashmapDatabase.addNewRelation
private Relation<?> addNewRelation(SimpleTypeInformation<?> meta) { @SuppressWarnings("unchecked") SimpleTypeInformation<Object> ometa = (SimpleTypeInformation<Object>) meta; Relation<?> relation = new MaterializedRelation<>(ometa, ids); relations.add(relation); getHierarchy().add(this, relation); // Try to add indexes where appropriate for(IndexFactory<?> factory : indexFactories) { if(factory.getInputTypeRestriction().isAssignableFromType(meta)) { @SuppressWarnings("unchecked") final IndexFactory<Object> ofact = (IndexFactory<Object>) factory; @SuppressWarnings("unchecked") final Relation<Object> orep = (Relation<Object>) relation; Index index = ofact.instantiate(orep); index.initialize(); getHierarchy().add(relation, index); } } return relation; }
java
private Relation<?> addNewRelation(SimpleTypeInformation<?> meta) { @SuppressWarnings("unchecked") SimpleTypeInformation<Object> ometa = (SimpleTypeInformation<Object>) meta; Relation<?> relation = new MaterializedRelation<>(ometa, ids); relations.add(relation); getHierarchy().add(this, relation); // Try to add indexes where appropriate for(IndexFactory<?> factory : indexFactories) { if(factory.getInputTypeRestriction().isAssignableFromType(meta)) { @SuppressWarnings("unchecked") final IndexFactory<Object> ofact = (IndexFactory<Object>) factory; @SuppressWarnings("unchecked") final Relation<Object> orep = (Relation<Object>) relation; Index index = ofact.instantiate(orep); index.initialize(); getHierarchy().add(relation, index); } } return relation; }
[ "private", "Relation", "<", "?", ">", "addNewRelation", "(", "SimpleTypeInformation", "<", "?", ">", "meta", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "SimpleTypeInformation", "<", "Object", ">", "ometa", "=", "(", "SimpleTypeInformation", "<...
Add a new representation for the given meta. @param meta meta data @return new representation
[ "Add", "a", "new", "representation", "for", "the", "given", "meta", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java#L200-L219
train
elki-project/elki
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java
HashmapDatabase.doDelete
private void doDelete(DBIDRef id) { // Remove id ids.remove(id); // Remove from all representations. for(Relation<?> relation : relations) { // ID has already been removed, and this would loop... if(relation == idrep) { continue; } if(!(relation instanceof ModifiableRelation)) { throw new AbortException("Non-modifiable relations have been added to the database."); } ((ModifiableRelation<?>) relation).delete(id); } DBIDFactory.FACTORY.deallocateSingleDBID(id); }
java
private void doDelete(DBIDRef id) { // Remove id ids.remove(id); // Remove from all representations. for(Relation<?> relation : relations) { // ID has already been removed, and this would loop... if(relation == idrep) { continue; } if(!(relation instanceof ModifiableRelation)) { throw new AbortException("Non-modifiable relations have been added to the database."); } ((ModifiableRelation<?>) relation).delete(id); } DBIDFactory.FACTORY.deallocateSingleDBID(id); }
[ "private", "void", "doDelete", "(", "DBIDRef", "id", ")", "{", "// Remove id", "ids", ".", "remove", "(", "id", ")", ";", "// Remove from all representations.", "for", "(", "Relation", "<", "?", ">", "relation", ":", "relations", ")", "{", "// ID has already b...
Removes the object with the specified id from this database. @param id id the id of the object to be removed
[ "Removes", "the", "object", "with", "the", "specified", "id", "from", "this", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java#L274-L289
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.greedy
private ArrayDBIDs greedy(DistanceQuery<V> distFunc, DBIDs sampleSet, int m, Random random) { ArrayModifiableDBIDs medoids = DBIDUtil.newArray(m); ArrayModifiableDBIDs s = DBIDUtil.newArray(sampleSet); DBIDArrayIter iter = s.iter(); DBIDVar m_i = DBIDUtil.newVar(); int size = s.size(); // Move a random element to the end, then pop() s.swap(random.nextInt(size), --size); medoids.add(s.pop(m_i)); if(LOG.isDebugging()) { LOG.debugFiner("medoids " + medoids.toString()); } // To track the current worst element: int worst = -1; double worstd = Double.NEGATIVE_INFINITY; // compute distances between each point in S and m_i WritableDoubleDataStore distances = DataStoreUtil.makeDoubleStorage(s, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); for(iter.seek(0); iter.getOffset() < size; iter.advance()) { final double dist = distFunc.distance(iter, m_i); distances.putDouble(iter, dist); if(dist > worstd) { worstd = dist; worst = iter.getOffset(); } } for(int i = 1; i < m; i++) { // choose medoid m_i to be far from previous medoids s.swap(worst, --size); medoids.add(s.pop(m_i)); // compute distances of each point to closest medoid; track worst. worst = -1; worstd = Double.NEGATIVE_INFINITY; for(iter.seek(0); iter.getOffset() < size; iter.advance()) { double dist_new = distFunc.distance(iter, m_i); double dist_old = distances.doubleValue(iter); double dist = (dist_new < dist_old) ? dist_new : dist_old; distances.putDouble(iter, dist); if(dist > worstd) { worstd = dist; worst = iter.getOffset(); } } if(LOG.isDebugging()) { LOG.debugFiner("medoids " + medoids.toString()); } } return medoids; }
java
private ArrayDBIDs greedy(DistanceQuery<V> distFunc, DBIDs sampleSet, int m, Random random) { ArrayModifiableDBIDs medoids = DBIDUtil.newArray(m); ArrayModifiableDBIDs s = DBIDUtil.newArray(sampleSet); DBIDArrayIter iter = s.iter(); DBIDVar m_i = DBIDUtil.newVar(); int size = s.size(); // Move a random element to the end, then pop() s.swap(random.nextInt(size), --size); medoids.add(s.pop(m_i)); if(LOG.isDebugging()) { LOG.debugFiner("medoids " + medoids.toString()); } // To track the current worst element: int worst = -1; double worstd = Double.NEGATIVE_INFINITY; // compute distances between each point in S and m_i WritableDoubleDataStore distances = DataStoreUtil.makeDoubleStorage(s, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); for(iter.seek(0); iter.getOffset() < size; iter.advance()) { final double dist = distFunc.distance(iter, m_i); distances.putDouble(iter, dist); if(dist > worstd) { worstd = dist; worst = iter.getOffset(); } } for(int i = 1; i < m; i++) { // choose medoid m_i to be far from previous medoids s.swap(worst, --size); medoids.add(s.pop(m_i)); // compute distances of each point to closest medoid; track worst. worst = -1; worstd = Double.NEGATIVE_INFINITY; for(iter.seek(0); iter.getOffset() < size; iter.advance()) { double dist_new = distFunc.distance(iter, m_i); double dist_old = distances.doubleValue(iter); double dist = (dist_new < dist_old) ? dist_new : dist_old; distances.putDouble(iter, dist); if(dist > worstd) { worstd = dist; worst = iter.getOffset(); } } if(LOG.isDebugging()) { LOG.debugFiner("medoids " + medoids.toString()); } } return medoids; }
[ "private", "ArrayDBIDs", "greedy", "(", "DistanceQuery", "<", "V", ">", "distFunc", ",", "DBIDs", "sampleSet", ",", "int", "m", ",", "Random", "random", ")", "{", "ArrayModifiableDBIDs", "medoids", "=", "DBIDUtil", ".", "newArray", "(", "m", ")", ";", "Arr...
Returns a piercing set of k medoids from the specified sample set. @param distFunc the distance function @param sampleSet the sample set @param m the number of medoids to be returned @param random random number generator @return a piercing set of m medoids from the specified sample set
[ "Returns", "a", "piercing", "set", "of", "k", "medoids", "from", "the", "specified", "sample", "set", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L233-L288
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.initialSet
private ArrayDBIDs initialSet(DBIDs sampleSet, int k, Random random) { return DBIDUtil.ensureArray(DBIDUtil.randomSample(sampleSet, k, random)); }
java
private ArrayDBIDs initialSet(DBIDs sampleSet, int k, Random random) { return DBIDUtil.ensureArray(DBIDUtil.randomSample(sampleSet, k, random)); }
[ "private", "ArrayDBIDs", "initialSet", "(", "DBIDs", "sampleSet", ",", "int", "k", ",", "Random", "random", ")", "{", "return", "DBIDUtil", ".", "ensureArray", "(", "DBIDUtil", ".", "randomSample", "(", "sampleSet", ",", "k", ",", "random", ")", ")", ";", ...
Returns a set of k elements from the specified sample set. @param sampleSet the sample set @param k the number of samples to be returned @param random random number generator @return a set of k elements from the specified sample set
[ "Returns", "a", "set", "of", "k", "elements", "from", "the", "specified", "sample", "set", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L298-L300
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.computeM_current
private ArrayDBIDs computeM_current(DBIDs m, DBIDs m_best, DBIDs m_bad, Random random) { ArrayModifiableDBIDs m_list = DBIDUtil.newArray(m); m_list.removeDBIDs(m_best); DBIDArrayMIter it = m_list.iter(); ArrayModifiableDBIDs m_current = DBIDUtil.newArray(); for(DBIDIter iter = m_best.iter(); iter.valid(); iter.advance()) { if(m_bad.contains(iter)) { int currentSize = m_current.size(); while(m_current.size() == currentSize) { m_current.add(it.seek(random.nextInt(m_list.size()))); it.remove(); } } else { m_current.add(iter); } } return m_current; }
java
private ArrayDBIDs computeM_current(DBIDs m, DBIDs m_best, DBIDs m_bad, Random random) { ArrayModifiableDBIDs m_list = DBIDUtil.newArray(m); m_list.removeDBIDs(m_best); DBIDArrayMIter it = m_list.iter(); ArrayModifiableDBIDs m_current = DBIDUtil.newArray(); for(DBIDIter iter = m_best.iter(); iter.valid(); iter.advance()) { if(m_bad.contains(iter)) { int currentSize = m_current.size(); while(m_current.size() == currentSize) { m_current.add(it.seek(random.nextInt(m_list.size()))); it.remove(); } } else { m_current.add(iter); } } return m_current; }
[ "private", "ArrayDBIDs", "computeM_current", "(", "DBIDs", "m", ",", "DBIDs", "m_best", ",", "DBIDs", "m_bad", ",", "Random", "random", ")", "{", "ArrayModifiableDBIDs", "m_list", "=", "DBIDUtil", ".", "newArray", "(", "m", ")", ";", "m_list", ".", "removeDB...
Computes the set of medoids in current iteration. @param m the medoids @param m_best the best set of medoids found so far @param m_bad the bad medoids @param random random number generator @return m_current, the set of medoids in current iteration
[ "Computes", "the", "set", "of", "medoids", "in", "current", "iteration", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L311-L331
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.findDimensions
private long[][] findDimensions(ArrayDBIDs medoids, Relation<V> database, DistanceQuery<V> distFunc, RangeQuery<V> rangeQuery) { // get localities DataStore<DBIDs> localities = getLocalities(medoids, distFunc, rangeQuery); // compute x_ij = avg distance from points in l_i to medoid m_i final int dim = RelationUtil.dimensionality(database); final int numc = medoids.size(); double[][] averageDistances = new double[numc][]; for(DBIDArrayIter iter = medoids.iter(); iter.valid(); iter.advance()) { V medoid_i = database.get(iter); DBIDs l_i = localities.get(iter); double[] x_i = new double[dim]; for(DBIDIter qr = l_i.iter(); qr.valid(); qr.advance()) { V o = database.get(qr); for(int d = 0; d < dim; d++) { x_i[d] += Math.abs(medoid_i.doubleValue(d) - o.doubleValue(d)); } } for(int d = 0; d < dim; d++) { x_i[d] /= l_i.size(); } averageDistances[iter.getOffset()] = x_i; } List<DoubleIntInt> z_ijs = computeZijs(averageDistances, dim); return computeDimensionMap(z_ijs, dim, numc); }
java
private long[][] findDimensions(ArrayDBIDs medoids, Relation<V> database, DistanceQuery<V> distFunc, RangeQuery<V> rangeQuery) { // get localities DataStore<DBIDs> localities = getLocalities(medoids, distFunc, rangeQuery); // compute x_ij = avg distance from points in l_i to medoid m_i final int dim = RelationUtil.dimensionality(database); final int numc = medoids.size(); double[][] averageDistances = new double[numc][]; for(DBIDArrayIter iter = medoids.iter(); iter.valid(); iter.advance()) { V medoid_i = database.get(iter); DBIDs l_i = localities.get(iter); double[] x_i = new double[dim]; for(DBIDIter qr = l_i.iter(); qr.valid(); qr.advance()) { V o = database.get(qr); for(int d = 0; d < dim; d++) { x_i[d] += Math.abs(medoid_i.doubleValue(d) - o.doubleValue(d)); } } for(int d = 0; d < dim; d++) { x_i[d] /= l_i.size(); } averageDistances[iter.getOffset()] = x_i; } List<DoubleIntInt> z_ijs = computeZijs(averageDistances, dim); return computeDimensionMap(z_ijs, dim, numc); }
[ "private", "long", "[", "]", "[", "]", "findDimensions", "(", "ArrayDBIDs", "medoids", ",", "Relation", "<", "V", ">", "database", ",", "DistanceQuery", "<", "V", ">", "distFunc", ",", "RangeQuery", "<", "V", ">", "rangeQuery", ")", "{", "// get localities...
Determines the set of correlated dimensions for each medoid in the specified medoid set. @param medoids the set of medoids @param database the database containing the objects @param distFunc the distance function @return the set of correlated dimensions for each medoid in the specified medoid set
[ "Determines", "the", "set", "of", "correlated", "dimensions", "for", "each", "medoid", "in", "the", "specified", "medoid", "set", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L378-L405
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.findDimensions
private List<Pair<double[], long[]>> findDimensions(ArrayList<PROCLUSCluster> clusters, Relation<V> database) { // compute x_ij = avg distance from points in c_i to c_i.centroid final int dim = RelationUtil.dimensionality(database); final int numc = clusters.size(); double[][] averageDistances = new double[numc][]; for(int i = 0; i < numc; i++) { PROCLUSCluster c_i = clusters.get(i); double[] x_i = new double[dim]; for(DBIDIter iter = c_i.objectIDs.iter(); iter.valid(); iter.advance()) { V o = database.get(iter); for(int d = 0; d < dim; d++) { x_i[d] += Math.abs(c_i.centroid[d] - o.doubleValue(d)); } } for(int d = 0; d < dim; d++) { x_i[d] /= c_i.objectIDs.size(); } averageDistances[i] = x_i; } List<DoubleIntInt> z_ijs = computeZijs(averageDistances, dim); long[][] dimensionMap = computeDimensionMap(z_ijs, dim, numc); // mapping cluster -> dimensions List<Pair<double[], long[]>> result = new ArrayList<>(numc); for(int i = 0; i < numc; i++) { long[] dims_i = dimensionMap[i]; if(dims_i == null) { continue; } result.add(new Pair<>(clusters.get(i).centroid, dims_i)); } return result; }
java
private List<Pair<double[], long[]>> findDimensions(ArrayList<PROCLUSCluster> clusters, Relation<V> database) { // compute x_ij = avg distance from points in c_i to c_i.centroid final int dim = RelationUtil.dimensionality(database); final int numc = clusters.size(); double[][] averageDistances = new double[numc][]; for(int i = 0; i < numc; i++) { PROCLUSCluster c_i = clusters.get(i); double[] x_i = new double[dim]; for(DBIDIter iter = c_i.objectIDs.iter(); iter.valid(); iter.advance()) { V o = database.get(iter); for(int d = 0; d < dim; d++) { x_i[d] += Math.abs(c_i.centroid[d] - o.doubleValue(d)); } } for(int d = 0; d < dim; d++) { x_i[d] /= c_i.objectIDs.size(); } averageDistances[i] = x_i; } List<DoubleIntInt> z_ijs = computeZijs(averageDistances, dim); long[][] dimensionMap = computeDimensionMap(z_ijs, dim, numc); // mapping cluster -> dimensions List<Pair<double[], long[]>> result = new ArrayList<>(numc); for(int i = 0; i < numc; i++) { long[] dims_i = dimensionMap[i]; if(dims_i == null) { continue; } result.add(new Pair<>(clusters.get(i).centroid, dims_i)); } return result; }
[ "private", "List", "<", "Pair", "<", "double", "[", "]", ",", "long", "[", "]", ">", ">", "findDimensions", "(", "ArrayList", "<", "PROCLUSCluster", ">", "clusters", ",", "Relation", "<", "V", ">", "database", ")", "{", "// compute x_ij = avg distance from p...
Refinement step that determines the set of correlated dimensions for each cluster centroid. @param clusters the list of clusters @param database the database containing the objects @return the set of correlated dimensions for each specified cluster centroid
[ "Refinement", "step", "that", "determines", "the", "set", "of", "correlated", "dimensions", "for", "each", "cluster", "centroid", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L416-L450
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.computeZijs
private List<DoubleIntInt> computeZijs(double[][] averageDistances, final int dim) { List<DoubleIntInt> z_ijs = new ArrayList<>(averageDistances.length * dim); for(int i = 0; i < averageDistances.length; i++) { double[] x_i = averageDistances[i]; // y_i double y_i = 0; for(int j = 0; j < dim; j++) { y_i += x_i[j]; } y_i /= dim; // sigma_i double sigma_i = 0; for(int j = 0; j < dim; j++) { double diff = x_i[j] - y_i; sigma_i += diff * diff; } sigma_i /= (dim - 1); sigma_i = FastMath.sqrt(sigma_i); for(int j = 0; j < dim; j++) { z_ijs.add(new DoubleIntInt((x_i[j] - y_i) / sigma_i, i, j)); } } Collections.sort(z_ijs); return z_ijs; }
java
private List<DoubleIntInt> computeZijs(double[][] averageDistances, final int dim) { List<DoubleIntInt> z_ijs = new ArrayList<>(averageDistances.length * dim); for(int i = 0; i < averageDistances.length; i++) { double[] x_i = averageDistances[i]; // y_i double y_i = 0; for(int j = 0; j < dim; j++) { y_i += x_i[j]; } y_i /= dim; // sigma_i double sigma_i = 0; for(int j = 0; j < dim; j++) { double diff = x_i[j] - y_i; sigma_i += diff * diff; } sigma_i /= (dim - 1); sigma_i = FastMath.sqrt(sigma_i); for(int j = 0; j < dim; j++) { z_ijs.add(new DoubleIntInt((x_i[j] - y_i) / sigma_i, i, j)); } } Collections.sort(z_ijs); return z_ijs; }
[ "private", "List", "<", "DoubleIntInt", ">", "computeZijs", "(", "double", "[", "]", "[", "]", "averageDistances", ",", "final", "int", "dim", ")", "{", "List", "<", "DoubleIntInt", ">", "z_ijs", "=", "new", "ArrayList", "<>", "(", "averageDistances", ".",...
Compute the z_ij values. @param averageDistances Average distances @param dim Dimensions @return z_ij values
[ "Compute", "the", "z_ij", "values", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L459-L485
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.computeDimensionMap
private long[][] computeDimensionMap(List<DoubleIntInt> z_ijs, final int dim, final int numc) { // mapping cluster index -> dimensions long[][] dimensionMap = new long[numc][((dim - 1) >> 6) + 1]; int max = Math.max(k * l, 2); for(int m = 0; m < max; m++) { DoubleIntInt z_ij = z_ijs.get(m); long[] dims_i = dimensionMap[z_ij.dimi]; BitsUtil.setI(dims_i, z_ij.dimj); if(LOG.isDebugging()) { LOG.debugFiner(new StringBuilder().append("z_ij ").append(z_ij).append('\n') // .append("D_i ").append(BitsUtil.toString(dims_i)).toString()); } } return dimensionMap; }
java
private long[][] computeDimensionMap(List<DoubleIntInt> z_ijs, final int dim, final int numc) { // mapping cluster index -> dimensions long[][] dimensionMap = new long[numc][((dim - 1) >> 6) + 1]; int max = Math.max(k * l, 2); for(int m = 0; m < max; m++) { DoubleIntInt z_ij = z_ijs.get(m); long[] dims_i = dimensionMap[z_ij.dimi]; BitsUtil.setI(dims_i, z_ij.dimj); if(LOG.isDebugging()) { LOG.debugFiner(new StringBuilder().append("z_ij ").append(z_ij).append('\n') // .append("D_i ").append(BitsUtil.toString(dims_i)).toString()); } } return dimensionMap; }
[ "private", "long", "[", "]", "[", "]", "computeDimensionMap", "(", "List", "<", "DoubleIntInt", ">", "z_ijs", ",", "final", "int", "dim", ",", "final", "int", "numc", ")", "{", "// mapping cluster index -> dimensions", "long", "[", "]", "[", "]", "dimensionM...
Compute the dimension map. @param z_ijs z_ij values @param dim Number of dimensions @param numc Number of clusters @return Bitmap of dimensions used
[ "Compute", "the", "dimension", "map", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L495-L510
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.assignPoints
private ArrayList<PROCLUSCluster> assignPoints(ArrayDBIDs m_current, long[][] dimensions, Relation<V> database) { ModifiableDBIDs[] clusterIDs = new ModifiableDBIDs[dimensions.length]; for(int i = 0; i < m_current.size(); i++) { clusterIDs[i] = DBIDUtil.newHashSet(); } DBIDArrayIter m_i = m_current.iter(); for(DBIDIter it = database.iterDBIDs(); it.valid(); it.advance()) { V p = database.get(it); double minDist = Double.NaN; int best = -1, i = 0; for(m_i.seek(0); m_i.valid(); m_i.advance(), i++) { V m = database.get(m_i); double currentDist = manhattanSegmentalDistance(p, m, dimensions[i]); if(!(minDist <= currentDist)) { minDist = currentDist; best = i; } } // add p to cluster with mindist assert best >= 0; clusterIDs[best].add(it); } ArrayList<PROCLUSCluster> clusters = new ArrayList<>(m_current.size()); for(int i = 0; i < dimensions.length; i++) { ModifiableDBIDs objectIDs = clusterIDs[i]; if(!objectIDs.isEmpty()) { long[] clusterDimensions = dimensions[i]; double[] centroid = Centroid.make(database, objectIDs).getArrayRef(); clusters.add(new PROCLUSCluster(objectIDs, clusterDimensions, centroid)); } else { clusters.add(null); } } if(LOG.isDebugging()) { LOG.debugFine(new StringBuilder().append("clusters ").append(clusters).toString()); } return clusters; }
java
private ArrayList<PROCLUSCluster> assignPoints(ArrayDBIDs m_current, long[][] dimensions, Relation<V> database) { ModifiableDBIDs[] clusterIDs = new ModifiableDBIDs[dimensions.length]; for(int i = 0; i < m_current.size(); i++) { clusterIDs[i] = DBIDUtil.newHashSet(); } DBIDArrayIter m_i = m_current.iter(); for(DBIDIter it = database.iterDBIDs(); it.valid(); it.advance()) { V p = database.get(it); double minDist = Double.NaN; int best = -1, i = 0; for(m_i.seek(0); m_i.valid(); m_i.advance(), i++) { V m = database.get(m_i); double currentDist = manhattanSegmentalDistance(p, m, dimensions[i]); if(!(minDist <= currentDist)) { minDist = currentDist; best = i; } } // add p to cluster with mindist assert best >= 0; clusterIDs[best].add(it); } ArrayList<PROCLUSCluster> clusters = new ArrayList<>(m_current.size()); for(int i = 0; i < dimensions.length; i++) { ModifiableDBIDs objectIDs = clusterIDs[i]; if(!objectIDs.isEmpty()) { long[] clusterDimensions = dimensions[i]; double[] centroid = Centroid.make(database, objectIDs).getArrayRef(); clusters.add(new PROCLUSCluster(objectIDs, clusterDimensions, centroid)); } else { clusters.add(null); } } if(LOG.isDebugging()) { LOG.debugFine(new StringBuilder().append("clusters ").append(clusters).toString()); } return clusters; }
[ "private", "ArrayList", "<", "PROCLUSCluster", ">", "assignPoints", "(", "ArrayDBIDs", "m_current", ",", "long", "[", "]", "[", "]", "dimensions", ",", "Relation", "<", "V", ">", "database", ")", "{", "ModifiableDBIDs", "[", "]", "clusterIDs", "=", "new", ...
Assigns the objects to the clusters. @param m_current Current centers @param dimensions set of correlated dimensions for each medoid of the cluster @param database the database containing the objects @return the assignments of the object to the clusters
[ "Assigns", "the", "objects", "to", "the", "clusters", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L521-L562
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.finalAssignment
private List<PROCLUSCluster> finalAssignment(List<Pair<double[], long[]>> dimensions, Relation<V> database) { Map<Integer, ModifiableDBIDs> clusterIDs = new HashMap<>(); for(int i = 0; i < dimensions.size(); i++) { clusterIDs.put(i, DBIDUtil.newHashSet()); } for(DBIDIter it = database.iterDBIDs(); it.valid(); it.advance()) { V p = database.get(it); double minDist = Double.POSITIVE_INFINITY; int best = -1; for(int i = 0; i < dimensions.size(); i++) { Pair<double[], long[]> pair_i = dimensions.get(i); double currentDist = manhattanSegmentalDistance(p, pair_i.first, pair_i.second); if(best < 0 || currentDist < minDist) { minDist = currentDist; best = i; } } // add p to cluster with mindist assert minDist >= 0.; clusterIDs.get(best).add(it); } List<PROCLUSCluster> clusters = new ArrayList<>(); for(int i = 0; i < dimensions.size(); i++) { ModifiableDBIDs objectIDs = clusterIDs.get(i); if(!objectIDs.isEmpty()) { long[] clusterDimensions = dimensions.get(i).second; double[] centroid = Centroid.make(database, objectIDs).getArrayRef(); clusters.add(new PROCLUSCluster(objectIDs, clusterDimensions, centroid)); } } if(LOG.isDebugging()) { LOG.debugFine(new StringBuilder().append("clusters ").append(clusters).toString()); } return clusters; }
java
private List<PROCLUSCluster> finalAssignment(List<Pair<double[], long[]>> dimensions, Relation<V> database) { Map<Integer, ModifiableDBIDs> clusterIDs = new HashMap<>(); for(int i = 0; i < dimensions.size(); i++) { clusterIDs.put(i, DBIDUtil.newHashSet()); } for(DBIDIter it = database.iterDBIDs(); it.valid(); it.advance()) { V p = database.get(it); double minDist = Double.POSITIVE_INFINITY; int best = -1; for(int i = 0; i < dimensions.size(); i++) { Pair<double[], long[]> pair_i = dimensions.get(i); double currentDist = manhattanSegmentalDistance(p, pair_i.first, pair_i.second); if(best < 0 || currentDist < minDist) { minDist = currentDist; best = i; } } // add p to cluster with mindist assert minDist >= 0.; clusterIDs.get(best).add(it); } List<PROCLUSCluster> clusters = new ArrayList<>(); for(int i = 0; i < dimensions.size(); i++) { ModifiableDBIDs objectIDs = clusterIDs.get(i); if(!objectIDs.isEmpty()) { long[] clusterDimensions = dimensions.get(i).second; double[] centroid = Centroid.make(database, objectIDs).getArrayRef(); clusters.add(new PROCLUSCluster(objectIDs, clusterDimensions, centroid)); } } if(LOG.isDebugging()) { LOG.debugFine(new StringBuilder().append("clusters ").append(clusters).toString()); } return clusters; }
[ "private", "List", "<", "PROCLUSCluster", ">", "finalAssignment", "(", "List", "<", "Pair", "<", "double", "[", "]", ",", "long", "[", "]", ">", ">", "dimensions", ",", "Relation", "<", "V", ">", "database", ")", "{", "Map", "<", "Integer", ",", "Mod...
Refinement step to assign the objects to the final clusters. @param dimensions pair containing the centroid and the set of correlated dimensions for the centroid @param database the database containing the objects @return the assignments of the object to the clusters
[ "Refinement", "step", "to", "assign", "the", "objects", "to", "the", "final", "clusters", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L572-L609
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.manhattanSegmentalDistance
private double manhattanSegmentalDistance(NumberVector o1, double[] o2, long[] dimensions) { double result = 0; int card = 0; for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) { result += Math.abs(o1.doubleValue(d) - o2[d]); ++card; } return result / card; }
java
private double manhattanSegmentalDistance(NumberVector o1, double[] o2, long[] dimensions) { double result = 0; int card = 0; for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) { result += Math.abs(o1.doubleValue(d) - o2[d]); ++card; } return result / card; }
[ "private", "double", "manhattanSegmentalDistance", "(", "NumberVector", "o1", ",", "double", "[", "]", "o2", ",", "long", "[", "]", "dimensions", ")", "{", "double", "result", "=", "0", ";", "int", "card", "=", "0", ";", "for", "(", "int", "d", "=", ...
Returns the Manhattan segmental distance between o1 and o2 relative to the specified dimensions. @param o1 the first object @param o2 the second object @param dimensions the dimensions to be considered @return the Manhattan segmental distance between o1 and o2 relative to the specified dimensions
[ "Returns", "the", "Manhattan", "segmental", "distance", "between", "o1", "and", "o2", "relative", "to", "the", "specified", "dimensions", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L641-L649
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.evaluateClusters
private double evaluateClusters(ArrayList<PROCLUSCluster> clusters, long[][] dimensions, Relation<V> database) { double result = 0; for(int i = 0; i < dimensions.length; i++) { PROCLUSCluster c_i = clusters.get(i); double[] centroid_i = c_i.centroid; long[] dims_i = dimensions[i]; double w_i = 0; for(int d = BitsUtil.nextSetBit(dims_i, 0); d >= 0; d = BitsUtil.nextSetBit(dims_i, d + 1)) { w_i += avgDistance(centroid_i, c_i.objectIDs, database, d); } w_i /= dimensions.length; result += c_i.objectIDs.size() * w_i; } return result / database.size(); }
java
private double evaluateClusters(ArrayList<PROCLUSCluster> clusters, long[][] dimensions, Relation<V> database) { double result = 0; for(int i = 0; i < dimensions.length; i++) { PROCLUSCluster c_i = clusters.get(i); double[] centroid_i = c_i.centroid; long[] dims_i = dimensions[i]; double w_i = 0; for(int d = BitsUtil.nextSetBit(dims_i, 0); d >= 0; d = BitsUtil.nextSetBit(dims_i, d + 1)) { w_i += avgDistance(centroid_i, c_i.objectIDs, database, d); } w_i /= dimensions.length; result += c_i.objectIDs.size() * w_i; } return result / database.size(); }
[ "private", "double", "evaluateClusters", "(", "ArrayList", "<", "PROCLUSCluster", ">", "clusters", ",", "long", "[", "]", "[", "]", "dimensions", ",", "Relation", "<", "V", ">", "database", ")", "{", "double", "result", "=", "0", ";", "for", "(", "int", ...
Evaluates the quality of the clusters. @param clusters the clusters to be evaluated @param dimensions the dimensions associated with each cluster @param database the database holding the objects @return a measure for the cluster quality
[ "Evaluates", "the", "quality", "of", "the", "clusters", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L659-L676
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.avgDistance
private double avgDistance(double[] centroid, DBIDs objectIDs, Relation<V> database, int dimension) { Mean avg = new Mean(); for(DBIDIter iter = objectIDs.iter(); iter.valid(); iter.advance()) { V o = database.get(iter); avg.put(Math.abs(centroid[dimension] - o.doubleValue(dimension))); } return avg.getMean(); }
java
private double avgDistance(double[] centroid, DBIDs objectIDs, Relation<V> database, int dimension) { Mean avg = new Mean(); for(DBIDIter iter = objectIDs.iter(); iter.valid(); iter.advance()) { V o = database.get(iter); avg.put(Math.abs(centroid[dimension] - o.doubleValue(dimension))); } return avg.getMean(); }
[ "private", "double", "avgDistance", "(", "double", "[", "]", "centroid", ",", "DBIDs", "objectIDs", ",", "Relation", "<", "V", ">", "database", ",", "int", "dimension", ")", "{", "Mean", "avg", "=", "new", "Mean", "(", ")", ";", "for", "(", "DBIDIter",...
Computes the average distance of the objects to the centroid along the specified dimension. @param centroid the centroid @param objectIDs the set of objects ids @param database the database holding the objects @param dimension the dimension for which the average distance is computed @return the average distance of the objects to the centroid along the specified dimension
[ "Computes", "the", "average", "distance", "of", "the", "objects", "to", "the", "centroid", "along", "the", "specified", "dimension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L689-L696
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java
PROCLUS.computeBadMedoids
private DBIDs computeBadMedoids(ArrayDBIDs m_current, ArrayList<PROCLUSCluster> clusters, int threshold) { ModifiableDBIDs badMedoids = DBIDUtil.newHashSet(m_current.size()); int i = 0; for(DBIDIter it = m_current.iter(); it.valid(); it.advance(), i++) { PROCLUSCluster c_i = clusters.get(i); if(c_i == null || c_i.objectIDs.size() < threshold) { badMedoids.add(it); } } return badMedoids; }
java
private DBIDs computeBadMedoids(ArrayDBIDs m_current, ArrayList<PROCLUSCluster> clusters, int threshold) { ModifiableDBIDs badMedoids = DBIDUtil.newHashSet(m_current.size()); int i = 0; for(DBIDIter it = m_current.iter(); it.valid(); it.advance(), i++) { PROCLUSCluster c_i = clusters.get(i); if(c_i == null || c_i.objectIDs.size() < threshold) { badMedoids.add(it); } } return badMedoids; }
[ "private", "DBIDs", "computeBadMedoids", "(", "ArrayDBIDs", "m_current", ",", "ArrayList", "<", "PROCLUSCluster", ">", "clusters", ",", "int", "threshold", ")", "{", "ModifiableDBIDs", "badMedoids", "=", "DBIDUtil", ".", "newHashSet", "(", "m_current", ".", "size"...
Computes the bad medoids, where the medoid of a cluster with less than the specified threshold of objects is bad. @param m_current Current medoids @param clusters the clusters @param threshold the threshold @return the bad medoids
[ "Computes", "the", "bad", "medoids", "where", "the", "medoid", "of", "a", "cluster", "with", "less", "than", "the", "specified", "threshold", "of", "objects", "is", "bad", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L707-L717
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/Bit.java
Bit.valueOf
public static Bit valueOf(String bit) throws NumberFormatException { final int i = ParseUtil.parseIntBase10(bit); if(i != 0 && i != 1) { throw new NumberFormatException("Input \"" + bit + "\" must be 0 or 1."); } return (i > 0) ? TRUE : FALSE; }
java
public static Bit valueOf(String bit) throws NumberFormatException { final int i = ParseUtil.parseIntBase10(bit); if(i != 0 && i != 1) { throw new NumberFormatException("Input \"" + bit + "\" must be 0 or 1."); } return (i > 0) ? TRUE : FALSE; }
[ "public", "static", "Bit", "valueOf", "(", "String", "bit", ")", "throws", "NumberFormatException", "{", "final", "int", "i", "=", "ParseUtil", ".", "parseIntBase10", "(", "bit", ")", ";", "if", "(", "i", "!=", "0", "&&", "i", "!=", "1", ")", "{", "t...
Method to construct a Bit for a given String expression. @param bit a String expression defining a Bit @return a Bit as defined by the given String expression @throws NumberFormatException if the given String expression does not fit the defined pattern.
[ "Method", "to", "construct", "a", "Bit", "for", "a", "given", "String", "expression", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/Bit.java#L62-L68
train
elki-project/elki
elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java
OfflineChangePointDetectionAlgorithm.run
public ChangePoints run(Relation<DoubleVector> relation) { if(!(relation.getDBIDs() instanceof ArrayDBIDs)) { throw new AbortException("This implementation may only be used on static databases, with ArrayDBIDs to provide a clear order."); } return new Instance(rnd.getSingleThreadedRandom()).run(relation); }
java
public ChangePoints run(Relation<DoubleVector> relation) { if(!(relation.getDBIDs() instanceof ArrayDBIDs)) { throw new AbortException("This implementation may only be used on static databases, with ArrayDBIDs to provide a clear order."); } return new Instance(rnd.getSingleThreadedRandom()).run(relation); }
[ "public", "ChangePoints", "run", "(", "Relation", "<", "DoubleVector", ">", "relation", ")", "{", "if", "(", "!", "(", "relation", ".", "getDBIDs", "(", ")", "instanceof", "ArrayDBIDs", ")", ")", "{", "throw", "new", "AbortException", "(", "\"This implementa...
Executes multiple change point detection for given relation @param relation the relation to process @return list with all the detected change point for every time series
[ "Executes", "multiple", "change", "point", "detection", "for", "given", "relation" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java#L133-L138
train
elki-project/elki
elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java
OfflineChangePointDetectionAlgorithm.cusum
public static void cusum(double[] data, double[] out, int begin, int end) { assert (out.length >= data.length); // Use Kahan summation for better precision! // FIXME: this should be unit tested. double m = 0., carry = 0.; for(int i = begin; i < end; i++) { double v = data[i] - carry; // Compensation double n = out[i] = (m + v); // May lose small digits of v. carry = (n - m) - v; // Recover lost bits m = n; } }
java
public static void cusum(double[] data, double[] out, int begin, int end) { assert (out.length >= data.length); // Use Kahan summation for better precision! // FIXME: this should be unit tested. double m = 0., carry = 0.; for(int i = begin; i < end; i++) { double v = data[i] - carry; // Compensation double n = out[i] = (m + v); // May lose small digits of v. carry = (n - m) - v; // Recover lost bits m = n; } }
[ "public", "static", "void", "cusum", "(", "double", "[", "]", "data", ",", "double", "[", "]", "out", ",", "int", "begin", ",", "int", "end", ")", "{", "assert", "(", "out", ".", "length", ">=", "data", ".", "length", ")", ";", "// Use Kahan summatio...
Compute the incremental sum of an array, i.e. the sum of all points up to the given index. @param data Input data @param out Output array (must be large enough).
[ "Compute", "the", "incremental", "sum", "of", "an", "array", "i", ".", "e", ".", "the", "sum", "of", "all", "points", "up", "to", "the", "given", "index", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java#L274-L285
train
elki-project/elki
elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java
OfflineChangePointDetectionAlgorithm.bestChangeInMean
public static DoubleIntPair bestChangeInMean(double[] sums, int begin, int end) { final int len = end - begin, last = end - 1; final double suml = begin > 0 ? sums[begin - 1] : 0.; final double sumr = sums[last]; int bestpos = begin; double bestscore = Double.NEGATIVE_INFINITY; // Iterate elements k=2..n-1 in math notation_ for(int j = begin, km1 = 1; j < last; j++, km1++) { assert (km1 < len); // FIXME: remove eventually final double sumj = sums[j]; // Sum _inclusive_ j'th element. // Derive the left mean and right mean from the precomputed aggregates: final double lmean = (sumj - suml) / km1; final double rmean = (sumr - sumj) / (len - km1); // Equation 2.6.17 from the Basseville book final double dm = lmean - rmean; final double score = km1 * (double) (len - km1) * dm * dm; if(score > bestscore) { bestpos = j + 1; bestscore = score; } } return new DoubleIntPair(bestscore, bestpos); }
java
public static DoubleIntPair bestChangeInMean(double[] sums, int begin, int end) { final int len = end - begin, last = end - 1; final double suml = begin > 0 ? sums[begin - 1] : 0.; final double sumr = sums[last]; int bestpos = begin; double bestscore = Double.NEGATIVE_INFINITY; // Iterate elements k=2..n-1 in math notation_ for(int j = begin, km1 = 1; j < last; j++, km1++) { assert (km1 < len); // FIXME: remove eventually final double sumj = sums[j]; // Sum _inclusive_ j'th element. // Derive the left mean and right mean from the precomputed aggregates: final double lmean = (sumj - suml) / km1; final double rmean = (sumr - sumj) / (len - km1); // Equation 2.6.17 from the Basseville book final double dm = lmean - rmean; final double score = km1 * (double) (len - km1) * dm * dm; if(score > bestscore) { bestpos = j + 1; bestscore = score; } } return new DoubleIntPair(bestscore, bestpos); }
[ "public", "static", "DoubleIntPair", "bestChangeInMean", "(", "double", "[", "]", "sums", ",", "int", "begin", ",", "int", "end", ")", "{", "final", "int", "len", "=", "end", "-", "begin", ",", "last", "=", "end", "-", "1", ";", "final", "double", "s...
Find the best position to assume a change in mean. @param sums Cumulative sums @param begin Interval begin @param end Interval end @return Best change position
[ "Find", "the", "best", "position", "to", "assume", "a", "change", "in", "mean", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java#L295-L318
train
elki-project/elki
elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java
OfflineChangePointDetectionAlgorithm.shuffle
public static void shuffle(double[] bstrap, int len, Random rnd) { int i = len; while(i > 0) { final int r = rnd.nextInt(i); --i; // Swap double tmp = bstrap[r]; bstrap[r] = bstrap[i]; bstrap[i] = tmp; } }
java
public static void shuffle(double[] bstrap, int len, Random rnd) { int i = len; while(i > 0) { final int r = rnd.nextInt(i); --i; // Swap double tmp = bstrap[r]; bstrap[r] = bstrap[i]; bstrap[i] = tmp; } }
[ "public", "static", "void", "shuffle", "(", "double", "[", "]", "bstrap", ",", "int", "len", ",", "Random", "rnd", ")", "{", "int", "i", "=", "len", ";", "while", "(", "i", ">", "0", ")", "{", "final", "int", "r", "=", "rnd", ".", "nextInt", "(...
Fisher-Yates shuffle of a partial array @param bstrap Data to shuffle @param len Length of valid data @param rnd Random generator
[ "Fisher", "-", "Yates", "shuffle", "of", "a", "partial", "array" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/OfflineChangePointDetectionAlgorithm.java#L327-L337
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/ObjHistogram.java
ObjHistogram.get
@SuppressWarnings("unchecked") public T get(double coord) { if(coord == Double.NEGATIVE_INFINITY) { return getSpecial(0); } if(coord == Double.POSITIVE_INFINITY) { return getSpecial(1); } if(Double.isNaN(coord)) { return getSpecial(2); } int bin = getBinNr(coord); if(bin < 0) { if(size - bin > data.length) { // Reallocate. TODO: use an arraylist-like grow strategy! Object[] tmpdata = new Object[growSize(data.length, size - bin)]; System.arraycopy(data, 0, tmpdata, -bin, size); data = tmpdata; } else { // Shift in place System.arraycopy(data, 0, data, -bin, size); } for(int i = 0; i < -bin; i++) { data[i] = supplier.make(); } // Note that bin is negative, -bin is the shift offset! offset -= bin; size -= bin; // TODO: modCounter++; and have iterators fast-fail // Unset max value when resizing max = Double.MAX_VALUE; return (T) data[0]; } else if(bin >= size) { if(bin >= data.length) { Object[] tmpdata = new Object[growSize(data.length, bin + 1)]; System.arraycopy(data, 0, tmpdata, 0, size); data = tmpdata; } for(int i = size; i <= bin; i++) { data[i] = supplier.make(); } size = bin + 1; // TODO: modCounter++; and have iterators fast-fail // Unset max value when resizing max = Double.MAX_VALUE; return (T) data[bin]; } else { return (T) data[bin]; } }
java
@SuppressWarnings("unchecked") public T get(double coord) { if(coord == Double.NEGATIVE_INFINITY) { return getSpecial(0); } if(coord == Double.POSITIVE_INFINITY) { return getSpecial(1); } if(Double.isNaN(coord)) { return getSpecial(2); } int bin = getBinNr(coord); if(bin < 0) { if(size - bin > data.length) { // Reallocate. TODO: use an arraylist-like grow strategy! Object[] tmpdata = new Object[growSize(data.length, size - bin)]; System.arraycopy(data, 0, tmpdata, -bin, size); data = tmpdata; } else { // Shift in place System.arraycopy(data, 0, data, -bin, size); } for(int i = 0; i < -bin; i++) { data[i] = supplier.make(); } // Note that bin is negative, -bin is the shift offset! offset -= bin; size -= bin; // TODO: modCounter++; and have iterators fast-fail // Unset max value when resizing max = Double.MAX_VALUE; return (T) data[0]; } else if(bin >= size) { if(bin >= data.length) { Object[] tmpdata = new Object[growSize(data.length, bin + 1)]; System.arraycopy(data, 0, tmpdata, 0, size); data = tmpdata; } for(int i = size; i <= bin; i++) { data[i] = supplier.make(); } size = bin + 1; // TODO: modCounter++; and have iterators fast-fail // Unset max value when resizing max = Double.MAX_VALUE; return (T) data[bin]; } else { return (T) data[bin]; } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "T", "get", "(", "double", "coord", ")", "{", "if", "(", "coord", "==", "Double", ".", "NEGATIVE_INFINITY", ")", "{", "return", "getSpecial", "(", "0", ")", ";", "}", "if", "(", "coord", "==...
Access the value of a bin with new data. @param coord Coordinate @return bin contents
[ "Access", "the", "value", "of", "a", "bin", "with", "new", "data", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/ObjHistogram.java#L78-L130
train
elki-project/elki
elki-precomputed/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/external/FileBasedSparseFloatDistanceFunction.java
FileBasedSparseFloatDistanceFunction.loadCache
protected void loadCache(int size, InputStream in) throws IOException { // Expect a sparse matrix here cache = new Long2FloatOpenHashMap(size * 20); cache.defaultReturnValue(Float.POSITIVE_INFINITY); min = Integer.MAX_VALUE; max = Integer.MIN_VALUE; parser.parse(in, new DistanceCacheWriter() { @Override public void put(int id1, int id2, double distance) { if(id1 < id2) { min = id1 < min ? id1 : min; max = id2 > max ? id2 : max; } else { min = id2 < min ? id2 : min; max = id1 > max ? id1 : max; } cache.put(makeKey(id1, id2), (float) distance); } }); if(min != 0) { LOG.verbose("Distance matrix is supposed to be 0-indexed. Choosing offset " + min + " to compensate."); } if(max + 1 - min != size) { LOG.warning("ID range is not consistent with relation size."); } }
java
protected void loadCache(int size, InputStream in) throws IOException { // Expect a sparse matrix here cache = new Long2FloatOpenHashMap(size * 20); cache.defaultReturnValue(Float.POSITIVE_INFINITY); min = Integer.MAX_VALUE; max = Integer.MIN_VALUE; parser.parse(in, new DistanceCacheWriter() { @Override public void put(int id1, int id2, double distance) { if(id1 < id2) { min = id1 < min ? id1 : min; max = id2 > max ? id2 : max; } else { min = id2 < min ? id2 : min; max = id1 > max ? id1 : max; } cache.put(makeKey(id1, id2), (float) distance); } }); if(min != 0) { LOG.verbose("Distance matrix is supposed to be 0-indexed. Choosing offset " + min + " to compensate."); } if(max + 1 - min != size) { LOG.warning("ID range is not consistent with relation size."); } }
[ "protected", "void", "loadCache", "(", "int", "size", ",", "InputStream", "in", ")", "throws", "IOException", "{", "// Expect a sparse matrix here", "cache", "=", "new", "Long2FloatOpenHashMap", "(", "size", "*", "20", ")", ";", "cache", ".", "defaultReturnValue",...
Fill cache from an input stream. @param size Expected size @param in Input stream @throws IOException
[ "Fill", "cache", "from", "an", "input", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-precomputed/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/external/FileBasedSparseFloatDistanceFunction.java#L130-L156
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.svgElement
public Element svgElement(String name, String cssclass) { Element elem = SVGUtil.svgElement(document, name); if(cssclass != null) { elem.setAttribute(SVGConstants.SVG_CLASS_ATTRIBUTE, cssclass); } return elem; }
java
public Element svgElement(String name, String cssclass) { Element elem = SVGUtil.svgElement(document, name); if(cssclass != null) { elem.setAttribute(SVGConstants.SVG_CLASS_ATTRIBUTE, cssclass); } return elem; }
[ "public", "Element", "svgElement", "(", "String", "name", ",", "String", "cssclass", ")", "{", "Element", "elem", "=", "SVGUtil", ".", "svgElement", "(", "document", ",", "name", ")", ";", "if", "(", "cssclass", "!=", "null", ")", "{", "elem", ".", "se...
Create a SVG element in the SVG namespace. Non-static version. @param name node name @param cssclass CSS class @return new SVG element.
[ "Create", "a", "SVG", "element", "in", "the", "SVG", "namespace", ".", "Non", "-", "static", "version", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L237-L243
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.svgRect
public Element svgRect(double x, double y, double w, double h) { return SVGUtil.svgRect(document, x, y, w, h); }
java
public Element svgRect(double x, double y, double w, double h) { return SVGUtil.svgRect(document, x, y, w, h); }
[ "public", "Element", "svgRect", "(", "double", "x", ",", "double", "y", ",", "double", "w", ",", "double", "h", ")", "{", "return", "SVGUtil", ".", "svgRect", "(", "document", ",", "x", ",", "y", ",", "w", ",", "h", ")", ";", "}" ]
Create a SVG rectangle @param x X coordinate @param y Y coordinate @param w Width @param h Height @return new element
[ "Create", "a", "SVG", "rectangle" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L254-L256
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.svgCircle
public Element svgCircle(double cx, double cy, double r) { return SVGUtil.svgCircle(document, cx, cy, r); }
java
public Element svgCircle(double cx, double cy, double r) { return SVGUtil.svgCircle(document, cx, cy, r); }
[ "public", "Element", "svgCircle", "(", "double", "cx", ",", "double", "cy", ",", "double", "r", ")", "{", "return", "SVGUtil", ".", "svgCircle", "(", "document", ",", "cx", ",", "cy", ",", "r", ")", ";", "}" ]
Create a SVG circle @param cx center X @param cy center Y @param r radius @return new element
[ "Create", "a", "SVG", "circle" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L266-L268
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.svgLine
public Element svgLine(double x1, double y1, double x2, double y2) { return SVGUtil.svgLine(document, x1, y1, x2, y2); }
java
public Element svgLine(double x1, double y1, double x2, double y2) { return SVGUtil.svgLine(document, x1, y1, x2, y2); }
[ "public", "Element", "svgLine", "(", "double", "x1", ",", "double", "y1", ",", "double", "x2", ",", "double", "y2", ")", "{", "return", "SVGUtil", ".", "svgLine", "(", "document", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ";", "}" ]
Create a SVG line element @param x1 first point x @param y1 first point y @param x2 second point x @param y2 second point y @return new element
[ "Create", "a", "SVG", "line", "element" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L279-L281
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.elementCoordinatesFromEvent
public SVGPoint elementCoordinatesFromEvent(Element tag, Event evt) { return SVGUtil.elementCoordinatesFromEvent(document, tag, evt); }
java
public SVGPoint elementCoordinatesFromEvent(Element tag, Event evt) { return SVGUtil.elementCoordinatesFromEvent(document, tag, evt); }
[ "public", "SVGPoint", "elementCoordinatesFromEvent", "(", "Element", "tag", ",", "Event", "evt", ")", "{", "return", "SVGUtil", ".", "elementCoordinatesFromEvent", "(", "document", ",", "tag", ",", "evt", ")", ";", "}" ]
Convert screen coordinates to element coordinates. @param tag Element to convert the coordinates for @param evt Event object @return Coordinates
[ "Convert", "screen", "coordinates", "to", "element", "coordinates", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L302-L304
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.addCSSClassOrLogError
public void addCSSClassOrLogError(CSSClass cls) { try { cssman.addClass(cls); } catch(CSSNamingConflict e) { LoggingUtil.exception(e); } }
java
public void addCSSClassOrLogError(CSSClass cls) { try { cssman.addClass(cls); } catch(CSSNamingConflict e) { LoggingUtil.exception(e); } }
[ "public", "void", "addCSSClassOrLogError", "(", "CSSClass", "cls", ")", "{", "try", "{", "cssman", ".", "addClass", "(", "cls", ")", ";", "}", "catch", "(", "CSSNamingConflict", "e", ")", "{", "LoggingUtil", ".", "exception", "(", "e", ")", ";", "}", "...
Convenience method to add a CSS class or log an error. @param cls CSS class to add.
[ "Convenience", "method", "to", "add", "a", "CSS", "class", "or", "log", "an", "error", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L361-L368
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.updateStyleElement
public void updateStyleElement() { // TODO: this should be sufficient - why does Batik occasionally not pick up // the changes unless we actually replace the style element itself? // cssman.updateStyleElement(document, style); Element newstyle = cssman.makeStyleElement(document); style.getParentNode().replaceChild(newstyle, style); style = newstyle; }
java
public void updateStyleElement() { // TODO: this should be sufficient - why does Batik occasionally not pick up // the changes unless we actually replace the style element itself? // cssman.updateStyleElement(document, style); Element newstyle = cssman.makeStyleElement(document); style.getParentNode().replaceChild(newstyle, style); style = newstyle; }
[ "public", "void", "updateStyleElement", "(", ")", "{", "// TODO: this should be sufficient - why does Batik occasionally not pick up", "// the changes unless we actually replace the style element itself?", "// cssman.updateStyleElement(document, style);", "Element", "newstyle", "=", "cssman"...
Update style element - invoke this appropriately after any change to the CSS styles.
[ "Update", "style", "element", "-", "invoke", "this", "appropriately", "after", "any", "change", "to", "the", "CSS", "styles", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L374-L381
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.saveAsSVG
public void saveAsSVG(File file) throws IOException, TransformerFactoryConfigurationError, TransformerException { OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); // TODO embed linked images. javax.xml.transform.Result result = new StreamResult(out); SVGDocument doc = cloneDocument(); // Use a transformer for pretty printing Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.setOutputProperty(OutputKeys.INDENT, "yes"); xformer.transform(new DOMSource(doc), result); out.flush(); out.close(); }
java
public void saveAsSVG(File file) throws IOException, TransformerFactoryConfigurationError, TransformerException { OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); // TODO embed linked images. javax.xml.transform.Result result = new StreamResult(out); SVGDocument doc = cloneDocument(); // Use a transformer for pretty printing Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.setOutputProperty(OutputKeys.INDENT, "yes"); xformer.transform(new DOMSource(doc), result); out.flush(); out.close(); }
[ "public", "void", "saveAsSVG", "(", "File", "file", ")", "throws", "IOException", ",", "TransformerFactoryConfigurationError", ",", "TransformerException", "{", "OutputStream", "out", "=", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "file", ")"...
Save document into a SVG file. References PNG images from the temporary files will be inlined automatically. @param file Output filename @throws IOException On write errors @throws TransformerFactoryConfigurationError Transformation error @throws TransformerException Transformation error
[ "Save", "document", "into", "a", "SVG", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L394-L405
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.transcode
protected void transcode(File file, Transcoder transcoder) throws IOException, TranscoderException { // Disable validation, performance is more important here (thumbnails!) transcoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE); SVGDocument doc = cloneDocument(); TranscoderInput input = new TranscoderInput(doc); OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); TranscoderOutput output = new TranscoderOutput(out); transcoder.transcode(input, output); out.flush(); out.close(); }
java
protected void transcode(File file, Transcoder transcoder) throws IOException, TranscoderException { // Disable validation, performance is more important here (thumbnails!) transcoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE); SVGDocument doc = cloneDocument(); TranscoderInput input = new TranscoderInput(doc); OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); TranscoderOutput output = new TranscoderOutput(out); transcoder.transcode(input, output); out.flush(); out.close(); }
[ "protected", "void", "transcode", "(", "File", "file", ",", "Transcoder", "transcoder", ")", "throws", "IOException", ",", "TranscoderException", "{", "// Disable validation, performance is more important here (thumbnails!)", "transcoder", ".", "addTranscodingHint", "(", "XML...
Transcode a document into a file using the given transcoder. @param file Output file @param transcoder Transcoder to use @throws IOException On write errors @throws TranscoderException On input/parsing errors
[ "Transcode", "a", "document", "into", "a", "file", "using", "the", "given", "transcoder", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L415-L425
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.cloneDocument
protected SVGDocument cloneDocument() { return (SVGDocument) new CloneInlineImages() { @Override public Node cloneNode(Document doc, Node eold) { // Skip elements with noexport attribute set if(eold instanceof Element) { Element eeold = (Element) eold; String vis = eeold.getAttribute(NO_EXPORT_ATTRIBUTE); if(vis != null && vis.length() > 0) { return null; } } return super.cloneNode(doc, eold); } }.cloneDocument(getDomImpl(), document); }
java
protected SVGDocument cloneDocument() { return (SVGDocument) new CloneInlineImages() { @Override public Node cloneNode(Document doc, Node eold) { // Skip elements with noexport attribute set if(eold instanceof Element) { Element eeold = (Element) eold; String vis = eeold.getAttribute(NO_EXPORT_ATTRIBUTE); if(vis != null && vis.length() > 0) { return null; } } return super.cloneNode(doc, eold); } }.cloneDocument(getDomImpl(), document); }
[ "protected", "SVGDocument", "cloneDocument", "(", ")", "{", "return", "(", "SVGDocument", ")", "new", "CloneInlineImages", "(", ")", "{", "@", "Override", "public", "Node", "cloneNode", "(", "Document", "doc", ",", "Node", "eold", ")", "{", "// Skip elements w...
Clone the SVGPlot document for transcoding. This will usually be necessary for exporting the SVG document if it is currently being displayed: otherwise, we break the Batik rendering trees. (Discovered by Simon). @return cloned document
[ "Clone", "the", "SVGPlot", "document", "for", "transcoding", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L436-L451
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.saveAsPDF
public void saveAsPDF(File file) throws IOException, TranscoderException, ClassNotFoundException { try { Object t = Class.forName("org.apache.fop.svg.PDFTranscoder").newInstance(); transcode(file, (Transcoder) t); } catch(InstantiationException | IllegalAccessException e) { throw new ClassNotFoundException("Could not instantiate PDF transcoder - is Apache FOP installed?", e); } }
java
public void saveAsPDF(File file) throws IOException, TranscoderException, ClassNotFoundException { try { Object t = Class.forName("org.apache.fop.svg.PDFTranscoder").newInstance(); transcode(file, (Transcoder) t); } catch(InstantiationException | IllegalAccessException e) { throw new ClassNotFoundException("Could not instantiate PDF transcoder - is Apache FOP installed?", e); } }
[ "public", "void", "saveAsPDF", "(", "File", "file", ")", "throws", "IOException", ",", "TranscoderException", ",", "ClassNotFoundException", "{", "try", "{", "Object", "t", "=", "Class", ".", "forName", "(", "\"org.apache.fop.svg.PDFTranscoder\"", ")", ".", "newIn...
Transcode file to PDF. @param file Output filename @throws IOException On write errors @throws TranscoderException On input/parsing errors. @throws ClassNotFoundException PDF transcoder not installed
[ "Transcode", "file", "to", "PDF", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L461-L469
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.saveAsPNG
public void saveAsPNG(File file, int width, int height) throws IOException, TranscoderException { PNGTranscoder t = new PNGTranscoder(); t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width)); t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height)); transcode(file, t); }
java
public void saveAsPNG(File file, int width, int height) throws IOException, TranscoderException { PNGTranscoder t = new PNGTranscoder(); t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width)); t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height)); transcode(file, t); }
[ "public", "void", "saveAsPNG", "(", "File", "file", ",", "int", "width", ",", "int", "height", ")", "throws", "IOException", ",", "TranscoderException", "{", "PNGTranscoder", "t", "=", "new", "PNGTranscoder", "(", ")", ";", "t", ".", "addTranscodingHint", "(...
Transcode file to PNG. @param file Output filename @param width Width @param height Height @throws IOException On write errors @throws TranscoderException On input/parsing errors.
[ "Transcode", "file", "to", "PNG", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L516-L521
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.saveAsANY
public void saveAsANY(File file, int width, int height, float quality) throws IOException, TranscoderException, TransformerFactoryConfigurationError, TransformerException, ClassNotFoundException { String extension = FileUtil.getFilenameExtension(file); if("svg".equals(extension)) { saveAsSVG(file); } else if("pdf".equals(extension)) { saveAsPDF(file); } else if("ps".equals(extension)) { saveAsPS(file); } else if("eps".equals(extension)) { saveAsEPS(file); } else if("png".equals(extension)) { saveAsPNG(file, width, height); } else if("jpg".equals(extension) || "jpeg".equals(extension)) { saveAsJPEG(file, width, height, quality); } else { throw new IOException("Unknown file extension: " + extension); } }
java
public void saveAsANY(File file, int width, int height, float quality) throws IOException, TranscoderException, TransformerFactoryConfigurationError, TransformerException, ClassNotFoundException { String extension = FileUtil.getFilenameExtension(file); if("svg".equals(extension)) { saveAsSVG(file); } else if("pdf".equals(extension)) { saveAsPDF(file); } else if("ps".equals(extension)) { saveAsPS(file); } else if("eps".equals(extension)) { saveAsEPS(file); } else if("png".equals(extension)) { saveAsPNG(file, width, height); } else if("jpg".equals(extension) || "jpeg".equals(extension)) { saveAsJPEG(file, width, height, quality); } else { throw new IOException("Unknown file extension: " + extension); } }
[ "public", "void", "saveAsANY", "(", "File", "file", ",", "int", "width", ",", "int", "height", ",", "float", "quality", ")", "throws", "IOException", ",", "TranscoderException", ",", "TransformerFactoryConfigurationError", ",", "TransformerException", ",", "ClassNot...
Save a file trying to auto-guess the file type. @param file File name @param width Width (for pixel formats) @param height Height (for pixel formats) @param quality Quality (for lossy compression) @throws IOException on file write errors or unrecognized file extensions @throws TranscoderException on transcoding errors @throws TransformerFactoryConfigurationError on transcoding errors @throws TransformerException on transcoding errors @throws ClassNotFoundException when the transcoder was not installed
[ "Save", "a", "file", "trying", "to", "auto", "-", "guess", "the", "file", "type", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L567-L590
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.makeAWTImage
public BufferedImage makeAWTImage(int width, int height) throws TranscoderException { ThumbnailTranscoder t = new ThumbnailTranscoder(); t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width)); t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height)); // Don't clone. Assume this is used safely. TranscoderInput input = new TranscoderInput(document); t.transcode(input, null); return t.getLastImage(); }
java
public BufferedImage makeAWTImage(int width, int height) throws TranscoderException { ThumbnailTranscoder t = new ThumbnailTranscoder(); t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width)); t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height)); // Don't clone. Assume this is used safely. TranscoderInput input = new TranscoderInput(document); t.transcode(input, null); return t.getLastImage(); }
[ "public", "BufferedImage", "makeAWTImage", "(", "int", "width", ",", "int", "height", ")", "throws", "TranscoderException", "{", "ThumbnailTranscoder", "t", "=", "new", "ThumbnailTranscoder", "(", ")", ";", "t", ".", "addTranscodingHint", "(", "PNGTranscoder", "."...
Convert the SVG to a thumbnail image. @param width Width of thumbnail @param height Height of thumbnail @return Buffered image
[ "Convert", "the", "SVG", "to", "a", "thumbnail", "image", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L599-L607
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.dumpDebugFile
public void dumpDebugFile() { try { File f = File.createTempFile("elki-debug", ".svg"); f.deleteOnExit(); this.saveAsSVG(f); LoggingUtil.warning("Saved debug file to: " + f.getAbsolutePath()); } catch(Throwable err) { // Ignore. } }
java
public void dumpDebugFile() { try { File f = File.createTempFile("elki-debug", ".svg"); f.deleteOnExit(); this.saveAsSVG(f); LoggingUtil.warning("Saved debug file to: " + f.getAbsolutePath()); } catch(Throwable err) { // Ignore. } }
[ "public", "void", "dumpDebugFile", "(", ")", "{", "try", "{", "File", "f", "=", "File", ".", "createTempFile", "(", "\"elki-debug\"", ",", "\".svg\"", ")", ";", "f", ".", "deleteOnExit", "(", ")", ";", "this", ".", "saveAsSVG", "(", "f", ")", ";", "L...
Dump the SVG plot to a debug file.
[ "Dump", "the", "SVG", "plot", "to", "a", "debug", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L612-L622
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.putIdElement
public void putIdElement(String id, Element obj) { objWithId.put(id, new WeakReference<>(obj)); }
java
public void putIdElement(String id, Element obj) { objWithId.put(id, new WeakReference<>(obj)); }
[ "public", "void", "putIdElement", "(", "String", "id", ",", "Element", "obj", ")", "{", "objWithId", ".", "put", "(", "id", ",", "new", "WeakReference", "<>", "(", "obj", ")", ")", ";", "}" ]
Add an object id. @param id ID @param obj Element
[ "Add", "an", "object", "id", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L630-L632
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
SVGPlot.getIdElement
public Element getIdElement(String id) { WeakReference<Element> ref = objWithId.get(id); return (ref != null) ? ref.get() : null; }
java
public Element getIdElement(String id) { WeakReference<Element> ref = objWithId.get(id); return (ref != null) ? ref.get() : null; }
[ "public", "Element", "getIdElement", "(", "String", "id", ")", "{", "WeakReference", "<", "Element", ">", "ref", "=", "objWithId", ".", "get", "(", "id", ")", ";", "return", "(", "ref", "!=", "null", ")", "?", "ref", ".", "get", "(", ")", ":", "nul...
Get an element by its id. @param id ID @return Element
[ "Get", "an", "element", "by", "its", "id", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L640-L643
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/evaluation/outlier/JudgeOutlierScores.java
JudgeOutlierScores.computeScore
protected ScoreResult computeScore(DBIDs ids, DBIDs outlierIds, OutlierResult or) throws IllegalStateException { if(scaling instanceof OutlierScaling) { OutlierScaling oscaling = (OutlierScaling) scaling; oscaling.prepare(or); } final ScalingFunction innerScaling; // If we have useful (finite) min/max, use these for binning. double min = scaling.getMin(); double max = scaling.getMax(); if(Double.isInfinite(min) || Double.isNaN(min) || Double.isInfinite(max) || Double.isNaN(max)) { innerScaling = new IdentityScaling(); // TODO: does the outlier score give us this guarantee? LOG.warning("JudgeOutlierScores expects values between 0.0 and 1.0, but we don't have such a guarantee by the scaling function: min:" + min + " max:" + max); } else { if(min == 0.0 && max == 1.0) { innerScaling = new IdentityScaling(); } else { innerScaling = new LinearScaling(1.0 / (max - min), -min); } } double posscore = 0.0; double negscore = 0.0; // fill histogram with values of each object for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double result = or.getScores().doubleValue(iter); result = innerScaling.getScaled(scaling.getScaled(result)); posscore += (1.0 - result); } for(DBIDIter iter = outlierIds.iter(); iter.valid(); iter.advance()) { double result = or.getScores().doubleValue(iter); result = innerScaling.getScaled(scaling.getScaled(result)); negscore += result; } posscore /= ids.size(); negscore /= outlierIds.size(); LOG.verbose("Scores: " + posscore + " " + negscore); ArrayList<double[]> s = new ArrayList<>(1); s.add(new double[] { (posscore + negscore) * .5, posscore, negscore }); return new ScoreResult(s); }
java
protected ScoreResult computeScore(DBIDs ids, DBIDs outlierIds, OutlierResult or) throws IllegalStateException { if(scaling instanceof OutlierScaling) { OutlierScaling oscaling = (OutlierScaling) scaling; oscaling.prepare(or); } final ScalingFunction innerScaling; // If we have useful (finite) min/max, use these for binning. double min = scaling.getMin(); double max = scaling.getMax(); if(Double.isInfinite(min) || Double.isNaN(min) || Double.isInfinite(max) || Double.isNaN(max)) { innerScaling = new IdentityScaling(); // TODO: does the outlier score give us this guarantee? LOG.warning("JudgeOutlierScores expects values between 0.0 and 1.0, but we don't have such a guarantee by the scaling function: min:" + min + " max:" + max); } else { if(min == 0.0 && max == 1.0) { innerScaling = new IdentityScaling(); } else { innerScaling = new LinearScaling(1.0 / (max - min), -min); } } double posscore = 0.0; double negscore = 0.0; // fill histogram with values of each object for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double result = or.getScores().doubleValue(iter); result = innerScaling.getScaled(scaling.getScaled(result)); posscore += (1.0 - result); } for(DBIDIter iter = outlierIds.iter(); iter.valid(); iter.advance()) { double result = or.getScores().doubleValue(iter); result = innerScaling.getScaled(scaling.getScaled(result)); negscore += result; } posscore /= ids.size(); negscore /= outlierIds.size(); LOG.verbose("Scores: " + posscore + " " + negscore); ArrayList<double[]> s = new ArrayList<>(1); s.add(new double[] { (posscore + negscore) * .5, posscore, negscore }); return new ScoreResult(s); }
[ "protected", "ScoreResult", "computeScore", "(", "DBIDs", "ids", ",", "DBIDs", "outlierIds", ",", "OutlierResult", "or", ")", "throws", "IllegalStateException", "{", "if", "(", "scaling", "instanceof", "OutlierScaling", ")", "{", "OutlierScaling", "oscaling", "=", ...
Evaluate a single outlier score result. @param ids Inlier IDs @param outlierIds Outlier IDs @param or Outlier Result to evaluate @return Outlier score result @throws IllegalStateException
[ "Evaluate", "a", "single", "outlier", "score", "result", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/evaluation/outlier/JudgeOutlierScores.java#L100-L145
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/FastDOC.java
FastDOC.runDOC
@Override protected Cluster<SubspaceModel> runDOC(Database database, Relation<V> relation, ArrayModifiableDBIDs S, int d, int n, int m, int r, int minClusterSize) { // Relevant attributes of highest cardinality. long[] D = null; // The seed point for the best dimensions. DBIDVar dV = DBIDUtil.newVar(); // Inform the user about the progress in the current iteration. FiniteProgress iprogress = LOG.isVerbose() ? new FiniteProgress("Iteration progress for current cluster", m * n, LOG) : null; Random random = rnd.getSingleThreadedRandom(); DBIDArrayIter iter = S.iter(); outer: for(int i = 0; i < n; ++i) { // Pick a random seed point. iter.seek(random.nextInt(S.size())); for(int j = 0; j < m; ++j) { // Choose a set of random points. DBIDs randomSet = DBIDUtil.randomSample(S, r, random); // Initialize cluster info. long[] nD = BitsUtil.zero(d); // Test each dimension. for(int k = 0; k < d; ++k) { if(dimensionIsRelevant(k, relation, randomSet)) { BitsUtil.setI(nD, k); } } if(D == null || BitsUtil.cardinality(nD) > BitsUtil.cardinality(D)) { D = nD; dV.set(iter); if(BitsUtil.cardinality(D) >= d_zero) { if(iprogress != null) { iprogress.setProcessed(iprogress.getTotal(), LOG); } break outer; } } LOG.incrementProcessed(iprogress); } } LOG.ensureCompleted(iprogress); // If no relevant dimensions were found, skip it. if(D == null || BitsUtil.cardinality(D) == 0) { return null; } // Get all points in the box. DBIDs C = findNeighbors(dV, D, S, relation); // If we have a non-empty cluster, return it. return (C.size() >= minClusterSize) ? makeCluster(relation, C, D) : null; }
java
@Override protected Cluster<SubspaceModel> runDOC(Database database, Relation<V> relation, ArrayModifiableDBIDs S, int d, int n, int m, int r, int minClusterSize) { // Relevant attributes of highest cardinality. long[] D = null; // The seed point for the best dimensions. DBIDVar dV = DBIDUtil.newVar(); // Inform the user about the progress in the current iteration. FiniteProgress iprogress = LOG.isVerbose() ? new FiniteProgress("Iteration progress for current cluster", m * n, LOG) : null; Random random = rnd.getSingleThreadedRandom(); DBIDArrayIter iter = S.iter(); outer: for(int i = 0; i < n; ++i) { // Pick a random seed point. iter.seek(random.nextInt(S.size())); for(int j = 0; j < m; ++j) { // Choose a set of random points. DBIDs randomSet = DBIDUtil.randomSample(S, r, random); // Initialize cluster info. long[] nD = BitsUtil.zero(d); // Test each dimension. for(int k = 0; k < d; ++k) { if(dimensionIsRelevant(k, relation, randomSet)) { BitsUtil.setI(nD, k); } } if(D == null || BitsUtil.cardinality(nD) > BitsUtil.cardinality(D)) { D = nD; dV.set(iter); if(BitsUtil.cardinality(D) >= d_zero) { if(iprogress != null) { iprogress.setProcessed(iprogress.getTotal(), LOG); } break outer; } } LOG.incrementProcessed(iprogress); } } LOG.ensureCompleted(iprogress); // If no relevant dimensions were found, skip it. if(D == null || BitsUtil.cardinality(D) == 0) { return null; } // Get all points in the box. DBIDs C = findNeighbors(dV, D, S, relation); // If we have a non-empty cluster, return it. return (C.size() >= minClusterSize) ? makeCluster(relation, C, D) : null; }
[ "@", "Override", "protected", "Cluster", "<", "SubspaceModel", ">", "runDOC", "(", "Database", "database", ",", "Relation", "<", "V", ">", "relation", ",", "ArrayModifiableDBIDs", "S", ",", "int", "d", ",", "int", "n", ",", "int", "m", ",", "int", "r", ...
Performs a single run of FastDOC, finding a single cluster. @param database Database context @param relation used to get actual values for DBIDs. @param S The set of points we're working on. @param d Dimensionality of the data set we're currently working on. @param r Size of random samples. @param m Number of inner iterations (per seed point). @param n Number of outer iterations (seed points). @param minClusterSize Minimum size a cluster must have to be accepted. @return a cluster, if one is found, else <code>null</code>.
[ "Performs", "a", "single", "run", "of", "FastDOC", "finding", "a", "single", "cluster", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/FastDOC.java#L101-L158
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/VoronoiDraw.java
VoronoiDraw.drawDelaunay
public static SVGPath drawDelaunay(Projection2D proj, List<SweepHullDelaunay2D.Triangle> delaunay, List<double[]> means) { final SVGPath path = new SVGPath(); for(SweepHullDelaunay2D.Triangle del : delaunay) { path.moveTo(proj.fastProjectDataToRenderSpace(means.get(del.a))); path.drawTo(proj.fastProjectDataToRenderSpace(means.get(del.b))); path.drawTo(proj.fastProjectDataToRenderSpace(means.get(del.c))); path.close(); } return path; }
java
public static SVGPath drawDelaunay(Projection2D proj, List<SweepHullDelaunay2D.Triangle> delaunay, List<double[]> means) { final SVGPath path = new SVGPath(); for(SweepHullDelaunay2D.Triangle del : delaunay) { path.moveTo(proj.fastProjectDataToRenderSpace(means.get(del.a))); path.drawTo(proj.fastProjectDataToRenderSpace(means.get(del.b))); path.drawTo(proj.fastProjectDataToRenderSpace(means.get(del.c))); path.close(); } return path; }
[ "public", "static", "SVGPath", "drawDelaunay", "(", "Projection2D", "proj", ",", "List", "<", "SweepHullDelaunay2D", ".", "Triangle", ">", "delaunay", ",", "List", "<", "double", "[", "]", ">", "means", ")", "{", "final", "SVGPath", "path", "=", "new", "SV...
Draw the Delaunay triangulation. @param proj Projection @param delaunay Triangulation @param means Means @return Path
[ "Draw", "the", "Delaunay", "triangulation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/VoronoiDraw.java#L57-L66
train