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-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/KappaDistribution.java
KappaDistribution.logcdf
public static double logcdf(double val, double shape1, double shape2) { if(val == Double.NEGATIVE_INFINITY) { return Double.NEGATIVE_INFINITY; } if(val == Double.POSITIVE_INFINITY) { return 0.; } if(val != val) { return Double.NaN; } if(shape1 == 0.) { val = FastMath.exp(-val); } else { double tmp = shape1 * val; if(tmp == Double.NEGATIVE_INFINITY) { return shape2 == 0 ? 0. : Double.NEGATIVE_INFINITY; } if(tmp >= 1.) { return shape2 == 0 ? Double.NEGATIVE_INFINITY : 0.; } val = FastMath.exp(FastMath.log1p(-tmp) / shape1); } if(shape2 == 0.) { return -val; } final double tmp = shape2 * val; return tmp < 1. ? FastMath.log1p(-tmp) / shape2 : Double.NEGATIVE_INFINITY; }
java
public static double logcdf(double val, double shape1, double shape2) { if(val == Double.NEGATIVE_INFINITY) { return Double.NEGATIVE_INFINITY; } if(val == Double.POSITIVE_INFINITY) { return 0.; } if(val != val) { return Double.NaN; } if(shape1 == 0.) { val = FastMath.exp(-val); } else { double tmp = shape1 * val; if(tmp == Double.NEGATIVE_INFINITY) { return shape2 == 0 ? 0. : Double.NEGATIVE_INFINITY; } if(tmp >= 1.) { return shape2 == 0 ? Double.NEGATIVE_INFINITY : 0.; } val = FastMath.exp(FastMath.log1p(-tmp) / shape1); } if(shape2 == 0.) { return -val; } final double tmp = shape2 * val; return tmp < 1. ? FastMath.log1p(-tmp) / shape2 : Double.NEGATIVE_INFINITY; }
[ "public", "static", "double", "logcdf", "(", "double", "val", ",", "double", "shape1", ",", "double", "shape2", ")", "{", "if", "(", "val", "==", "Double", ".", "NEGATIVE_INFINITY", ")", "{", "return", "Double", ".", "NEGATIVE_INFINITY", ";", "}", "if", ...
Cumulative density function, for location = 0, scale = 1 @param val Value @param shape1 Shape parameter @param shape2 Shape parameter @return CDF
[ "Cumulative", "density", "function", "for", "location", "=", "0", "scale", "=", "1" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/KappaDistribution.java#L246-L274
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java
InMemoryInvertedIndex.naiveQuerySparse
private double naiveQuerySparse(SparseNumberVector obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) { double len = 0.; // Length of query object, for final normalization for(int iter = obj.iter(); obj.iterValid(iter); iter = obj.iterAdvance(iter)) { final int dim = obj.iterDim(iter); final double val = obj.iterDoubleValue(iter); if(val == 0. || val != val) { continue; } len += val * val; // No matching documents in index: if(dim >= index.size()) { continue; } ModifiableDoubleDBIDList column = index.get(dim); for(DoubleDBIDListIter n = column.iter(); n.valid(); n.advance()) { scores.increment(n, n.doubleValue() * val); cands.add(n); } } return FastMath.sqrt(len); }
java
private double naiveQuerySparse(SparseNumberVector obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) { double len = 0.; // Length of query object, for final normalization for(int iter = obj.iter(); obj.iterValid(iter); iter = obj.iterAdvance(iter)) { final int dim = obj.iterDim(iter); final double val = obj.iterDoubleValue(iter); if(val == 0. || val != val) { continue; } len += val * val; // No matching documents in index: if(dim >= index.size()) { continue; } ModifiableDoubleDBIDList column = index.get(dim); for(DoubleDBIDListIter n = column.iter(); n.valid(); n.advance()) { scores.increment(n, n.doubleValue() * val); cands.add(n); } } return FastMath.sqrt(len); }
[ "private", "double", "naiveQuerySparse", "(", "SparseNumberVector", "obj", ",", "WritableDoubleDataStore", "scores", ",", "HashSetModifiableDBIDs", "cands", ")", "{", "double", "len", "=", "0.", ";", "// Length of query object, for final normalization", "for", "(", "int",...
Query the most similar objects, sparse version. @param obj Query object @param scores Score storage @param cands Non-zero objects set @return Result
[ "Query", "the", "most", "similar", "objects", "sparse", "version", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java#L180-L200
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java
InMemoryInvertedIndex.naiveQueryDense
private double naiveQueryDense(NumberVector obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) { double len = 0.; // Length of query object, for final normalization for(int dim = 0, max = obj.getDimensionality(); dim < max; dim++) { final double val = obj.doubleValue(dim); if(val == 0. || val != val) { continue; } len += val * val; // No matching documents in index: if(dim >= index.size()) { continue; } ModifiableDoubleDBIDList column = index.get(dim); for(DoubleDBIDListIter n = column.iter(); n.valid(); n.advance()) { scores.increment(n, n.doubleValue() * val); cands.add(n); } } return FastMath.sqrt(len); }
java
private double naiveQueryDense(NumberVector obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) { double len = 0.; // Length of query object, for final normalization for(int dim = 0, max = obj.getDimensionality(); dim < max; dim++) { final double val = obj.doubleValue(dim); if(val == 0. || val != val) { continue; } len += val * val; // No matching documents in index: if(dim >= index.size()) { continue; } ModifiableDoubleDBIDList column = index.get(dim); for(DoubleDBIDListIter n = column.iter(); n.valid(); n.advance()) { scores.increment(n, n.doubleValue() * val); cands.add(n); } } return FastMath.sqrt(len); }
[ "private", "double", "naiveQueryDense", "(", "NumberVector", "obj", ",", "WritableDoubleDataStore", "scores", ",", "HashSetModifiableDBIDs", "cands", ")", "{", "double", "len", "=", "0.", ";", "// Length of query object, for final normalization", "for", "(", "int", "dim...
Query the most similar objects, dense version. @param obj Query object @param scores Score storage @param cands Non-zero objects set @return Result
[ "Query", "the", "most", "similar", "objects", "dense", "version", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java#L210-L229
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java
InMemoryInvertedIndex.naiveQuery
private double naiveQuery(V obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) { if(obj instanceof SparseNumberVector) { return naiveQuerySparse((SparseNumberVector) obj, scores, cands); } else { return naiveQueryDense(obj, scores, cands); } }
java
private double naiveQuery(V obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) { if(obj instanceof SparseNumberVector) { return naiveQuerySparse((SparseNumberVector) obj, scores, cands); } else { return naiveQueryDense(obj, scores, cands); } }
[ "private", "double", "naiveQuery", "(", "V", "obj", ",", "WritableDoubleDataStore", "scores", ",", "HashSetModifiableDBIDs", "cands", ")", "{", "if", "(", "obj", "instanceof", "SparseNumberVector", ")", "{", "return", "naiveQuerySparse", "(", "(", "SparseNumberVecto...
Query the most similar objects, abstract version. @param obj Query object @param scores Score storage (must be initialized with zeros!) @param cands Non-zero objects set (must be empty) @return Result
[ "Query", "the", "most", "similar", "objects", "abstract", "version", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java#L239-L246
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/AbstractDatabaseConnection.java
AbstractDatabaseConnection.invokeStreamFilters
protected BundleStreamSource invokeStreamFilters(BundleStreamSource stream) { assert (stream != null); if(filters == null) { return stream; } // We dynamically switch between streaming and bundle operations. MultipleObjectsBundle bundle = null; for(ObjectFilter filter : filters) { if(filter instanceof StreamFilter) { stream = ((StreamFilter) filter).init(bundle != null ? bundle.asStream() : stream); bundle = null; } else { bundle = filter.filter(stream != null ? stream.asMultipleObjectsBundle() : bundle); stream = null; } } return stream != null ? stream : bundle.asStream(); }
java
protected BundleStreamSource invokeStreamFilters(BundleStreamSource stream) { assert (stream != null); if(filters == null) { return stream; } // We dynamically switch between streaming and bundle operations. MultipleObjectsBundle bundle = null; for(ObjectFilter filter : filters) { if(filter instanceof StreamFilter) { stream = ((StreamFilter) filter).init(bundle != null ? bundle.asStream() : stream); bundle = null; } else { bundle = filter.filter(stream != null ? stream.asMultipleObjectsBundle() : bundle); stream = null; } } return stream != null ? stream : bundle.asStream(); }
[ "protected", "BundleStreamSource", "invokeStreamFilters", "(", "BundleStreamSource", "stream", ")", "{", "assert", "(", "stream", "!=", "null", ")", ";", "if", "(", "filters", "==", "null", ")", "{", "return", "stream", ";", "}", "// We dynamically switch between ...
Transforms the specified list of objects and their labels into a list of objects and their associations. @param stream the objects to process @return processed objects
[ "Transforms", "the", "specified", "list", "of", "objects", "and", "their", "labels", "into", "a", "list", "of", "objects", "and", "their", "associations", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/AbstractDatabaseConnection.java#L100-L118
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/ELKILogRecord.java
ELKILogRecord.inferCallerELKI
private void inferCallerELKI() { needToInferCaller = false; StackTraceElement[] stack = (new Throwable()).getStackTrace(); int ix = 0; // skip back to the logger. while(ix < stack.length) { StackTraceElement frame = stack[ix]; final String cls = frame.getClassName(); if(cls.equals(START_TRACE_AT)) { break; } ix++; } // skip further back through helper functions while(ix < stack.length) { StackTraceElement frame = stack[ix]; final String cls = frame.getClassName(); boolean ignore = false; for(int i = 0; i < IGNORE_CLASSES.length; i++) { if(cls.equals(IGNORE_CLASSES[i])) { ignore = true; break; } } if(!ignore) { super.setSourceClassName(frame.getClassName()); super.setSourceMethodName(frame.getMethodName()); break; } ix++; } }
java
private void inferCallerELKI() { needToInferCaller = false; StackTraceElement[] stack = (new Throwable()).getStackTrace(); int ix = 0; // skip back to the logger. while(ix < stack.length) { StackTraceElement frame = stack[ix]; final String cls = frame.getClassName(); if(cls.equals(START_TRACE_AT)) { break; } ix++; } // skip further back through helper functions while(ix < stack.length) { StackTraceElement frame = stack[ix]; final String cls = frame.getClassName(); boolean ignore = false; for(int i = 0; i < IGNORE_CLASSES.length; i++) { if(cls.equals(IGNORE_CLASSES[i])) { ignore = true; break; } } if(!ignore) { super.setSourceClassName(frame.getClassName()); super.setSourceMethodName(frame.getMethodName()); break; } ix++; } }
[ "private", "void", "inferCallerELKI", "(", ")", "{", "needToInferCaller", "=", "false", ";", "StackTraceElement", "[", "]", "stack", "=", "(", "new", "Throwable", "(", ")", ")", ".", "getStackTrace", "(", ")", ";", "int", "ix", "=", "0", ";", "// skip ba...
Infer a caller, ignoring logging-related classes.
[ "Infer", "a", "caller", "ignoring", "logging", "-", "related", "classes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/ELKILogRecord.java#L119-L151
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/result/SamplingResult.java
SamplingResult.getSamplingResult
public static SamplingResult getSamplingResult(final Relation<?> rel) { Collection<SamplingResult> selections = ResultUtil.filterResults(rel.getHierarchy(), rel, SamplingResult.class); if(selections.isEmpty()) { final SamplingResult newsam = new SamplingResult(rel); ResultUtil.addChildResult(rel, newsam); return newsam; } return selections.iterator().next(); }
java
public static SamplingResult getSamplingResult(final Relation<?> rel) { Collection<SamplingResult> selections = ResultUtil.filterResults(rel.getHierarchy(), rel, SamplingResult.class); if(selections.isEmpty()) { final SamplingResult newsam = new SamplingResult(rel); ResultUtil.addChildResult(rel, newsam); return newsam; } return selections.iterator().next(); }
[ "public", "static", "SamplingResult", "getSamplingResult", "(", "final", "Relation", "<", "?", ">", "rel", ")", "{", "Collection", "<", "SamplingResult", ">", "selections", "=", "ResultUtil", ".", "filterResults", "(", "rel", ".", "getHierarchy", "(", ")", ","...
Get the sampling result attached to a relation @param rel Relation @return Sampling result.
[ "Get", "the", "sampling", "result", "attached", "to", "a", "relation" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/result/SamplingResult.java#L83-L91
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGButton.java
SVGButton.render
public Element render(SVGPlot svgp) { Element tag = svgp.svgElement(SVGConstants.SVG_G_TAG); Element button = svgp.svgRect(x, y, w, h); if(!Double.isNaN(r)) { SVGUtil.setAtt(button, SVGConstants.SVG_RX_ATTRIBUTE, r); SVGUtil.setAtt(button, SVGConstants.SVG_RY_ATTRIBUTE, r); } SVGUtil.setAtt(button, SVGConstants.SVG_STYLE_ATTRIBUTE, butcss.inlineCSS()); tag.appendChild(button); // Add light effect: if (svgp.getIdElement(SVGEffects.LIGHT_GRADIENT_ID) != null) { Element light = svgp.svgRect(x, y, w, h); if(!Double.isNaN(r)) { SVGUtil.setAtt(light, SVGConstants.SVG_RX_ATTRIBUTE, r); SVGUtil.setAtt(light, SVGConstants.SVG_RY_ATTRIBUTE, r); } SVGUtil.setAtt(light, SVGConstants.SVG_STYLE_ATTRIBUTE, "fill:url(#"+SVGEffects.LIGHT_GRADIENT_ID+");fill-opacity:.5"); tag.appendChild(light); } // Add shadow effect: if(svgp.getIdElement(SVGEffects.SHADOW_ID) != null) { //Element shadow = svgp.svgRect(x + (w * .05), y + (h * .05), w, h); //SVGUtil.setAtt(button, SVGConstants.SVG_STYLE_ATTRIBUTE, SVGConstants.CSS_FILL_PROPERTY + ":" + SVGConstants.CSS_BLACK_VALUE); button.setAttribute(SVGConstants.SVG_FILTER_ATTRIBUTE, "url(#" + SVGEffects.SHADOW_ID + ")"); //tag.appendChild(shadow); } if(title != null) { Element label = svgp.svgText(x + w * .5, y + h * .7, title); label.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, titlecss.inlineCSS()); tag.appendChild(label); } return tag; }
java
public Element render(SVGPlot svgp) { Element tag = svgp.svgElement(SVGConstants.SVG_G_TAG); Element button = svgp.svgRect(x, y, w, h); if(!Double.isNaN(r)) { SVGUtil.setAtt(button, SVGConstants.SVG_RX_ATTRIBUTE, r); SVGUtil.setAtt(button, SVGConstants.SVG_RY_ATTRIBUTE, r); } SVGUtil.setAtt(button, SVGConstants.SVG_STYLE_ATTRIBUTE, butcss.inlineCSS()); tag.appendChild(button); // Add light effect: if (svgp.getIdElement(SVGEffects.LIGHT_GRADIENT_ID) != null) { Element light = svgp.svgRect(x, y, w, h); if(!Double.isNaN(r)) { SVGUtil.setAtt(light, SVGConstants.SVG_RX_ATTRIBUTE, r); SVGUtil.setAtt(light, SVGConstants.SVG_RY_ATTRIBUTE, r); } SVGUtil.setAtt(light, SVGConstants.SVG_STYLE_ATTRIBUTE, "fill:url(#"+SVGEffects.LIGHT_GRADIENT_ID+");fill-opacity:.5"); tag.appendChild(light); } // Add shadow effect: if(svgp.getIdElement(SVGEffects.SHADOW_ID) != null) { //Element shadow = svgp.svgRect(x + (w * .05), y + (h * .05), w, h); //SVGUtil.setAtt(button, SVGConstants.SVG_STYLE_ATTRIBUTE, SVGConstants.CSS_FILL_PROPERTY + ":" + SVGConstants.CSS_BLACK_VALUE); button.setAttribute(SVGConstants.SVG_FILTER_ATTRIBUTE, "url(#" + SVGEffects.SHADOW_ID + ")"); //tag.appendChild(shadow); } if(title != null) { Element label = svgp.svgText(x + w * .5, y + h * .7, title); label.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, titlecss.inlineCSS()); tag.appendChild(label); } return tag; }
[ "public", "Element", "render", "(", "SVGPlot", "svgp", ")", "{", "Element", "tag", "=", "svgp", ".", "svgElement", "(", "SVGConstants", ".", "SVG_G_TAG", ")", ";", "Element", "button", "=", "svgp", ".", "svgRect", "(", "x", ",", "y", ",", "w", ",", "...
Produce the actual SVG elements for the button. @param svgp Plot to draw to @return Button wrapper element
[ "Produce", "the", "actual", "SVG", "elements", "for", "the", "button", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGButton.java#L113-L147
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGButton.java
SVGButton.setTitle
public void setTitle(String title, String textcolor) { this.title = title; if(titlecss == null) { titlecss = new CSSClass(this, "text"); titlecss.setStatement(SVGConstants.CSS_TEXT_ANCHOR_PROPERTY, SVGConstants.CSS_MIDDLE_VALUE); titlecss.setStatement(SVGConstants.CSS_FILL_PROPERTY, textcolor); titlecss.setStatement(SVGConstants.CSS_FONT_SIZE_PROPERTY, .6 * h); } }
java
public void setTitle(String title, String textcolor) { this.title = title; if(titlecss == null) { titlecss = new CSSClass(this, "text"); titlecss.setStatement(SVGConstants.CSS_TEXT_ANCHOR_PROPERTY, SVGConstants.CSS_MIDDLE_VALUE); titlecss.setStatement(SVGConstants.CSS_FILL_PROPERTY, textcolor); titlecss.setStatement(SVGConstants.CSS_FONT_SIZE_PROPERTY, .6 * h); } }
[ "public", "void", "setTitle", "(", "String", "title", ",", "String", "textcolor", ")", "{", "this", ".", "title", "=", "title", ";", "if", "(", "titlecss", "==", "null", ")", "{", "titlecss", "=", "new", "CSSClass", "(", "this", ",", "\"text\"", ")", ...
Set the button title @param title Button title @param textcolor Color
[ "Set", "the", "button", "title" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGButton.java#L155-L163
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java
LayerMap.key
private Pair<PlotItem, VisualizationTask> key(PlotItem item, VisualizationTask task) { return new Pair<>(item, task); }
java
private Pair<PlotItem, VisualizationTask> key(PlotItem item, VisualizationTask task) { return new Pair<>(item, task); }
[ "private", "Pair", "<", "PlotItem", ",", "VisualizationTask", ">", "key", "(", "PlotItem", "item", ",", "VisualizationTask", "task", ")", "{", "return", "new", "Pair", "<>", "(", "item", ",", "task", ")", ";", "}" ]
Helper function for building a key object @param item Plot item @param task Visualization Task @return Key
[ "Helper", "function", "for", "building", "a", "key", "object" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java#L54-L56
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java
LayerMap.value
private Pair<Element, Visualization> value(Element elem, Visualization vis) { return new Pair<>(elem, vis); }
java
private Pair<Element, Visualization> value(Element elem, Visualization vis) { return new Pair<>(elem, vis); }
[ "private", "Pair", "<", "Element", ",", "Visualization", ">", "value", "(", "Element", "elem", ",", "Visualization", "vis", ")", "{", "return", "new", "Pair", "<>", "(", "elem", ",", "vis", ")", ";", "}" ]
Helper function to build a value pair @param elem Container element @param vis Visualization @return Value object
[ "Helper", "function", "to", "build", "a", "value", "pair" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java#L65-L67
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java
LayerMap.put
public void put(PlotItem it, VisualizationTask task, Element elem, Visualization vis) { map.put(key(it, task), value(elem, vis)); }
java
public void put(PlotItem it, VisualizationTask task, Element elem, Visualization vis) { map.put(key(it, task), value(elem, vis)); }
[ "public", "void", "put", "(", "PlotItem", "it", ",", "VisualizationTask", "task", ",", "Element", "elem", ",", "Visualization", "vis", ")", "{", "map", ".", "put", "(", "key", "(", "it", ",", "task", ")", ",", "value", "(", "elem", ",", "vis", ")", ...
Put a new combination into the map. @param it Plot item @param task Visualization Task @param elem Container element @param vis Visualization
[ "Put", "a", "new", "combination", "into", "the", "map", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java#L117-L119
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java
LayerMap.remove
public Pair<Element, Visualization> remove(PlotItem it, VisualizationTask task) { return map.remove(key(it, task)); }
java
public Pair<Element, Visualization> remove(PlotItem it, VisualizationTask task) { return map.remove(key(it, task)); }
[ "public", "Pair", "<", "Element", ",", "Visualization", ">", "remove", "(", "PlotItem", "it", ",", "VisualizationTask", "task", ")", "{", "return", "map", ".", "remove", "(", "key", "(", "it", ",", "task", ")", ")", ";", "}" ]
Remove a combination. @param it Plot item @param task Visualization task @return Previous value
[ "Remove", "a", "combination", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java#L128-L130
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java
LayerMap.put
public void put(PlotItem it, VisualizationTask task, Pair<Element, Visualization> pair) { map.put(key(it, task), pair); }
java
public void put(PlotItem it, VisualizationTask task, Pair<Element, Visualization> pair) { map.put(key(it, task), pair); }
[ "public", "void", "put", "(", "PlotItem", "it", ",", "VisualizationTask", "task", ",", "Pair", "<", "Element", ",", "Visualization", ">", "pair", ")", "{", "map", ".", "put", "(", "key", "(", "it", ",", "task", ")", ",", "pair", ")", ";", "}" ]
Put a new item into the visualizations @param it Plot item @param task Visualization task @param pair Pair object
[ "Put", "a", "new", "item", "into", "the", "visualizations" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/LayerMap.java#L139-L141
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/AbstractMTreeNode.java
AbstractMTreeNode.coveringRadiusFromEntries
public double coveringRadiusFromEntries(DBID routingObjectID, AbstractMTree<O, N, E, ?> mTree) { double coveringRadius = 0.; for(int i = 0; i < getNumEntries(); i++) { E entry = getEntry(i); final double cover = entry.getParentDistance() + entry.getCoveringRadius(); coveringRadius = coveringRadius < cover ? cover : coveringRadius; } return coveringRadius; }
java
public double coveringRadiusFromEntries(DBID routingObjectID, AbstractMTree<O, N, E, ?> mTree) { double coveringRadius = 0.; for(int i = 0; i < getNumEntries(); i++) { E entry = getEntry(i); final double cover = entry.getParentDistance() + entry.getCoveringRadius(); coveringRadius = coveringRadius < cover ? cover : coveringRadius; } return coveringRadius; }
[ "public", "double", "coveringRadiusFromEntries", "(", "DBID", "routingObjectID", ",", "AbstractMTree", "<", "O", ",", "N", ",", "E", ",", "?", ">", "mTree", ")", "{", "double", "coveringRadius", "=", "0.", ";", "for", "(", "int", "i", "=", "0", ";", "i...
Determines and returns the covering radius of this node. @param routingObjectID the object id of the routing object of this node @param mTree the M-Tree @return the covering radius of this node
[ "Determines", "and", "returns", "the", "covering", "radius", "of", "this", "node", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/AbstractMTreeNode.java#L86-L94
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/SweepHullDelaunay2D.java
SweepHullDelaunay2D.quadraticEuclidean
public static double quadraticEuclidean(double[] v1, double[] v2) { final double d1 = v1[0] - v2[0], d2 = v1[1] - v2[1]; return (d1 * d1) + (d2 * d2); }
java
public static double quadraticEuclidean(double[] v1, double[] v2) { final double d1 = v1[0] - v2[0], d2 = v1[1] - v2[1]; return (d1 * d1) + (d2 * d2); }
[ "public", "static", "double", "quadraticEuclidean", "(", "double", "[", "]", "v1", ",", "double", "[", "]", "v2", ")", "{", "final", "double", "d1", "=", "v1", "[", "0", "]", "-", "v2", "[", "0", "]", ",", "d2", "=", "v1", "[", "1", "]", "-", ...
Squared euclidean distance. 2d. @param v1 First double[] @param v2 Second double[] @return Quadratic distance
[ "Squared", "euclidean", "distance", ".", "2d", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/SweepHullDelaunay2D.java#L693-L696
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/AbstractObjDynamicHistogram.java
AbstractObjDynamicHistogram.aggregateSpecial
protected void aggregateSpecial(T value, int bin) { final T exist = getSpecial(bin); // Note: do not inline above accessor, as getSpecial will initialize the // special variable used below! special[bin] = aggregate(exist, value); }
java
protected void aggregateSpecial(T value, int bin) { final T exist = getSpecial(bin); // Note: do not inline above accessor, as getSpecial will initialize the // special variable used below! special[bin] = aggregate(exist, value); }
[ "protected", "void", "aggregateSpecial", "(", "T", "value", ",", "int", "bin", ")", "{", "final", "T", "exist", "=", "getSpecial", "(", "bin", ")", ";", "// Note: do not inline above accessor, as getSpecial will initialize the", "// special variable used below!", "special...
Aggregate for a special value. @param value Parameter value @param bin Special bin index.
[ "Aggregate", "for", "a", "special", "value", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/AbstractObjDynamicHistogram.java#L161-L166
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/AbstractProjectionAlgorithm.java
AbstractProjectionAlgorithm.removePreviousRelation
protected void removePreviousRelation(Relation<?> relation) { if(keep) { return; } boolean first = true; for(It<Index> it = relation.getHierarchy().iterDescendants(relation).filter(Index.class); it.valid(); it.advance()) { if(first) { Logging.getLogger(getClass()).statistics("Index statistics when removing initial data relation."); first = false; } it.get().logStatistics(); } ResultUtil.removeRecursive(relation.getHierarchy(), relation); }
java
protected void removePreviousRelation(Relation<?> relation) { if(keep) { return; } boolean first = true; for(It<Index> it = relation.getHierarchy().iterDescendants(relation).filter(Index.class); it.valid(); it.advance()) { if(first) { Logging.getLogger(getClass()).statistics("Index statistics when removing initial data relation."); first = false; } it.get().logStatistics(); } ResultUtil.removeRecursive(relation.getHierarchy(), relation); }
[ "protected", "void", "removePreviousRelation", "(", "Relation", "<", "?", ">", "relation", ")", "{", "if", "(", "keep", ")", "{", "return", ";", "}", "boolean", "first", "=", "true", ";", "for", "(", "It", "<", "Index", ">", "it", "=", "relation", "....
Remove the previous relation. Manually also log index statistics, as we may be removing indexes. @param relation Relation to remove
[ "Remove", "the", "previous", "relation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/AbstractProjectionAlgorithm.java#L68-L81
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mktab/MkTabTreeNode.java
MkTabTreeNode.kNNDistances
protected double[] kNNDistances() { int k = getEntry(0).getKnnDistances().length; double[] result = new double[k]; for(int i = 0; i < getNumEntries(); i++) { for(int j = 0; j < k; j++) { MkTabEntry entry = getEntry(i); result[j] = Math.max(result[j], entry.getKnnDistance(j + 1)); } } return result; }
java
protected double[] kNNDistances() { int k = getEntry(0).getKnnDistances().length; double[] result = new double[k]; for(int i = 0; i < getNumEntries(); i++) { for(int j = 0; j < k; j++) { MkTabEntry entry = getEntry(i); result[j] = Math.max(result[j], entry.getKnnDistance(j + 1)); } } return result; }
[ "protected", "double", "[", "]", "kNNDistances", "(", ")", "{", "int", "k", "=", "getEntry", "(", "0", ")", ".", "getKnnDistances", "(", ")", ".", "length", ";", "double", "[", "]", "result", "=", "new", "double", "[", "k", "]", ";", "for", "(", ...
Determines and returns the knn distance of this node as the maximum knn distance of all entries. @return the knn distance of this node
[ "Determines", "and", "returns", "the", "knn", "distance", "of", "this", "node", "as", "the", "maximum", "knn", "distance", "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/mktab/MkTabTreeNode.java#L66-L79
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/VarianceOfVolume.java
VarianceOfVolume.run
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress("VOV", 3) : null; DBIDs ids = relation.getDBIDs(); int dim = RelationUtil.dimensionality(relation); LOG.beginStep(stepprog, 1, "Materializing nearest-neighbor sets."); KNNQuery<O> knnq = DatabaseUtil.precomputedKNNQuery(database, relation, getDistanceFunction(), k); // Compute Volumes LOG.beginStep(stepprog, 2, "Computing Volumes."); WritableDoubleDataStore vols = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); computeVolumes(knnq, dim, ids, vols); // compute VOV of each object LOG.beginStep(stepprog, 3, "Computing Variance of Volumes (VOV)."); WritableDoubleDataStore vovs = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); // track the maximum value for normalization. DoubleMinMax vovminmax = new DoubleMinMax(); computeVOVs(knnq, ids, vols, vovs, vovminmax); LOG.setCompleted(stepprog); // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Variance of Volume", "vov-outlier", vovs, ids); OutlierScoreMeta scoreMeta = new BasicOutlierScoreMeta(vovminmax.getMin(), vovminmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 0.0); return new OutlierResult(scoreMeta, scoreResult); }
java
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress("VOV", 3) : null; DBIDs ids = relation.getDBIDs(); int dim = RelationUtil.dimensionality(relation); LOG.beginStep(stepprog, 1, "Materializing nearest-neighbor sets."); KNNQuery<O> knnq = DatabaseUtil.precomputedKNNQuery(database, relation, getDistanceFunction(), k); // Compute Volumes LOG.beginStep(stepprog, 2, "Computing Volumes."); WritableDoubleDataStore vols = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP); computeVolumes(knnq, dim, ids, vols); // compute VOV of each object LOG.beginStep(stepprog, 3, "Computing Variance of Volumes (VOV)."); WritableDoubleDataStore vovs = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); // track the maximum value for normalization. DoubleMinMax vovminmax = new DoubleMinMax(); computeVOVs(knnq, ids, vols, vovs, vovminmax); LOG.setCompleted(stepprog); // Build result representation. DoubleRelation scoreResult = new MaterializedDoubleRelation("Variance of Volume", "vov-outlier", vovs, ids); OutlierScoreMeta scoreMeta = new BasicOutlierScoreMeta(vovminmax.getMin(), vovminmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 0.0); return new OutlierResult(scoreMeta, scoreResult); }
[ "public", "OutlierResult", "run", "(", "Database", "database", ",", "Relation", "<", "O", ">", "relation", ")", "{", "StepProgress", "stepprog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "StepProgress", "(", "\"VOV\"", ",", "3", ")", ":", "null...
Runs the VOV algorithm on the given database. @param database Database to query @param relation Data to process @return VOV outlier result
[ "Runs", "the", "VOV", "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/VarianceOfVolume.java#L122-L148
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/VarianceOfVolume.java
VarianceOfVolume.computeVOVs
private void computeVOVs(KNNQuery<O> knnq, DBIDs ids, DoubleDataStore vols, WritableDoubleDataStore vovs, DoubleMinMax vovminmax) { FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Variance of Volume", ids.size(), LOG) : null; boolean warned = false; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { KNNList knns = knnq.getKNNForDBID(iter, k); DoubleDBIDListIter it = knns.iter(); double vbar = 0.; for(; it.valid(); it.advance()) { vbar += vols.doubleValue(it); } vbar /= knns.size(); // Average double vov = 0.; for(it.seek(0); it.valid(); it.advance()) { double v = vols.doubleValue(it) - vbar; vov += v * v; } if(!(vov < Double.POSITIVE_INFINITY) && !warned) { LOG.warning("Variance of Volumes has hit double precision limits, results are not reliable."); warned = true; } vov = (vov < Double.POSITIVE_INFINITY) ? vov / (knns.size() - 1) : Double.POSITIVE_INFINITY; vovs.putDouble(iter, vov); // update minimum and maximum vovminmax.put(vov); LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); }
java
private void computeVOVs(KNNQuery<O> knnq, DBIDs ids, DoubleDataStore vols, WritableDoubleDataStore vovs, DoubleMinMax vovminmax) { FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Variance of Volume", ids.size(), LOG) : null; boolean warned = false; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { KNNList knns = knnq.getKNNForDBID(iter, k); DoubleDBIDListIter it = knns.iter(); double vbar = 0.; for(; it.valid(); it.advance()) { vbar += vols.doubleValue(it); } vbar /= knns.size(); // Average double vov = 0.; for(it.seek(0); it.valid(); it.advance()) { double v = vols.doubleValue(it) - vbar; vov += v * v; } if(!(vov < Double.POSITIVE_INFINITY) && !warned) { LOG.warning("Variance of Volumes has hit double precision limits, results are not reliable."); warned = true; } vov = (vov < Double.POSITIVE_INFINITY) ? vov / (knns.size() - 1) : Double.POSITIVE_INFINITY; vovs.putDouble(iter, vov); // update minimum and maximum vovminmax.put(vov); LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); }
[ "private", "void", "computeVOVs", "(", "KNNQuery", "<", "O", ">", "knnq", ",", "DBIDs", "ids", ",", "DoubleDataStore", "vols", ",", "WritableDoubleDataStore", "vovs", ",", "DoubleMinMax", "vovminmax", ")", "{", "FiniteProgress", "prog", "=", "LOG", ".", "isVer...
Compute variance of volumes. @param knnq KNN query @param ids IDs to process @param vols Volumes @param vovs Variance of Volume storage @param vovminmax Score minimum/maximum tracker
[ "Compute", "variance", "of", "volumes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/VarianceOfVolume.java#L190-L217
train
elki-project/elki
elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java
NNDescent.boundSize
private void boundSize(HashSetModifiableDBIDs set, int items) { if(set.size() > items) { DBIDs sample = DBIDUtil.randomSample(set, items, rnd); set.clear(); set.addDBIDs(sample); } }
java
private void boundSize(HashSetModifiableDBIDs set, int items) { if(set.size() > items) { DBIDs sample = DBIDUtil.randomSample(set, items, rnd); set.clear(); set.addDBIDs(sample); } }
[ "private", "void", "boundSize", "(", "HashSetModifiableDBIDs", "set", ",", "int", "items", ")", "{", "if", "(", "set", ".", "size", "(", ")", ">", "items", ")", "{", "DBIDs", "sample", "=", "DBIDUtil", ".", "randomSample", "(", "set", ",", "items", ","...
Bound the size of a set by random sampling. @param set Set to process @param items Maximum size
[ "Bound", "the", "size", "of", "a", "set", "by", "random", "sampling", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java#L281-L287
train
elki-project/elki
elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java
NNDescent.add
private boolean add(DBIDRef cur, DBIDRef cand, double distance) { KNNHeap neighbors = store.get(cur); if(neighbors.contains(cand)) { return false; } double newKDistance = neighbors.insert(distance, cand); return (distance <= newKDistance); }
java
private boolean add(DBIDRef cur, DBIDRef cand, double distance) { KNNHeap neighbors = store.get(cur); if(neighbors.contains(cand)) { return false; } double newKDistance = neighbors.insert(distance, cand); return (distance <= newKDistance); }
[ "private", "boolean", "add", "(", "DBIDRef", "cur", ",", "DBIDRef", "cand", ",", "double", "distance", ")", "{", "KNNHeap", "neighbors", "=", "store", ".", "get", "(", "cur", ")", ";", "if", "(", "neighbors", ".", "contains", "(", "cand", ")", ")", "...
Add cand to cur's heap neighbors with distance @param cur Current object @param cand Neighbor candidate @param distance Distance @return {@code true} if it was a new neighbor.
[ "Add", "cand", "to", "cur", "s", "heap", "neighbors", "with", "distance" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java#L388-L395
train
elki-project/elki
elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java
NNDescent.sampleNew
private int sampleNew(DBIDs ids, WritableDataStore<HashSetModifiableDBIDs> sampleNewNeighbors, WritableDataStore<HashSetModifiableDBIDs> newNeighborHash, int items) { int t = 0; for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { KNNHeap realNeighbors = store.get(iditer); HashSetModifiableDBIDs newNeighbors = newNeighborHash.get(iditer); HashSetModifiableDBIDs realNewNeighbors = sampleNewNeighbors.get(iditer); realNewNeighbors.clear(); // Reuse for(DoubleDBIDListIter heapiter = realNeighbors.unorderedIterator(); heapiter.valid(); heapiter.advance()) { if(newNeighbors.contains(heapiter)) { realNewNeighbors.add(heapiter); t++; } } boundSize(realNewNeighbors, items); newNeighbors.removeDBIDs(realNewNeighbors); newNeighborHash.put(iditer, newNeighbors); } return t; }
java
private int sampleNew(DBIDs ids, WritableDataStore<HashSetModifiableDBIDs> sampleNewNeighbors, WritableDataStore<HashSetModifiableDBIDs> newNeighborHash, int items) { int t = 0; for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { KNNHeap realNeighbors = store.get(iditer); HashSetModifiableDBIDs newNeighbors = newNeighborHash.get(iditer); HashSetModifiableDBIDs realNewNeighbors = sampleNewNeighbors.get(iditer); realNewNeighbors.clear(); // Reuse for(DoubleDBIDListIter heapiter = realNeighbors.unorderedIterator(); heapiter.valid(); heapiter.advance()) { if(newNeighbors.contains(heapiter)) { realNewNeighbors.add(heapiter); t++; } } boundSize(realNewNeighbors, items); newNeighbors.removeDBIDs(realNewNeighbors); newNeighborHash.put(iditer, newNeighbors); } return t; }
[ "private", "int", "sampleNew", "(", "DBIDs", "ids", ",", "WritableDataStore", "<", "HashSetModifiableDBIDs", ">", "sampleNewNeighbors", ",", "WritableDataStore", "<", "HashSetModifiableDBIDs", ">", "newNeighborHash", ",", "int", "items", ")", "{", "int", "t", "=", ...
samples newNeighbors for every object @param ids All ids @param sampleNewNeighbors Output of sampled new neighbors @param newNeighborHash - new neighbors for every object @param items Number of items to collect @return Number of new neighbors
[ "samples", "newNeighbors", "for", "every", "object" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java#L416-L435
train
elki-project/elki
elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java
NNDescent.reverse
private void reverse(WritableDataStore<HashSetModifiableDBIDs> sampleNewHash, WritableDataStore<HashSetModifiableDBIDs> newReverseNeighbors, WritableDataStore<HashSetModifiableDBIDs> oldReverseNeighbors) { for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { KNNHeap heap = store.get(iditer); HashSetDBIDs newNeighbors = sampleNewHash.get(iditer); for(DoubleDBIDListIter heapiter = heap.unorderedIterator(); heapiter.valid(); heapiter.advance()) { (newNeighbors.contains(heapiter) ? newReverseNeighbors : oldReverseNeighbors).get(heapiter).add(iditer); } } }
java
private void reverse(WritableDataStore<HashSetModifiableDBIDs> sampleNewHash, WritableDataStore<HashSetModifiableDBIDs> newReverseNeighbors, WritableDataStore<HashSetModifiableDBIDs> oldReverseNeighbors) { for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { KNNHeap heap = store.get(iditer); HashSetDBIDs newNeighbors = sampleNewHash.get(iditer); for(DoubleDBIDListIter heapiter = heap.unorderedIterator(); heapiter.valid(); heapiter.advance()) { (newNeighbors.contains(heapiter) ? newReverseNeighbors : oldReverseNeighbors).get(heapiter).add(iditer); } } }
[ "private", "void", "reverse", "(", "WritableDataStore", "<", "HashSetModifiableDBIDs", ">", "sampleNewHash", ",", "WritableDataStore", "<", "HashSetModifiableDBIDs", ">", "newReverseNeighbors", ",", "WritableDataStore", "<", "HashSetModifiableDBIDs", ">", "oldReverseNeighbors...
calculates new and old neighbors for database @param sampleNewHash new neighbors for every object @param newReverseNeighbors new reverse neighbors @param oldReverseNeighbors old reverse neighbors
[ "calculates", "new", "and", "old", "neighbors", "for", "database" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/NNDescent.java#L444-L452
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/set/JaccardSimilarityDistanceFunction.java
JaccardSimilarityDistanceFunction.similarityNumberVector
public static double similarityNumberVector(NumberVector o1, NumberVector o2) { final int d1 = o1.getDimensionality(), d2 = o2.getDimensionality(); int intersection = 0, union = 0; int d = 0; for(; d < d1 && d < d2; d++) { double v1 = o1.doubleValue(d), v2 = o2.doubleValue(d); if(v1 != v1 || v2 != v2) { // Skip NaNs. continue; } if(v1 != 0. || v2 != 0) { ++union; if(v1 == v2) { ++intersection; } } } for(; d < d1; d++) { if(o1.doubleValue(d) != 0) { ++union; } } for(; d < d2; d++) { if(o2.doubleValue(d) != 0) { ++union; } } return intersection / (double) union; }
java
public static double similarityNumberVector(NumberVector o1, NumberVector o2) { final int d1 = o1.getDimensionality(), d2 = o2.getDimensionality(); int intersection = 0, union = 0; int d = 0; for(; d < d1 && d < d2; d++) { double v1 = o1.doubleValue(d), v2 = o2.doubleValue(d); if(v1 != v1 || v2 != v2) { // Skip NaNs. continue; } if(v1 != 0. || v2 != 0) { ++union; if(v1 == v2) { ++intersection; } } } for(; d < d1; d++) { if(o1.doubleValue(d) != 0) { ++union; } } for(; d < d2; d++) { if(o2.doubleValue(d) != 0) { ++union; } } return intersection / (double) union; }
[ "public", "static", "double", "similarityNumberVector", "(", "NumberVector", "o1", ",", "NumberVector", "o2", ")", "{", "final", "int", "d1", "=", "o1", ".", "getDimensionality", "(", ")", ",", "d2", "=", "o2", ".", "getDimensionality", "(", ")", ";", "int...
Compute Jaccard similarity for two number vectors. @param o1 First vector @param o2 Second vector @return Jaccard similarity
[ "Compute", "Jaccard", "similarity", "for", "two", "number", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/set/JaccardSimilarityDistanceFunction.java#L124-L151
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/AbstractMkTree.java
AbstractMkTree.batchNN
@Deprecated protected final Map<DBID, KNNList> batchNN(N node, DBIDs ids, int kmax) { Map<DBID, KNNList> res = new HashMap<>(ids.size()); for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { DBID id = DBIDUtil.deref(iter); res.put(id, knnq.getKNNForDBID(id, kmax)); } return res; }
java
@Deprecated protected final Map<DBID, KNNList> batchNN(N node, DBIDs ids, int kmax) { Map<DBID, KNNList> res = new HashMap<>(ids.size()); for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { DBID id = DBIDUtil.deref(iter); res.put(id, knnq.getKNNForDBID(id, kmax)); } return res; }
[ "@", "Deprecated", "protected", "final", "Map", "<", "DBID", ",", "KNNList", ">", "batchNN", "(", "N", "node", ",", "DBIDs", "ids", ",", "int", "kmax", ")", "{", "Map", "<", "DBID", ",", "KNNList", ">", "res", "=", "new", "HashMap", "<>", "(", "ids...
Performs a batch k-nearest neighbor query for a list of query objects. @param node the node representing the subtree on which the query should be performed @param ids the ids of the query objects @param kmax Maximum k value @deprecated Change to use by-object NN lookups instead.
[ "Performs", "a", "batch", "k", "-", "nearest", "neighbor", "query", "for", "a", "list", "of", "query", "objects", "." ]
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/AbstractMkTree.java#L106-L114
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/ComputeKNNOutlierScores.java
ComputeKNNOutlierScores.writeResult
void writeResult(PrintStream out, DBIDs ids, OutlierResult result, ScalingFunction scaling, String label) { if(scaling instanceof OutlierScaling) { ((OutlierScaling) scaling).prepare(result); } out.append(label); DoubleRelation scores = result.getScores(); for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double value = scores.doubleValue(iter); value = scaling != null ? scaling.getScaled(value) : value; out.append(' ').append(Double.toString(value)); } out.append(FormatUtil.NEWLINE); }
java
void writeResult(PrintStream out, DBIDs ids, OutlierResult result, ScalingFunction scaling, String label) { if(scaling instanceof OutlierScaling) { ((OutlierScaling) scaling).prepare(result); } out.append(label); DoubleRelation scores = result.getScores(); for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double value = scores.doubleValue(iter); value = scaling != null ? scaling.getScaled(value) : value; out.append(' ').append(Double.toString(value)); } out.append(FormatUtil.NEWLINE); }
[ "void", "writeResult", "(", "PrintStream", "out", ",", "DBIDs", "ids", ",", "OutlierResult", "result", ",", "ScalingFunction", "scaling", ",", "String", "label", ")", "{", "if", "(", "scaling", "instanceof", "OutlierScaling", ")", "{", "(", "(", "OutlierScalin...
Write a single output line. @param out Output stream @param ids DBIDs @param result Outlier result @param scaling Scaling function @param label Identification label
[ "Write", "a", "single", "output", "line", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/ComputeKNNOutlierScores.java#L336-L348
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/ComputeKNNOutlierScores.java
ComputeKNNOutlierScores.runForEachK
private void runForEachK(String prefix, int mink, int maxk, IntFunction<OutlierResult> runner, BiConsumer<String, OutlierResult> out) { if(isDisabled(prefix)) { LOG.verbose("Skipping (disabled): " + prefix); return; // Disabled } LOG.verbose("Running " + prefix); final int digits = (int) FastMath.ceil(FastMath.log10(krange.getMax() + 1)); final String format = "%s-%0" + digits + "d"; krange.forEach(k -> { if(k >= mink && k <= maxk) { Duration time = LOG.newDuration(this.getClass().getCanonicalName() + "." + prefix + ".k" + k + ".runtime").begin(); OutlierResult result = runner.apply(k); LOG.statistics(time.end()); if(result != null) { out.accept(String.format(Locale.ROOT, format, prefix, k), result); result.getHierarchy().removeSubtree(result); } } }); }
java
private void runForEachK(String prefix, int mink, int maxk, IntFunction<OutlierResult> runner, BiConsumer<String, OutlierResult> out) { if(isDisabled(prefix)) { LOG.verbose("Skipping (disabled): " + prefix); return; // Disabled } LOG.verbose("Running " + prefix); final int digits = (int) FastMath.ceil(FastMath.log10(krange.getMax() + 1)); final String format = "%s-%0" + digits + "d"; krange.forEach(k -> { if(k >= mink && k <= maxk) { Duration time = LOG.newDuration(this.getClass().getCanonicalName() + "." + prefix + ".k" + k + ".runtime").begin(); OutlierResult result = runner.apply(k); LOG.statistics(time.end()); if(result != null) { out.accept(String.format(Locale.ROOT, format, prefix, k), result); result.getHierarchy().removeSubtree(result); } } }); }
[ "private", "void", "runForEachK", "(", "String", "prefix", ",", "int", "mink", ",", "int", "maxk", ",", "IntFunction", "<", "OutlierResult", ">", "runner", ",", "BiConsumer", "<", "String", ",", "OutlierResult", ">", "out", ")", "{", "if", "(", "isDisabled...
Iterate over the k range. @param prefix Prefix string @param mink Minimum value of k for this method @param maxk Maximum value of k for this method @param runner Runner to run @param out Output function
[ "Iterate", "over", "the", "k", "range", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/ComputeKNNOutlierScores.java#L359-L378
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/PolynomialApproximation.java
PolynomialApproximation.getCoefficients
public double[] getCoefficients() { double[] result = new double[b.length]; System.arraycopy(b, 0, result, 0, b.length); return result; }
java
public double[] getCoefficients() { double[] result = new double[b.length]; System.arraycopy(b, 0, result, 0, b.length); return result; }
[ "public", "double", "[", "]", "getCoefficients", "(", ")", "{", "double", "[", "]", "result", "=", "new", "double", "[", "b", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "b", ",", "0", ",", "result", ",", "0", ",", "b", ".", "length...
Returns a copy of the the array of coefficients b0, ..., bp. @return the a copy of the array of coefficients b0, ..., bp
[ "Returns", "a", "copy", "of", "the", "the", "array", "of", "coefficients", "b0", "...", "bp", "." ]
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/mkapp/PolynomialApproximation.java#L77-L81
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/PolynomialApproximation.java
PolynomialApproximation.getValueAt
public double getValueAt(int k) { double result = 0.; double log_k = FastMath.log(k), acc = 1.; for (int p = 0; p < b.length; p++) { result += b[p] * acc; acc *= log_k; } return result; }
java
public double getValueAt(int k) { double result = 0.; double log_k = FastMath.log(k), acc = 1.; for (int p = 0; p < b.length; p++) { result += b[p] * acc; acc *= log_k; } return result; }
[ "public", "double", "getValueAt", "(", "int", "k", ")", "{", "double", "result", "=", "0.", ";", "double", "log_k", "=", "FastMath", ".", "log", "(", "k", ")", ",", "acc", "=", "1.", ";", "for", "(", "int", "p", "=", "0", ";", "p", "<", "b", ...
Returns the function value of the polynomial approximation at the specified k. @param k the value for which the polynomial approximation should be returned @return the function value of the polynomial approximation at the specified k
[ "Returns", "the", "function", "value", "of", "the", "polynomial", "approximation", "at", "the", "specified", "k", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/PolynomialApproximation.java#L100-L108
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/projection/FeatureSelection.java
FeatureSelection.getAdapter
@SuppressWarnings("unchecked") private static <V extends FeatureVector<F>, F> ArrayAdapter<F, ? super V> getAdapter(Factory<V, F> factory) { if(factory instanceof NumberVector.Factory) { return (ArrayAdapter<F, ? super V>) NumberVectorAdapter.STATIC; } return (ArrayAdapter<F, ? super V>) FeatureVectorAdapter.STATIC; }
java
@SuppressWarnings("unchecked") private static <V extends FeatureVector<F>, F> ArrayAdapter<F, ? super V> getAdapter(Factory<V, F> factory) { if(factory instanceof NumberVector.Factory) { return (ArrayAdapter<F, ? super V>) NumberVectorAdapter.STATIC; } return (ArrayAdapter<F, ? super V>) FeatureVectorAdapter.STATIC; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "<", "V", "extends", "FeatureVector", "<", "F", ">", ",", "F", ">", "ArrayAdapter", "<", "F", ",", "?", "super", "V", ">", "getAdapter", "(", "Factory", "<", "V", ",", "F", ">", ...
Choose the best adapter for this. @param factory Object factory, for type inference @param <V> Vector type @param <F> Value type @return Adapter
[ "Choose", "the", "best", "adapter", "for", "this", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/projection/FeatureSelection.java#L112-L118
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/FastOPTICS.java
FastOPTICS.expandClusterOrder
protected void expandClusterOrder(DBID ipt, ClusterOrder order, DistanceQuery<V> dq, FiniteProgress prog) { UpdatableHeap<OPTICSHeapEntry> heap = new UpdatableHeap<>(); heap.add(new OPTICSHeapEntry(ipt, null, Double.POSITIVE_INFINITY)); while(!heap.isEmpty()) { final OPTICSHeapEntry current = heap.poll(); DBID currPt = current.objectID; order.add(currPt, current.reachability, current.predecessorID); processed.add(currPt); double coredist = inverseDensities.doubleValue(currPt); for(DBIDIter it = neighs.get(currPt).iter(); it.valid(); it.advance()) { if(processed.contains(it)) { continue; } double nrdist = dq.distance(currPt, it); if(coredist > nrdist) { nrdist = coredist; } if(reachDist.doubleValue(it) == UNDEFINED_DISTANCE) { reachDist.put(it, nrdist); } else if(nrdist < reachDist.doubleValue(it)) { reachDist.put(it, nrdist); } heap.add(new OPTICSHeapEntry(DBIDUtil.deref(it), currPt, nrdist)); } LOG.incrementProcessed(prog); } }
java
protected void expandClusterOrder(DBID ipt, ClusterOrder order, DistanceQuery<V> dq, FiniteProgress prog) { UpdatableHeap<OPTICSHeapEntry> heap = new UpdatableHeap<>(); heap.add(new OPTICSHeapEntry(ipt, null, Double.POSITIVE_INFINITY)); while(!heap.isEmpty()) { final OPTICSHeapEntry current = heap.poll(); DBID currPt = current.objectID; order.add(currPt, current.reachability, current.predecessorID); processed.add(currPt); double coredist = inverseDensities.doubleValue(currPt); for(DBIDIter it = neighs.get(currPt).iter(); it.valid(); it.advance()) { if(processed.contains(it)) { continue; } double nrdist = dq.distance(currPt, it); if(coredist > nrdist) { nrdist = coredist; } if(reachDist.doubleValue(it) == UNDEFINED_DISTANCE) { reachDist.put(it, nrdist); } else if(nrdist < reachDist.doubleValue(it)) { reachDist.put(it, nrdist); } heap.add(new OPTICSHeapEntry(DBIDUtil.deref(it), currPt, nrdist)); } LOG.incrementProcessed(prog); } }
[ "protected", "void", "expandClusterOrder", "(", "DBID", "ipt", ",", "ClusterOrder", "order", ",", "DistanceQuery", "<", "V", ">", "dq", ",", "FiniteProgress", "prog", ")", "{", "UpdatableHeap", "<", "OPTICSHeapEntry", ">", "heap", "=", "new", "UpdatableHeap", ...
OPTICS algorithm for processing a point, but with different density estimates @param ipt Point @param order Cluster order (output) @param dq Distance query @param prog Progress for logging.
[ "OPTICS", "algorithm", "for", "processing", "a", "point", "but", "with", "different", "density", "estimates" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/FastOPTICS.java#L181-L208
train
elki-project/elki
elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskUpperTriangleMatrix.java
OnDiskUpperTriangleMatrix.resizeMatrix
public synchronized void resizeMatrix(int newsize) throws IOException { if(newsize >= 0xFFFF) { throw new RuntimeException("Matrix size is too big and will overflow the integer datatype."); } if(!array.isWritable()) { throw new IOException("Can't resize a read-only array."); } array.resizeFile(arraysize(newsize)); this.matrixsize = newsize; ByteBuffer header = array.getExtraHeader(); header.putInt(this.matrixsize); }
java
public synchronized void resizeMatrix(int newsize) throws IOException { if(newsize >= 0xFFFF) { throw new RuntimeException("Matrix size is too big and will overflow the integer datatype."); } if(!array.isWritable()) { throw new IOException("Can't resize a read-only array."); } array.resizeFile(arraysize(newsize)); this.matrixsize = newsize; ByteBuffer header = array.getExtraHeader(); header.putInt(this.matrixsize); }
[ "public", "synchronized", "void", "resizeMatrix", "(", "int", "newsize", ")", "throws", "IOException", "{", "if", "(", "newsize", ">=", "0xFFFF", ")", "{", "throw", "new", "RuntimeException", "(", "\"Matrix size is too big and will overflow the integer datatype.\"", ")"...
Resize the matrix to cover newsize x newsize. @param newsize New matrix size. @throws IOException on IO errors
[ "Resize", "the", "matrix", "to", "cover", "newsize", "x", "newsize", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskUpperTriangleMatrix.java#L102-L113
train
elki-project/elki
elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskUpperTriangleMatrix.java
OnDiskUpperTriangleMatrix.computeOffset
private int computeOffset(int x, int y) { if(y > x) { return computeOffset(y, x); } return ((x * (x + 1)) >> 1) + y; }
java
private int computeOffset(int x, int y) { if(y > x) { return computeOffset(y, x); } return ((x * (x + 1)) >> 1) + y; }
[ "private", "int", "computeOffset", "(", "int", "x", ",", "int", "y", ")", "{", "if", "(", "y", ">", "x", ")", "{", "return", "computeOffset", "(", "y", ",", "x", ")", ";", "}", "return", "(", "(", "x", "*", "(", "x", "+", "1", ")", ")", ">>...
Compute the offset within the file. @param x First coordinate @param y Second coordinate @return Linear offset
[ "Compute", "the", "offset", "within", "the", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskUpperTriangleMatrix.java#L132-L137
train
elki-project/elki
elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskArray.java
OnDiskArray.validateHeader
private void validateHeader(boolean validateRecordSize) throws IOException { int readmagic = file.readInt(); // Validate magic number if (readmagic != this.magic) { file.close(); throw new IOException("Magic in LinearDiskCache does not match: " + readmagic + " instead of " + this.magic); } // Validate header size if (file.readInt() != this.headersize) { file.close(); throw new IOException("Header size in LinearDiskCache does not match."); } if (validateRecordSize) { // Validate record size if (file.readInt() != this.recordsize) { file.close(); throw new IOException("Recordsize in LinearDiskCache does not match."); } } else { // or just read it from file this.recordsize = file.readInt(); } // read the number of records and validate with file size. if (file.getFilePointer() != HEADER_POS_SIZE) { throw new IOException("Incorrect file position when reading header."); } this.numrecs = file.readInt(); if (numrecs < 0 || file.length() != indexToFileposition(numrecs)) { throw new IOException("File size and number of records do not agree."); } // yet another sanity check. We should have read all of our internal header // now. if (file.getFilePointer() != INTERNAL_HEADER_SIZE) { throw new IOException("Incorrect file position after reading header."); } }
java
private void validateHeader(boolean validateRecordSize) throws IOException { int readmagic = file.readInt(); // Validate magic number if (readmagic != this.magic) { file.close(); throw new IOException("Magic in LinearDiskCache does not match: " + readmagic + " instead of " + this.magic); } // Validate header size if (file.readInt() != this.headersize) { file.close(); throw new IOException("Header size in LinearDiskCache does not match."); } if (validateRecordSize) { // Validate record size if (file.readInt() != this.recordsize) { file.close(); throw new IOException("Recordsize in LinearDiskCache does not match."); } } else { // or just read it from file this.recordsize = file.readInt(); } // read the number of records and validate with file size. if (file.getFilePointer() != HEADER_POS_SIZE) { throw new IOException("Incorrect file position when reading header."); } this.numrecs = file.readInt(); if (numrecs < 0 || file.length() != indexToFileposition(numrecs)) { throw new IOException("File size and number of records do not agree."); } // yet another sanity check. We should have read all of our internal header // now. if (file.getFilePointer() != INTERNAL_HEADER_SIZE) { throw new IOException("Incorrect file position after reading header."); } }
[ "private", "void", "validateHeader", "(", "boolean", "validateRecordSize", ")", "throws", "IOException", "{", "int", "readmagic", "=", "file", ".", "readInt", "(", ")", ";", "// Validate magic number", "if", "(", "readmagic", "!=", "this", ".", "magic", ")", "...
Validates the header and throws an IOException if the header is invalid. If validateRecordSize is set to true the record size must match exactly the stored record size within the files header, else the record size is read from the header and used. @param validateRecordSize @throws IOException
[ "Validates", "the", "header", "and", "throws", "an", "IOException", "if", "the", "header", "is", "invalid", ".", "If", "validateRecordSize", "is", "set", "to", "true", "the", "record", "size", "must", "match", "exactly", "the", "stored", "record", "size", "w...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskArray.java#L252-L289
train
elki-project/elki
elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskArray.java
OnDiskArray.resizeFile
public synchronized void resizeFile(int newsize) throws IOException { if (!writable) { throw new IOException("File is not writeable!"); } // update the number of records this.numrecs = newsize; file.seek(HEADER_POS_SIZE); file.writeInt(numrecs); // resize file file.setLength(indexToFileposition(numrecs)); mapArray(); }
java
public synchronized void resizeFile(int newsize) throws IOException { if (!writable) { throw new IOException("File is not writeable!"); } // update the number of records this.numrecs = newsize; file.seek(HEADER_POS_SIZE); file.writeInt(numrecs); // resize file file.setLength(indexToFileposition(numrecs)); mapArray(); }
[ "public", "synchronized", "void", "resizeFile", "(", "int", "newsize", ")", "throws", "IOException", "{", "if", "(", "!", "writable", ")", "{", "throw", "new", "IOException", "(", "\"File is not writeable!\"", ")", ";", "}", "// update the number of records", "thi...
Resize file to the intended size @param newsize New file size. @throws IOException on IO errors
[ "Resize", "file", "to", "the", "intended", "size" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskArray.java#L324-L336
train
elki-project/elki
elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskArray.java
OnDiskArray.getExtraHeader
public synchronized ByteBuffer getExtraHeader() throws IOException { final int size = headersize - INTERNAL_HEADER_SIZE; final MapMode mode = writable ? MapMode.READ_WRITE : MapMode.READ_ONLY; return file.getChannel().map(mode, INTERNAL_HEADER_SIZE, size); }
java
public synchronized ByteBuffer getExtraHeader() throws IOException { final int size = headersize - INTERNAL_HEADER_SIZE; final MapMode mode = writable ? MapMode.READ_WRITE : MapMode.READ_ONLY; return file.getChannel().map(mode, INTERNAL_HEADER_SIZE, size); }
[ "public", "synchronized", "ByteBuffer", "getExtraHeader", "(", ")", "throws", "IOException", "{", "final", "int", "size", "=", "headersize", "-", "INTERNAL_HEADER_SIZE", ";", "final", "MapMode", "mode", "=", "writable", "?", "MapMode", ".", "READ_WRITE", ":", "M...
Read the extra header data. @return additional header data @throws IOException on IO errors
[ "Read", "the", "extra", "header", "data", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/OnDiskArray.java#L372-L376
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java
MiniMax.run
public PointerPrototypeHierarchyRepresentationResult run(Database db, Relation<O> relation) { DistanceQuery<O> dq = DatabaseUtil.precomputedDistanceQuery(db, relation, getDistanceFunction(), LOG); final DBIDs ids = relation.getDBIDs(); final int size = ids.size(); // Initialize space for result: PointerHierarchyRepresentationBuilder builder = new PointerHierarchyRepresentationBuilder(ids, dq.getDistanceFunction().isSquared()); Int2ObjectOpenHashMap<ModifiableDBIDs> clusters = new Int2ObjectOpenHashMap<>(size); // Allocate working space: MatrixParadigm mat = new MatrixParadigm(ids); ArrayModifiableDBIDs prots = DBIDUtil.newArray(MatrixParadigm.triangleSize(size)); initializeMatrices(mat, prots, dq); DBIDArrayMIter protiter = prots.iter(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("MiniMax clustering", size - 1, LOG) : null; DBIDArrayIter ix = mat.ix; for(int i = 1, end = size; i < size; i++) { end = AGNES.shrinkActiveSet(ix, builder, end, // findMerge(end, mat, protiter, builder, clusters, dq)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); return (PointerPrototypeHierarchyRepresentationResult) builder.complete(); }
java
public PointerPrototypeHierarchyRepresentationResult run(Database db, Relation<O> relation) { DistanceQuery<O> dq = DatabaseUtil.precomputedDistanceQuery(db, relation, getDistanceFunction(), LOG); final DBIDs ids = relation.getDBIDs(); final int size = ids.size(); // Initialize space for result: PointerHierarchyRepresentationBuilder builder = new PointerHierarchyRepresentationBuilder(ids, dq.getDistanceFunction().isSquared()); Int2ObjectOpenHashMap<ModifiableDBIDs> clusters = new Int2ObjectOpenHashMap<>(size); // Allocate working space: MatrixParadigm mat = new MatrixParadigm(ids); ArrayModifiableDBIDs prots = DBIDUtil.newArray(MatrixParadigm.triangleSize(size)); initializeMatrices(mat, prots, dq); DBIDArrayMIter protiter = prots.iter(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("MiniMax clustering", size - 1, LOG) : null; DBIDArrayIter ix = mat.ix; for(int i = 1, end = size; i < size; i++) { end = AGNES.shrinkActiveSet(ix, builder, end, // findMerge(end, mat, protiter, builder, clusters, dq)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); return (PointerPrototypeHierarchyRepresentationResult) builder.complete(); }
[ "public", "PointerPrototypeHierarchyRepresentationResult", "run", "(", "Database", "db", ",", "Relation", "<", "O", ">", "relation", ")", "{", "DistanceQuery", "<", "O", ">", "dq", "=", "DatabaseUtil", ".", "precomputedDistanceQuery", "(", "db", ",", "relation", ...
Run the algorithm on a database. @param db Database @param relation Relation to process. @return Hierarchical result
[ "Run", "the", "algorithm", "on", "a", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L91-L115
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java
MiniMax.initializeMatrices
protected static <O> void initializeMatrices(MatrixParadigm mat, ArrayModifiableDBIDs prots, DistanceQuery<O> dq) { final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] distances = mat.matrix; int pos = 0; for(ix.seek(0); ix.valid(); ix.advance()) { for(iy.seek(0); iy.getOffset() < ix.getOffset(); iy.advance()) { distances[pos] = dq.distance(ix, iy); prots.add(iy); pos++; } } assert (prots.size() == pos); }
java
protected static <O> void initializeMatrices(MatrixParadigm mat, ArrayModifiableDBIDs prots, DistanceQuery<O> dq) { final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] distances = mat.matrix; int pos = 0; for(ix.seek(0); ix.valid(); ix.advance()) { for(iy.seek(0); iy.getOffset() < ix.getOffset(); iy.advance()) { distances[pos] = dq.distance(ix, iy); prots.add(iy); pos++; } } assert (prots.size() == pos); }
[ "protected", "static", "<", "O", ">", "void", "initializeMatrices", "(", "MatrixParadigm", "mat", ",", "ArrayModifiableDBIDs", "prots", ",", "DistanceQuery", "<", "O", ">", "dq", ")", "{", "final", "DBIDArrayIter", "ix", "=", "mat", ".", "ix", ",", "iy", "...
Initializes the inter-cluster distance matrix of possible merges @param mat Matrix @param dq The distance query
[ "Initializes", "the", "inter", "-", "cluster", "distance", "matrix", "of", "possible", "merges" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L123-L135
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java
MiniMax.findMerge
protected static int findMerge(int end, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq) { final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] distances = mat.matrix; double mindist = Double.POSITIVE_INFINITY; int x = -1, y = -1; for(int dx = 0; dx < end; dx++) { // Skip if object is already linked if(builder.isLinked(ix.seek(dx))) { continue; } final int xoffset = MatrixParadigm.triangleSize(dx); for(int dy = 0; dy < dx; dy++) { // Skip if object is already linked if(builder.isLinked(iy.seek(dy))) { continue; } double dist = distances[xoffset + dy]; if(dist < mindist) { mindist = dist; x = dx; y = dy; } } } assert (y < x); merge(end, mat, prots, builder, clusters, dq, x, y); return x; }
java
protected static int findMerge(int end, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq) { final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] distances = mat.matrix; double mindist = Double.POSITIVE_INFINITY; int x = -1, y = -1; for(int dx = 0; dx < end; dx++) { // Skip if object is already linked if(builder.isLinked(ix.seek(dx))) { continue; } final int xoffset = MatrixParadigm.triangleSize(dx); for(int dy = 0; dy < dx; dy++) { // Skip if object is already linked if(builder.isLinked(iy.seek(dy))) { continue; } double dist = distances[xoffset + dy]; if(dist < mindist) { mindist = dist; x = dx; y = dy; } } } assert (y < x); merge(end, mat, prots, builder, clusters, dq, x, y); return x; }
[ "protected", "static", "int", "findMerge", "(", "int", "end", ",", "MatrixParadigm", "mat", ",", "DBIDArrayMIter", "prots", ",", "PointerHierarchyRepresentationBuilder", "builder", ",", "Int2ObjectOpenHashMap", "<", "ModifiableDBIDs", ">", "clusters", ",", "DistanceQuer...
Find the best merge. @param mat Matrix view @param prots Prototypes @param builder Result builder @param clusters Current clusters @param dq Distance query @return x, for shrinking the working set.
[ "Find", "the", "best", "merge", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L147-L178
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java
MiniMax.merge
protected static void merge(int size, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq, int x, int y) { assert (y < x); final DBIDArrayIter ix = mat.ix.seek(x), iy = mat.iy.seek(y); final double[] distances = mat.matrix; int offset = MatrixParadigm.triangleSize(x) + y; if(LOG.isDebuggingFine()) { LOG.debugFine("Merging: " + DBIDUtil.toString(ix) + " -> " + DBIDUtil.toString(iy) + " " + distances[offset]); } ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y); // Keep y if(cy == null) { cy = DBIDUtil.newHashSet(); cy.add(iy); } if(cx == null) { cy.add(ix); } else { cy.addDBIDs(cx); clusters.remove(x); } clusters.put(y, cy); // parent of x is set to y builder.add(ix, distances[offset], iy, prots.seek(offset)); updateMatrices(size, mat, prots, builder, clusters, dq, y); }
java
protected static void merge(int size, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq, int x, int y) { assert (y < x); final DBIDArrayIter ix = mat.ix.seek(x), iy = mat.iy.seek(y); final double[] distances = mat.matrix; int offset = MatrixParadigm.triangleSize(x) + y; if(LOG.isDebuggingFine()) { LOG.debugFine("Merging: " + DBIDUtil.toString(ix) + " -> " + DBIDUtil.toString(iy) + " " + distances[offset]); } ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y); // Keep y if(cy == null) { cy = DBIDUtil.newHashSet(); cy.add(iy); } if(cx == null) { cy.add(ix); } else { cy.addDBIDs(cx); clusters.remove(x); } clusters.put(y, cy); // parent of x is set to y builder.add(ix, distances[offset], iy, prots.seek(offset)); updateMatrices(size, mat, prots, builder, clusters, dq, y); }
[ "protected", "static", "void", "merge", "(", "int", "size", ",", "MatrixParadigm", "mat", ",", "DBIDArrayMIter", "prots", ",", "PointerHierarchyRepresentationBuilder", "builder", ",", "Int2ObjectOpenHashMap", "<", "ModifiableDBIDs", ">", "clusters", ",", "DistanceQuery"...
Merges two clusters given by x, y, their points with smallest IDs, and y to keep @param size number of ids in the data set @param mat distance matrix @param prots calculated prototypes @param builder Result builder @param clusters the clusters @param dq distance query of the data set @param x first cluster to merge @param y second cluster to merge
[ "Merges", "two", "clusters", "given", "by", "x", "y", "their", "points", "with", "smallest", "IDs", "and", "y", "to", "keep" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L193-L223
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java
MiniMax.updateMatrices
protected static <O> void updateMatrices(int size, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<O> dq, int c) { final DBIDArrayIter ix = mat.ix, iy = mat.iy; // c is the new cluster. // Update entries (at (x,y) with x > y) in the matrix where x = c or y = c // Update entries at (c,y) with y < c ix.seek(c); for(iy.seek(0); iy.getOffset() < c; iy.advance()) { // Skip entry if already merged if(builder.isLinked(iy)) { continue; } updateEntry(mat, prots, clusters, dq, c, iy.getOffset()); } // Update entries at (x,c) with x > c iy.seek(c); for(ix.seek(c + 1); ix.valid(); ix.advance()) { // Skip entry if already merged if(builder.isLinked(ix)) { continue; } updateEntry(mat, prots, clusters, dq, ix.getOffset(), c); } }
java
protected static <O> void updateMatrices(int size, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<O> dq, int c) { final DBIDArrayIter ix = mat.ix, iy = mat.iy; // c is the new cluster. // Update entries (at (x,y) with x > y) in the matrix where x = c or y = c // Update entries at (c,y) with y < c ix.seek(c); for(iy.seek(0); iy.getOffset() < c; iy.advance()) { // Skip entry if already merged if(builder.isLinked(iy)) { continue; } updateEntry(mat, prots, clusters, dq, c, iy.getOffset()); } // Update entries at (x,c) with x > c iy.seek(c); for(ix.seek(c + 1); ix.valid(); ix.advance()) { // Skip entry if already merged if(builder.isLinked(ix)) { continue; } updateEntry(mat, prots, clusters, dq, ix.getOffset(), c); } }
[ "protected", "static", "<", "O", ">", "void", "updateMatrices", "(", "int", "size", ",", "MatrixParadigm", "mat", ",", "DBIDArrayMIter", "prots", ",", "PointerHierarchyRepresentationBuilder", "builder", ",", "Int2ObjectOpenHashMap", "<", "ModifiableDBIDs", ">", "clust...
Update the entries of the matrices that contain a distance to c, the newly merged cluster. @param size number of ids in the data set @param mat matrix paradigm @param prots calculated prototypes @param builder Result builder @param clusters the clusters @param dq distance query of the data set @param c the cluster to update distances to
[ "Update", "the", "entries", "of", "the", "matrices", "that", "contain", "a", "distance", "to", "c", "the", "newly", "merged", "cluster", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L237-L261
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java
MiniMax.updateEntry
protected static void updateEntry(MatrixParadigm mat, DBIDArrayMIter prots, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq, int x, int y) { assert (y < x); final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] distances = mat.matrix; ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y); DBIDVar prototype = DBIDUtil.newVar(ix.seek(x)); // Default prototype double minMaxDist; // Two "real" clusters: if(cx != null && cy != null) { minMaxDist = findPrototype(dq, cx, cy, prototype, Double.POSITIVE_INFINITY); minMaxDist = findPrototype(dq, cy, cx, prototype, minMaxDist); } else if(cx != null) { // cy is singleton. minMaxDist = findPrototypeSingleton(dq, cx, iy.seek(y), prototype); } else if(cy != null) { // cx is singleton. minMaxDist = findPrototypeSingleton(dq, cy, ix.seek(x), prototype); } else { minMaxDist = dq.distance(ix.seek(x), iy.seek(y)); prototype.set(ix); } final int offset = MatrixParadigm.triangleSize(x) + y; distances[offset] = minMaxDist; prots.seek(offset).setDBID(prototype); }
java
protected static void updateEntry(MatrixParadigm mat, DBIDArrayMIter prots, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq, int x, int y) { assert (y < x); final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] distances = mat.matrix; ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y); DBIDVar prototype = DBIDUtil.newVar(ix.seek(x)); // Default prototype double minMaxDist; // Two "real" clusters: if(cx != null && cy != null) { minMaxDist = findPrototype(dq, cx, cy, prototype, Double.POSITIVE_INFINITY); minMaxDist = findPrototype(dq, cy, cx, prototype, minMaxDist); } else if(cx != null) { // cy is singleton. minMaxDist = findPrototypeSingleton(dq, cx, iy.seek(y), prototype); } else if(cy != null) { // cx is singleton. minMaxDist = findPrototypeSingleton(dq, cy, ix.seek(x), prototype); } else { minMaxDist = dq.distance(ix.seek(x), iy.seek(y)); prototype.set(ix); } final int offset = MatrixParadigm.triangleSize(x) + y; distances[offset] = minMaxDist; prots.seek(offset).setDBID(prototype); }
[ "protected", "static", "void", "updateEntry", "(", "MatrixParadigm", "mat", ",", "DBIDArrayMIter", "prots", ",", "Int2ObjectOpenHashMap", "<", "ModifiableDBIDs", ">", "clusters", ",", "DistanceQuery", "<", "?", ">", "dq", ",", "int", "x", ",", "int", "y", ")",...
Update entry at x,y for distance matrix distances @param mat distance matrix @param prots calculated prototypes @param clusters the clusters @param dq distance query on the data set @param x index of cluster, {@code x > y} @param y index of cluster, {@code y < x}
[ "Update", "entry", "at", "x", "y", "for", "distance", "matrix", "distances" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L273-L302
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java
MiniMax.findMax
private static double findMax(DistanceQuery<?> dq, DBIDIter i, DBIDs cy, double maxDist, double minMaxDist) { for(DBIDIter j = cy.iter(); j.valid(); j.advance()) { double dist = dq.distance(i, j); if(dist > maxDist) { // Stop early, if we already know a better candidate. if(dist >= minMaxDist) { return dist; } maxDist = dist; } } return maxDist; }
java
private static double findMax(DistanceQuery<?> dq, DBIDIter i, DBIDs cy, double maxDist, double minMaxDist) { for(DBIDIter j = cy.iter(); j.valid(); j.advance()) { double dist = dq.distance(i, j); if(dist > maxDist) { // Stop early, if we already know a better candidate. if(dist >= minMaxDist) { return dist; } maxDist = dist; } } return maxDist; }
[ "private", "static", "double", "findMax", "(", "DistanceQuery", "<", "?", ">", "dq", ",", "DBIDIter", "i", ",", "DBIDs", "cy", ",", "double", "maxDist", ",", "double", "minMaxDist", ")", "{", "for", "(", "DBIDIter", "j", "=", "cy", ".", "iter", "(", ...
Find the maximum distance of one object to a set. @param dq Distance query @param i Current object @param cy Set of candidates @param maxDist Known maximum to others @param minMaxDist Early stopping threshold @return Maximum distance
[ "Find", "the", "maximum", "distance", "of", "one", "object", "to", "a", "set", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L380-L392
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/SpatialPointLeafEntry.java
SpatialPointLeafEntry.writeExternal
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(DBIDUtil.asInteger(id)); out.writeInt(values.length); for(double v : values) { out.writeDouble(v); } }
java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(DBIDUtil.asInteger(id)); out.writeInt(values.length); for(double v : values) { out.writeDouble(v); } }
[ "@", "Override", "public", "void", "writeExternal", "(", "ObjectOutput", "out", ")", "throws", "IOException", "{", "out", ".", "writeInt", "(", "DBIDUtil", ".", "asInteger", "(", "id", ")", ")", ";", "out", ".", "writeInt", "(", "values", ".", "length", ...
Calls the super method and writes the values of this entry to the specified stream. @param out the stream to write the object to @throws java.io.IOException Includes any I/O exceptions that may occur
[ "Calls", "the", "super", "method", "and", "writes", "the", "values", "of", "this", "entry", "to", "the", "specified", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/SpatialPointLeafEntry.java#L108-L115
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/SpatialPointLeafEntry.java
SpatialPointLeafEntry.readExternal
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { id = DBIDUtil.importInteger(in.read()); values = new double[in.readInt()]; for(int d = 0; d < values.length; d++) { values[d] = in.readDouble(); } }
java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { id = DBIDUtil.importInteger(in.read()); values = new double[in.readInt()]; for(int d = 0; d < values.length; d++) { values[d] = in.readDouble(); } }
[ "@", "Override", "public", "void", "readExternal", "(", "ObjectInput", "in", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "id", "=", "DBIDUtil", ".", "importInteger", "(", "in", ".", "read", "(", ")", ")", ";", "values", "=", "new", "d...
Calls the super method and reads the values of this entry from the specified input stream. @param in the stream to read data from in order to restore the object @throws java.io.IOException if I/O errors occur @throws ClassNotFoundException If the class for an object being restored cannot be found.
[ "Calls", "the", "super", "method", "and", "reads", "the", "values", "of", "this", "entry", "from", "the", "specified", "input", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/SpatialPointLeafEntry.java#L126-L133
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/IndefiniteProgress.java
IndefiniteProgress.appendToBuffer
@Override public StringBuilder appendToBuffer(StringBuilder buf) { buf.append(getTask()); buf.append(": "); buf.append(getProcessed()); return buf; }
java
@Override public StringBuilder appendToBuffer(StringBuilder buf) { buf.append(getTask()); buf.append(": "); buf.append(getProcessed()); return buf; }
[ "@", "Override", "public", "StringBuilder", "appendToBuffer", "(", "StringBuilder", "buf", ")", "{", "buf", ".", "append", "(", "getTask", "(", ")", ")", ";", "buf", ".", "append", "(", "\": \"", ")", ";", "buf", ".", "append", "(", "getProcessed", "(", ...
Serialize 'indefinite' progress.
[ "Serialize", "indefinite", "progress", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/IndefiniteProgress.java#L60-L66
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/typeconversions/SplitNumberVectorFilter.java
SplitNumberVectorFilter.getInputTypeRestriction
private TypeInformation getInputTypeRestriction() { // Find maximum dimension requested int m = dims[0]; for(int i = 1; i < dims.length; i++) { m = Math.max(dims[i], m); } return VectorFieldTypeInformation.typeRequest(NumberVector.class, m, Integer.MAX_VALUE); }
java
private TypeInformation getInputTypeRestriction() { // Find maximum dimension requested int m = dims[0]; for(int i = 1; i < dims.length; i++) { m = Math.max(dims[i], m); } return VectorFieldTypeInformation.typeRequest(NumberVector.class, m, Integer.MAX_VALUE); }
[ "private", "TypeInformation", "getInputTypeRestriction", "(", ")", "{", "// Find maximum dimension requested", "int", "m", "=", "dims", "[", "0", "]", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "dims", ".", "length", ";", "i", "++", ")", "{", ...
The input type we use. @return type information
[ "The", "input", "type", "we", "use", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/typeconversions/SplitNumberVectorFilter.java#L142-L149
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/LSDBC.java
LSDBC.isLocalMaximum
private boolean isLocalMaximum(double kdist, DBIDs neighbors, WritableDoubleDataStore kdists) { for(DBIDIter it = neighbors.iter(); it.valid(); it.advance()) { if(kdists.doubleValue(it) < kdist) { return false; } } return true; }
java
private boolean isLocalMaximum(double kdist, DBIDs neighbors, WritableDoubleDataStore kdists) { for(DBIDIter it = neighbors.iter(); it.valid(); it.advance()) { if(kdists.doubleValue(it) < kdist) { return false; } } return true; }
[ "private", "boolean", "isLocalMaximum", "(", "double", "kdist", ",", "DBIDs", "neighbors", ",", "WritableDoubleDataStore", "kdists", ")", "{", "for", "(", "DBIDIter", "it", "=", "neighbors", ".", "iter", "(", ")", ";", "it", ".", "valid", "(", ")", ";", ...
Test if a point is a local density maximum. @param kdist k-distance of current @param neighbors Neighbor points @param kdists kNN distances @return {@code true} when the point is a local maximum
[ "Test", "if", "a", "point", "is", "a", "local", "density", "maximum", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/LSDBC.java#L222-L229
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/LSDBC.java
LSDBC.expandCluster
protected int expandCluster(final int clusterid, final WritableIntegerDataStore clusterids, final KNNQuery<O> knnq, final DBIDs neighbors, final double maxkdist, final FiniteProgress progress) { int clustersize = 1; // initial seed! final ArrayModifiableDBIDs activeSet = DBIDUtil.newArray(); activeSet.addDBIDs(neighbors); // run expandCluster as long as this set is non-empty (non-recursive // implementation) DBIDVar id = DBIDUtil.newVar(); while(!activeSet.isEmpty()) { activeSet.pop(id); // Assign object to cluster final int oldclus = clusterids.intValue(id); if(oldclus == NOISE) { clustersize += 1; // Non core point cluster member: clusterids.putInt(id, -clusterid); } else if(oldclus == UNPROCESSED) { clustersize += 1; // expandCluster again: // Evaluate Neighborhood predicate final KNNList newneighbors = knnq.getKNNForDBID(id, k); // Evaluate Core-Point predicate if(newneighbors.getKNNDistance() <= maxkdist) { activeSet.addDBIDs(newneighbors); } clusterids.putInt(id, clusterid); LOG.incrementProcessed(progress); } } return clustersize; }
java
protected int expandCluster(final int clusterid, final WritableIntegerDataStore clusterids, final KNNQuery<O> knnq, final DBIDs neighbors, final double maxkdist, final FiniteProgress progress) { int clustersize = 1; // initial seed! final ArrayModifiableDBIDs activeSet = DBIDUtil.newArray(); activeSet.addDBIDs(neighbors); // run expandCluster as long as this set is non-empty (non-recursive // implementation) DBIDVar id = DBIDUtil.newVar(); while(!activeSet.isEmpty()) { activeSet.pop(id); // Assign object to cluster final int oldclus = clusterids.intValue(id); if(oldclus == NOISE) { clustersize += 1; // Non core point cluster member: clusterids.putInt(id, -clusterid); } else if(oldclus == UNPROCESSED) { clustersize += 1; // expandCluster again: // Evaluate Neighborhood predicate final KNNList newneighbors = knnq.getKNNForDBID(id, k); // Evaluate Core-Point predicate if(newneighbors.getKNNDistance() <= maxkdist) { activeSet.addDBIDs(newneighbors); } clusterids.putInt(id, clusterid); LOG.incrementProcessed(progress); } } return clustersize; }
[ "protected", "int", "expandCluster", "(", "final", "int", "clusterid", ",", "final", "WritableIntegerDataStore", "clusterids", ",", "final", "KNNQuery", "<", "O", ">", "knnq", ",", "final", "DBIDs", "neighbors", ",", "final", "double", "maxkdist", ",", "final", ...
Set-based expand cluster implementation. @param clusterid ID of the current cluster. @param clusterids Current object to cluster mapping. @param knnq kNNQuery @param neighbors Neighbors acquired by initial getNeighbors call. @param maxkdist Maximum k-distance @param progress Progress logging @return cluster size
[ "Set", "-", "based", "expand", "cluster", "implementation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/LSDBC.java#L243-L273
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/LSDBC.java
LSDBC.fillDensities
private void fillDensities(KNNQuery<O> knnq, DBIDs ids, WritableDoubleDataStore dens) { FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Densities", ids.size(), LOG) : null; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { final KNNList neighbors = knnq.getKNNForDBID(iter, k); dens.putDouble(iter, neighbors.getKNNDistance()); LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); }
java
private void fillDensities(KNNQuery<O> knnq, DBIDs ids, WritableDoubleDataStore dens) { FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Densities", ids.size(), LOG) : null; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { final KNNList neighbors = knnq.getKNNForDBID(iter, k); dens.putDouble(iter, neighbors.getKNNDistance()); LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); }
[ "private", "void", "fillDensities", "(", "KNNQuery", "<", "O", ">", "knnq", ",", "DBIDs", "ids", ",", "WritableDoubleDataStore", "dens", ")", "{", "FiniteProgress", "prog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "FiniteProgress", "(", "\"Densiti...
Collect all densities into an array for sorting. @param knnq kNN query @param ids DBIDs to process @param dens Density storage
[ "Collect", "all", "densities", "into", "an", "array", "for", "sorting", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/LSDBC.java#L282-L290
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.run
public Clustering<SubspaceModel> run(Relation<? extends NumberVector> relation) { final int dimensionality = RelationUtil.dimensionality(relation); StepProgress step = new StepProgress(2); // 1. Identification of subspaces that contain clusters step.beginStep(1, "Identification of subspaces that contain clusters", LOG); ArrayList<List<CLIQUESubspace>> dimensionToDenseSubspaces = new ArrayList<>(dimensionality); List<CLIQUESubspace> denseSubspaces = findOneDimensionalDenseSubspaces(relation); dimensionToDenseSubspaces.add(denseSubspaces); if(LOG.isVerbose()) { LOG.verbose("1-dimensional dense subspaces: " + denseSubspaces.size()); } if(LOG.isDebugging()) { for(CLIQUESubspace s : denseSubspaces) { LOG.debug(s.toString()); } } for(int k = 2; k <= dimensionality && !denseSubspaces.isEmpty(); k++) { denseSubspaces = findDenseSubspaces(relation, denseSubspaces); assert (dimensionToDenseSubspaces.size() == k - 1); dimensionToDenseSubspaces.add(denseSubspaces); if(LOG.isVerbose()) { LOG.verbose(k + "-dimensional dense subspaces: " + denseSubspaces.size()); } if(LOG.isDebugging()) { for(CLIQUESubspace s : denseSubspaces) { LOG.debug(s.toString()); } } } // 2. Identification of clusters step.beginStep(2, "Identification of clusters", LOG); // build result Clustering<SubspaceModel> result = new Clustering<>("CLIQUE clustering", "clique-clustering"); for(int dim = 0; dim < dimensionToDenseSubspaces.size(); dim++) { List<CLIQUESubspace> subspaces = dimensionToDenseSubspaces.get(dim); List<Pair<Subspace, ModifiableDBIDs>> modelsAndClusters = determineClusters(subspaces); if(LOG.isVerbose()) { LOG.verbose((dim + 1) + "-dimensional clusters: " + modelsAndClusters.size()); } for(Pair<Subspace, ModifiableDBIDs> modelAndCluster : modelsAndClusters) { Cluster<SubspaceModel> newCluster = new Cluster<>(modelAndCluster.second); newCluster.setModel(new SubspaceModel(modelAndCluster.first, Centroid.make(relation, modelAndCluster.second).getArrayRef())); result.addToplevelCluster(newCluster); } } return result; }
java
public Clustering<SubspaceModel> run(Relation<? extends NumberVector> relation) { final int dimensionality = RelationUtil.dimensionality(relation); StepProgress step = new StepProgress(2); // 1. Identification of subspaces that contain clusters step.beginStep(1, "Identification of subspaces that contain clusters", LOG); ArrayList<List<CLIQUESubspace>> dimensionToDenseSubspaces = new ArrayList<>(dimensionality); List<CLIQUESubspace> denseSubspaces = findOneDimensionalDenseSubspaces(relation); dimensionToDenseSubspaces.add(denseSubspaces); if(LOG.isVerbose()) { LOG.verbose("1-dimensional dense subspaces: " + denseSubspaces.size()); } if(LOG.isDebugging()) { for(CLIQUESubspace s : denseSubspaces) { LOG.debug(s.toString()); } } for(int k = 2; k <= dimensionality && !denseSubspaces.isEmpty(); k++) { denseSubspaces = findDenseSubspaces(relation, denseSubspaces); assert (dimensionToDenseSubspaces.size() == k - 1); dimensionToDenseSubspaces.add(denseSubspaces); if(LOG.isVerbose()) { LOG.verbose(k + "-dimensional dense subspaces: " + denseSubspaces.size()); } if(LOG.isDebugging()) { for(CLIQUESubspace s : denseSubspaces) { LOG.debug(s.toString()); } } } // 2. Identification of clusters step.beginStep(2, "Identification of clusters", LOG); // build result Clustering<SubspaceModel> result = new Clustering<>("CLIQUE clustering", "clique-clustering"); for(int dim = 0; dim < dimensionToDenseSubspaces.size(); dim++) { List<CLIQUESubspace> subspaces = dimensionToDenseSubspaces.get(dim); List<Pair<Subspace, ModifiableDBIDs>> modelsAndClusters = determineClusters(subspaces); if(LOG.isVerbose()) { LOG.verbose((dim + 1) + "-dimensional clusters: " + modelsAndClusters.size()); } for(Pair<Subspace, ModifiableDBIDs> modelAndCluster : modelsAndClusters) { Cluster<SubspaceModel> newCluster = new Cluster<>(modelAndCluster.second); newCluster.setModel(new SubspaceModel(modelAndCluster.first, Centroid.make(relation, modelAndCluster.second).getArrayRef())); result.addToplevelCluster(newCluster); } } return result; }
[ "public", "Clustering", "<", "SubspaceModel", ">", "run", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "relation", ")", "{", "final", "int", "dimensionality", "=", "RelationUtil", ".", "dimensionality", "(", "relation", ")", ";", "StepProgress", ...
Performs the CLIQUE algorithm on the given database. @param relation Data relation to process @return Clustering result
[ "Performs", "the", "CLIQUE", "algorithm", "on", "the", "given", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L134-L186
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.determineClusters
private List<Pair<Subspace, ModifiableDBIDs>> determineClusters(List<CLIQUESubspace> denseSubspaces) { List<Pair<Subspace, ModifiableDBIDs>> clusters = new ArrayList<>(); for(CLIQUESubspace subspace : denseSubspaces) { List<Pair<Subspace, ModifiableDBIDs>> clustersInSubspace = subspace.determineClusters(); if(LOG.isDebugging()) { LOG.debugFine("Subspace " + subspace + " clusters " + clustersInSubspace.size()); } clusters.addAll(clustersInSubspace); } return clusters; }
java
private List<Pair<Subspace, ModifiableDBIDs>> determineClusters(List<CLIQUESubspace> denseSubspaces) { List<Pair<Subspace, ModifiableDBIDs>> clusters = new ArrayList<>(); for(CLIQUESubspace subspace : denseSubspaces) { List<Pair<Subspace, ModifiableDBIDs>> clustersInSubspace = subspace.determineClusters(); if(LOG.isDebugging()) { LOG.debugFine("Subspace " + subspace + " clusters " + clustersInSubspace.size()); } clusters.addAll(clustersInSubspace); } return clusters; }
[ "private", "List", "<", "Pair", "<", "Subspace", ",", "ModifiableDBIDs", ">", ">", "determineClusters", "(", "List", "<", "CLIQUESubspace", ">", "denseSubspaces", ")", "{", "List", "<", "Pair", "<", "Subspace", ",", "ModifiableDBIDs", ">", ">", "clusters", "...
Determines the clusters in the specified dense subspaces. @param denseSubspaces the dense subspaces in reverse order by their coverage @return the clusters in the specified dense subspaces and the corresponding cluster models
[ "Determines", "the", "clusters", "in", "the", "specified", "dense", "subspaces", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L196-L207
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.findOneDimensionalDenseSubspaces
private List<CLIQUESubspace> findOneDimensionalDenseSubspaces(Relation<? extends NumberVector> database) { List<CLIQUESubspace> denseSubspaceCandidates = findOneDimensionalDenseSubspaceCandidates(database); return prune ? pruneDenseSubspaces(denseSubspaceCandidates) : denseSubspaceCandidates; }
java
private List<CLIQUESubspace> findOneDimensionalDenseSubspaces(Relation<? extends NumberVector> database) { List<CLIQUESubspace> denseSubspaceCandidates = findOneDimensionalDenseSubspaceCandidates(database); return prune ? pruneDenseSubspaces(denseSubspaceCandidates) : denseSubspaceCandidates; }
[ "private", "List", "<", "CLIQUESubspace", ">", "findOneDimensionalDenseSubspaces", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "database", ")", "{", "List", "<", "CLIQUESubspace", ">", "denseSubspaceCandidates", "=", "findOneDimensionalDenseSubspaceCandidat...
Determines the one dimensional dense subspaces and performs a pruning if this option is chosen. @param database the database to run the algorithm on @return the one dimensional dense subspaces reverse ordered by their coverage
[ "Determines", "the", "one", "dimensional", "dense", "subspaces", "and", "performs", "a", "pruning", "if", "this", "option", "is", "chosen", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L217-L220
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.updateMinMax
private void updateMinMax(NumberVector featureVector, double[] minima, double[] maxima) { assert (minima.length == featureVector.getDimensionality()); for(int d = 0; d < featureVector.getDimensionality(); d++) { double v = featureVector.doubleValue(d); if(v == v) { // Avoid NaN. maxima[d] = MathUtil.max(v, maxima[d]); minima[d] = MathUtil.min(v, minima[d]); } } }
java
private void updateMinMax(NumberVector featureVector, double[] minima, double[] maxima) { assert (minima.length == featureVector.getDimensionality()); for(int d = 0; d < featureVector.getDimensionality(); d++) { double v = featureVector.doubleValue(d); if(v == v) { // Avoid NaN. maxima[d] = MathUtil.max(v, maxima[d]); minima[d] = MathUtil.min(v, minima[d]); } } }
[ "private", "void", "updateMinMax", "(", "NumberVector", "featureVector", ",", "double", "[", "]", "minima", ",", "double", "[", "]", "maxima", ")", "{", "assert", "(", "minima", ".", "length", "==", "featureVector", ".", "getDimensionality", "(", ")", ")", ...
Updates the minima and maxima array according to the specified feature vector. @param featureVector the feature vector @param minima the array of minima @param maxima the array of maxima
[ "Updates", "the", "minima", "and", "maxima", "array", "according", "to", "the", "specified", "feature", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L304-L313
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.findOneDimensionalDenseSubspaceCandidates
private List<CLIQUESubspace> findOneDimensionalDenseSubspaceCandidates(Relation<? extends NumberVector> database) { Collection<CLIQUEUnit> units = initOneDimensionalUnits(database); // identify dense units double total = database.size(); for(DBIDIter it = database.iterDBIDs(); it.valid(); it.advance()) { NumberVector featureVector = database.get(it); // FIXME: rather than repeatedly testing, use a clever data structure? for(CLIQUEUnit unit : units) { unit.addFeatureVector(it, featureVector); } } int dimensionality = RelationUtil.dimensionality(database); Collection<CLIQUEUnit> denseUnits = new ArrayList<>(); CLIQUESubspace[] denseSubspaces = new CLIQUESubspace[dimensionality]; for(CLIQUEUnit unit : units) { // unit is a dense unit if(unit.selectivity(total) >= tau) { denseUnits.add(unit); // add the one-dimensional dense unit to its subspace int dim = unit.getDimension(0); CLIQUESubspace subspace_d = denseSubspaces[dim]; if(subspace_d == null) { denseSubspaces[dim] = subspace_d = new CLIQUESubspace(dim); } subspace_d.addDenseUnit(unit); } } // Omit null values where no dense unit was found: List<CLIQUESubspace> subspaceCandidates = new ArrayList<>(dimensionality); for(CLIQUESubspace s : denseSubspaces) { if(s != null) { subspaceCandidates.add(s); } } Collections.sort(subspaceCandidates, CLIQUESubspace.BY_COVERAGE); if(LOG.isDebugging()) { LOG.debugFine(new StringBuilder().append(" number of 1-dim dense units: ").append(denseUnits.size()) // .append("\n number of 1-dim dense subspace candidates: ").append(subspaceCandidates.size()).toString()); } return subspaceCandidates; }
java
private List<CLIQUESubspace> findOneDimensionalDenseSubspaceCandidates(Relation<? extends NumberVector> database) { Collection<CLIQUEUnit> units = initOneDimensionalUnits(database); // identify dense units double total = database.size(); for(DBIDIter it = database.iterDBIDs(); it.valid(); it.advance()) { NumberVector featureVector = database.get(it); // FIXME: rather than repeatedly testing, use a clever data structure? for(CLIQUEUnit unit : units) { unit.addFeatureVector(it, featureVector); } } int dimensionality = RelationUtil.dimensionality(database); Collection<CLIQUEUnit> denseUnits = new ArrayList<>(); CLIQUESubspace[] denseSubspaces = new CLIQUESubspace[dimensionality]; for(CLIQUEUnit unit : units) { // unit is a dense unit if(unit.selectivity(total) >= tau) { denseUnits.add(unit); // add the one-dimensional dense unit to its subspace int dim = unit.getDimension(0); CLIQUESubspace subspace_d = denseSubspaces[dim]; if(subspace_d == null) { denseSubspaces[dim] = subspace_d = new CLIQUESubspace(dim); } subspace_d.addDenseUnit(unit); } } // Omit null values where no dense unit was found: List<CLIQUESubspace> subspaceCandidates = new ArrayList<>(dimensionality); for(CLIQUESubspace s : denseSubspaces) { if(s != null) { subspaceCandidates.add(s); } } Collections.sort(subspaceCandidates, CLIQUESubspace.BY_COVERAGE); if(LOG.isDebugging()) { LOG.debugFine(new StringBuilder().append(" number of 1-dim dense units: ").append(denseUnits.size()) // .append("\n number of 1-dim dense subspace candidates: ").append(subspaceCandidates.size()).toString()); } return subspaceCandidates; }
[ "private", "List", "<", "CLIQUESubspace", ">", "findOneDimensionalDenseSubspaceCandidates", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "database", ")", "{", "Collection", "<", "CLIQUEUnit", ">", "units", "=", "initOneDimensionalUnits", "(", "database",...
Determines the one-dimensional dense subspace candidates by making a pass over the database. @param database the database to run the algorithm on @return the one-dimensional dense subspace candidates reverse ordered by their coverage
[ "Determines", "the", "one", "-", "dimensional", "dense", "subspace", "candidates", "by", "making", "a", "pass", "over", "the", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L323-L365
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.pruneDenseSubspaces
private List<CLIQUESubspace> pruneDenseSubspaces(List<CLIQUESubspace> denseSubspaces) { int[][] means = computeMeans(denseSubspaces); double[][] diffs = computeDiffs(denseSubspaces, means[0], means[1]); double[] codeLength = new double[denseSubspaces.size()]; double minCL = Double.MAX_VALUE; int min_i = -1; for(int i = 0; i < denseSubspaces.size(); i++) { int mi = means[0][i], mp = means[1][i]; double cl = codeLength[i] = log2OrZero(mi) + diffs[0][i] + log2OrZero(mp) + diffs[1][i]; if(cl <= minCL) { minCL = cl; min_i = i; } } return denseSubspaces.subList(0, min_i + 1); }
java
private List<CLIQUESubspace> pruneDenseSubspaces(List<CLIQUESubspace> denseSubspaces) { int[][] means = computeMeans(denseSubspaces); double[][] diffs = computeDiffs(denseSubspaces, means[0], means[1]); double[] codeLength = new double[denseSubspaces.size()]; double minCL = Double.MAX_VALUE; int min_i = -1; for(int i = 0; i < denseSubspaces.size(); i++) { int mi = means[0][i], mp = means[1][i]; double cl = codeLength[i] = log2OrZero(mi) + diffs[0][i] + log2OrZero(mp) + diffs[1][i]; if(cl <= minCL) { minCL = cl; min_i = i; } } return denseSubspaces.subList(0, min_i + 1); }
[ "private", "List", "<", "CLIQUESubspace", ">", "pruneDenseSubspaces", "(", "List", "<", "CLIQUESubspace", ">", "denseSubspaces", ")", "{", "int", "[", "]", "[", "]", "means", "=", "computeMeans", "(", "denseSubspaces", ")", ";", "double", "[", "]", "[", "]...
Performs a MDL-based pruning of the specified dense subspaces as described in the CLIQUE algorithm. @param denseSubspaces the subspaces to be pruned sorted in reverse order by their coverage @return the subspaces which are not pruned reverse ordered by their coverage
[ "Performs", "a", "MDL", "-", "based", "pruning", "of", "the", "specified", "dense", "subspaces", "as", "described", "in", "the", "CLIQUE", "algorithm", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L409-L427
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.computeMeans
private int[][] computeMeans(List<CLIQUESubspace> denseSubspaces) { int n = denseSubspaces.size() - 1; int[] mi = new int[n + 1], mp = new int[n + 1]; double resultMI = 0, resultMP = 0; for(int i = 0; i < denseSubspaces.size(); i++) { resultMI += denseSubspaces.get(i).getCoverage(); resultMP += denseSubspaces.get(n - i).getCoverage(); mi[i] = (int) FastMath.ceil(resultMI / (i + 1)); if(i != n) { mp[n - 1 - i] = (int) FastMath.ceil(resultMP / (i + 1)); } } return new int[][] { mi, mp }; }
java
private int[][] computeMeans(List<CLIQUESubspace> denseSubspaces) { int n = denseSubspaces.size() - 1; int[] mi = new int[n + 1], mp = new int[n + 1]; double resultMI = 0, resultMP = 0; for(int i = 0; i < denseSubspaces.size(); i++) { resultMI += denseSubspaces.get(i).getCoverage(); resultMP += denseSubspaces.get(n - i).getCoverage(); mi[i] = (int) FastMath.ceil(resultMI / (i + 1)); if(i != n) { mp[n - 1 - i] = (int) FastMath.ceil(resultMP / (i + 1)); } } return new int[][] { mi, mp }; }
[ "private", "int", "[", "]", "[", "]", "computeMeans", "(", "List", "<", "CLIQUESubspace", ">", "denseSubspaces", ")", "{", "int", "n", "=", "denseSubspaces", ".", "size", "(", ")", "-", "1", ";", "int", "[", "]", "mi", "=", "new", "int", "[", "n", ...
The specified sorted list of dense subspaces is divided into the selected set I and the pruned set P. For each set the mean of the cover fractions is computed. @param denseSubspaces the dense subspaces in reverse order by their coverage @return the mean of the cover fractions, the first value is the mean of the selected set I, the second value is the mean of the pruned set P.
[ "The", "specified", "sorted", "list", "of", "dense", "subspaces", "is", "divided", "into", "the", "selected", "set", "I", "and", "the", "pruned", "set", "P", ".", "For", "each", "set", "the", "mean", "of", "the", "cover", "fractions", "is", "computed", "...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L439-L455
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java
CLIQUE.computeDiffs
private double[][] computeDiffs(List<CLIQUESubspace> denseSubspaces, int[] mi, int[] mp) { int n = denseSubspaces.size() - 1; double[] diff_mi = new double[n + 1], diff_mp = new double[n + 1]; double resultMI = 0, resultMP = 0; for(int i = 0; i < denseSubspaces.size(); i++) { double diffMI = Math.abs(denseSubspaces.get(i).getCoverage() - mi[i]); resultMI += log2OrZero(diffMI); double diffMP = (i != n) ? Math.abs(denseSubspaces.get(n - i).getCoverage() - mp[n - 1 - i]) : 0; resultMP += log2OrZero(diffMP); diff_mi[i] = resultMI; if(i != n) { diff_mp[n - 1 - i] = resultMP; } } return new double[][] { diff_mi, diff_mp }; }
java
private double[][] computeDiffs(List<CLIQUESubspace> denseSubspaces, int[] mi, int[] mp) { int n = denseSubspaces.size() - 1; double[] diff_mi = new double[n + 1], diff_mp = new double[n + 1]; double resultMI = 0, resultMP = 0; for(int i = 0; i < denseSubspaces.size(); i++) { double diffMI = Math.abs(denseSubspaces.get(i).getCoverage() - mi[i]); resultMI += log2OrZero(diffMI); double diffMP = (i != n) ? Math.abs(denseSubspaces.get(n - i).getCoverage() - mp[n - 1 - i]) : 0; resultMP += log2OrZero(diffMP); diff_mi[i] = resultMI; if(i != n) { diff_mp[n - 1 - i] = resultMP; } } return new double[][] { diff_mi, diff_mp }; }
[ "private", "double", "[", "]", "[", "]", "computeDiffs", "(", "List", "<", "CLIQUESubspace", ">", "denseSubspaces", ",", "int", "[", "]", "mi", ",", "int", "[", "]", "mp", ")", "{", "int", "n", "=", "denseSubspaces", ".", "size", "(", ")", "-", "1"...
The specified sorted list of dense subspaces is divided into the selected set I and the pruned set P. For each set the difference from the specified mean values is computed. @param denseSubspaces denseSubspaces the dense subspaces in reverse order by their coverage @param mi the mean of the selected sets I @param mp the mean of the pruned sets P @return the difference from the specified mean values, the first value is the difference from the mean of the selected set I, the second value is the difference from the mean of the pruned set P.
[ "The", "specified", "sorted", "list", "of", "dense", "subspaces", "is", "divided", "into", "the", "selected", "set", "I", "and", "the", "pruned", "set", "P", ".", "For", "each", "set", "the", "difference", "from", "the", "specified", "mean", "values", "is"...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/CLIQUE.java#L470-L487
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/SingleObjectBundle.java
SingleObjectBundle.append
public void append(SimpleTypeInformation<?> meta, Object data) { this.meta.add(meta); this.contents.add(data); }
java
public void append(SimpleTypeInformation<?> meta, Object data) { this.meta.add(meta); this.contents.add(data); }
[ "public", "void", "append", "(", "SimpleTypeInformation", "<", "?", ">", "meta", ",", "Object", "data", ")", "{", "this", ".", "meta", ".", "add", "(", "meta", ")", ";", "this", ".", "contents", ".", "add", "(", "data", ")", ";", "}" ]
Append a single representation to the object. @param meta Meta for the representation @param data Data to append
[ "Append", "a", "single", "representation", "to", "the", "object", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/SingleObjectBundle.java#L143-L146
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/BitVector.java
BitVector.contains
public boolean contains(long[] bitset) { for(int i = 0; i < bitset.length; i++) { final long b = bitset[i]; if(i >= bits.length && b != 0L) { return false; } if((b & bits[i]) != b) { return false; } } return true; }
java
public boolean contains(long[] bitset) { for(int i = 0; i < bitset.length; i++) { final long b = bitset[i]; if(i >= bits.length && b != 0L) { return false; } if((b & bits[i]) != b) { return false; } } return true; }
[ "public", "boolean", "contains", "(", "long", "[", "]", "bitset", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bitset", ".", "length", ";", "i", "++", ")", "{", "final", "long", "b", "=", "bitset", "[", "i", "]", ";", "if", "("...
Returns whether this BitVector contains all bits that are set to true in the specified BitSet. @param bitset the bits to inspect in this BitVector @return true if this BitVector contains all bits that are set to true in the specified BitSet, false otherwise
[ "Returns", "whether", "this", "BitVector", "contains", "all", "bits", "that", "are", "set", "to", "true", "in", "the", "specified", "BitSet", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/BitVector.java#L177-L188
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/BitVector.java
BitVector.jaccardSimilarity
public double jaccardSimilarity(BitVector v2) { return BitsUtil.intersectionSize(bits, v2.bits) / (double) BitsUtil.unionSize(bits, v2.bits); }
java
public double jaccardSimilarity(BitVector v2) { return BitsUtil.intersectionSize(bits, v2.bits) / (double) BitsUtil.unionSize(bits, v2.bits); }
[ "public", "double", "jaccardSimilarity", "(", "BitVector", "v2", ")", "{", "return", "BitsUtil", ".", "intersectionSize", "(", "bits", ",", "v2", ".", "bits", ")", "/", "(", "double", ")", "BitsUtil", ".", "unionSize", "(", "bits", ",", "v2", ".", "bits"...
Compute the Jaccard similarity of two bit vectors. @param v2 Second bit vector @return Jaccard similarity (intersection / union)
[ "Compute", "the", "Jaccard", "similarity", "of", "two", "bit", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/BitVector.java#L214-L216
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeShort
public static int writeShort(byte[] array, int offset, int v) { array[offset + 0] = (byte) (v >>> 8); array[offset + 1] = (byte) (v >>> 0); return SIZE_SHORT; }
java
public static int writeShort(byte[] array, int offset, int v) { array[offset + 0] = (byte) (v >>> 8); array[offset + 1] = (byte) (v >>> 0); return SIZE_SHORT; }
[ "public", "static", "int", "writeShort", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "int", "v", ")", "{", "array", "[", "offset", "+", "0", "]", "=", "(", "byte", ")", "(", "v", ">>>", "8", ")", ";", "array", "[", "offset", "+",...
Write a short to the byte array at the given offset. @param array Array to write to @param offset Offset to write to @param v data @return number of bytes written
[ "Write", "a", "short", "to", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L106-L110
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeInt
public static int writeInt(byte[] array, int offset, int v) { array[offset + 0] = (byte) (v >>> 24); array[offset + 1] = (byte) (v >>> 16); array[offset + 2] = (byte) (v >>> 8); array[offset + 3] = (byte) (v >>> 0); return SIZE_INT; }
java
public static int writeInt(byte[] array, int offset, int v) { array[offset + 0] = (byte) (v >>> 24); array[offset + 1] = (byte) (v >>> 16); array[offset + 2] = (byte) (v >>> 8); array[offset + 3] = (byte) (v >>> 0); return SIZE_INT; }
[ "public", "static", "int", "writeInt", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "int", "v", ")", "{", "array", "[", "offset", "+", "0", "]", "=", "(", "byte", ")", "(", "v", ">>>", "24", ")", ";", "array", "[", "offset", "+", ...
Write an integer to the byte array at the given offset. @param array Array to write to @param offset Offset to write to @param v data @return number of bytes written
[ "Write", "an", "integer", "to", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L120-L126
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeLong
public static int writeLong(byte[] array, int offset, long v) { array[offset + 0] = (byte) (v >>> 56); array[offset + 1] = (byte) (v >>> 48); array[offset + 2] = (byte) (v >>> 40); array[offset + 3] = (byte) (v >>> 32); array[offset + 4] = (byte) (v >>> 24); array[offset + 5] = (byte) (v >>> 16); array[offset + 6] = (byte) (v >>> 8); array[offset + 7] = (byte) (v >>> 0); return SIZE_LONG; }
java
public static int writeLong(byte[] array, int offset, long v) { array[offset + 0] = (byte) (v >>> 56); array[offset + 1] = (byte) (v >>> 48); array[offset + 2] = (byte) (v >>> 40); array[offset + 3] = (byte) (v >>> 32); array[offset + 4] = (byte) (v >>> 24); array[offset + 5] = (byte) (v >>> 16); array[offset + 6] = (byte) (v >>> 8); array[offset + 7] = (byte) (v >>> 0); return SIZE_LONG; }
[ "public", "static", "int", "writeLong", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "long", "v", ")", "{", "array", "[", "offset", "+", "0", "]", "=", "(", "byte", ")", "(", "v", ">>>", "56", ")", ";", "array", "[", "offset", "+"...
Write a long to the byte array at the given offset. @param array Array to write to @param offset Offset to write to @param v data @return number of bytes written
[ "Write", "a", "long", "to", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L136-L146
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeFloat
public static int writeFloat(byte[] array, int offset, float v) { return writeInt(array, offset, Float.floatToIntBits(v)); }
java
public static int writeFloat(byte[] array, int offset, float v) { return writeInt(array, offset, Float.floatToIntBits(v)); }
[ "public", "static", "int", "writeFloat", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "float", "v", ")", "{", "return", "writeInt", "(", "array", ",", "offset", ",", "Float", ".", "floatToIntBits", "(", "v", ")", ")", ";", "}" ]
Write a float to the byte array at the given offset. @param array Array to write to @param offset Offset to write to @param v data @return number of bytes written
[ "Write", "a", "float", "to", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L156-L158
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeDouble
public static int writeDouble(byte[] array, int offset, double v) { return writeLong(array, offset, Double.doubleToLongBits(v)); }
java
public static int writeDouble(byte[] array, int offset, double v) { return writeLong(array, offset, Double.doubleToLongBits(v)); }
[ "public", "static", "int", "writeDouble", "(", "byte", "[", "]", "array", ",", "int", "offset", ",", "double", "v", ")", "{", "return", "writeLong", "(", "array", ",", "offset", ",", "Double", ".", "doubleToLongBits", "(", "v", ")", ")", ";", "}" ]
Write a double to the byte array at the given offset. @param array Array to write to @param offset Offset to write to @param v data @return number of bytes written
[ "Write", "a", "double", "to", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L168-L170
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.readShort
public static short readShort(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. int b0 = array[offset + 0] & 0xFF; int b1 = array[offset + 1] & 0xFF; return (short) ((b0 << 8) + (b1 << 0)); }
java
public static short readShort(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. int b0 = array[offset + 0] & 0xFF; int b1 = array[offset + 1] & 0xFF; return (short) ((b0 << 8) + (b1 << 0)); }
[ "public", "static", "short", "readShort", "(", "byte", "[", "]", "array", ",", "int", "offset", ")", "{", "// First make integers to resolve signed vs. unsigned issues.", "int", "b0", "=", "array", "[", "offset", "+", "0", "]", "&", "0xFF", ";", "int", "b1", ...
Read a short from the byte array at the given offset. @param array Array to read from @param offset Offset to read at @return (signed) short
[ "Read", "a", "short", "from", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L179-L184
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.readUnsignedShort
public static int readUnsignedShort(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. int b0 = array[offset + 0] & 0xFF; int b1 = array[offset + 1] & 0xFF; return ((b0 << 8) + (b1 << 0)); }
java
public static int readUnsignedShort(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. int b0 = array[offset + 0] & 0xFF; int b1 = array[offset + 1] & 0xFF; return ((b0 << 8) + (b1 << 0)); }
[ "public", "static", "int", "readUnsignedShort", "(", "byte", "[", "]", "array", ",", "int", "offset", ")", "{", "// First make integers to resolve signed vs. unsigned issues.", "int", "b0", "=", "array", "[", "offset", "+", "0", "]", "&", "0xFF", ";", "int", "...
Read an unsigned short from the byte array at the given offset. @param array Array to read from @param offset Offset to read at @return short
[ "Read", "an", "unsigned", "short", "from", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L193-L198
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.readInt
public static int readInt(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. int b0 = array[offset + 0] & 0xFF; int b1 = array[offset + 1] & 0xFF; int b2 = array[offset + 2] & 0xFF; int b3 = array[offset + 3] & 0xFF; return ((b0 << 24) + (b1 << 16) + (b2 << 8) + (b3 << 0)); }
java
public static int readInt(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. int b0 = array[offset + 0] & 0xFF; int b1 = array[offset + 1] & 0xFF; int b2 = array[offset + 2] & 0xFF; int b3 = array[offset + 3] & 0xFF; return ((b0 << 24) + (b1 << 16) + (b2 << 8) + (b3 << 0)); }
[ "public", "static", "int", "readInt", "(", "byte", "[", "]", "array", ",", "int", "offset", ")", "{", "// First make integers to resolve signed vs. unsigned issues.", "int", "b0", "=", "array", "[", "offset", "+", "0", "]", "&", "0xFF", ";", "int", "b1", "="...
Read an integer from the byte array at the given offset. @param array Array to read from @param offset Offset to read at @return data
[ "Read", "an", "integer", "from", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L207-L214
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.readLong
public static long readLong(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. long b0 = array[offset + 0]; long b1 = array[offset + 1] & 0xFF; long b2 = array[offset + 2] & 0xFF; long b3 = array[offset + 3] & 0xFF; long b4 = array[offset + 4] & 0xFF; int b5 = array[offset + 5] & 0xFF; int b6 = array[offset + 6] & 0xFF; int b7 = array[offset + 7] & 0xFF; return ((b0 << 56) + (b1 << 48) + (b2 << 40) + (b3 << 32) + (b4 << 24) + (b5 << 16) + (b6 << 8) + (b7 << 0)); }
java
public static long readLong(byte[] array, int offset) { // First make integers to resolve signed vs. unsigned issues. long b0 = array[offset + 0]; long b1 = array[offset + 1] & 0xFF; long b2 = array[offset + 2] & 0xFF; long b3 = array[offset + 3] & 0xFF; long b4 = array[offset + 4] & 0xFF; int b5 = array[offset + 5] & 0xFF; int b6 = array[offset + 6] & 0xFF; int b7 = array[offset + 7] & 0xFF; return ((b0 << 56) + (b1 << 48) + (b2 << 40) + (b3 << 32) + (b4 << 24) + (b5 << 16) + (b6 << 8) + (b7 << 0)); }
[ "public", "static", "long", "readLong", "(", "byte", "[", "]", "array", ",", "int", "offset", ")", "{", "// First make integers to resolve signed vs. unsigned issues.", "long", "b0", "=", "array", "[", "offset", "+", "0", "]", ";", "long", "b1", "=", "array", ...
Read a long from the byte array at the given offset. @param array Array to read from @param offset Offset to read at @return data
[ "Read", "a", "long", "from", "the", "byte", "array", "at", "the", "given", "offset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L223-L234
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeUnsignedVarint
public static void writeUnsignedVarint(ByteBuffer buffer, int val) { // Extra bytes have the high bit set while((val & 0x7F) != val) { buffer.put((byte) ((val & 0x7F) | 0x80)); val >>>= 7; } // Last byte doesn't have high bit set buffer.put((byte) (val & 0x7F)); }
java
public static void writeUnsignedVarint(ByteBuffer buffer, int val) { // Extra bytes have the high bit set while((val & 0x7F) != val) { buffer.put((byte) ((val & 0x7F) | 0x80)); val >>>= 7; } // Last byte doesn't have high bit set buffer.put((byte) (val & 0x7F)); }
[ "public", "static", "void", "writeUnsignedVarint", "(", "ByteBuffer", "buffer", ",", "int", "val", ")", "{", "// Extra bytes have the high bit set", "while", "(", "(", "val", "&", "0x7F", ")", "!=", "val", ")", "{", "buffer", ".", "put", "(", "(", "byte", ...
Write an unsigned integer using a variable-length encoding. Data is always written in 7-bit little-endian, where the 8th bit is the continuation flag. @param buffer Buffer to write to @param val number to write
[ "Write", "an", "unsigned", "integer", "using", "a", "variable", "-", "length", "encoding", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L647-L655
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeUnsignedVarintLong
public static void writeUnsignedVarintLong(ByteBuffer buffer, long val) { // Extra bytes have the high bit set while((val & 0x7F) != val) { buffer.put((byte) ((val & 0x7F) | 0x80)); val >>>= 7; } // Last byte doesn't have high bit set buffer.put((byte) (val & 0x7F)); }
java
public static void writeUnsignedVarintLong(ByteBuffer buffer, long val) { // Extra bytes have the high bit set while((val & 0x7F) != val) { buffer.put((byte) ((val & 0x7F) | 0x80)); val >>>= 7; } // Last byte doesn't have high bit set buffer.put((byte) (val & 0x7F)); }
[ "public", "static", "void", "writeUnsignedVarintLong", "(", "ByteBuffer", "buffer", ",", "long", "val", ")", "{", "// Extra bytes have the high bit set", "while", "(", "(", "val", "&", "0x7F", ")", "!=", "val", ")", "{", "buffer", ".", "put", "(", "(", "byte...
Write an unsigned long using a variable-length encoding. Data is always written in 7-bit little-endian, where the 8th bit is the continuation flag. Note that for integers, this will result in the same encoding as {@link #writeUnsignedVarint} @param buffer Buffer to write to @param val number to write
[ "Write", "an", "unsigned", "long", "using", "a", "variable", "-", "length", "encoding", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L669-L677
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.writeString
public static void writeString(ByteBuffer buffer, String s) throws IOException { if(s == null) { s = ""; // Which will be written as Varint 0 = single byte 0. } ByteArrayUtil.STRING_SERIALIZER.toByteBuffer(buffer, s); }
java
public static void writeString(ByteBuffer buffer, String s) throws IOException { if(s == null) { s = ""; // Which will be written as Varint 0 = single byte 0. } ByteArrayUtil.STRING_SERIALIZER.toByteBuffer(buffer, s); }
[ "public", "static", "void", "writeString", "(", "ByteBuffer", "buffer", ",", "String", "s", ")", "throws", "IOException", "{", "if", "(", "s", "==", "null", ")", "{", "s", "=", "\"\"", ";", "// Which will be written as Varint 0 = single byte 0.", "}", "ByteArray...
Write a string to the buffer. See {@link StringSerializer} for details. @param buffer Buffer to write to @param s String to write
[ "Write", "a", "string", "to", "the", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L687-L692
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.readUnsignedVarint
public static int readUnsignedVarint(ByteBuffer buffer) throws IOException { int val = 0; int bits = 0; while(true) { final int data = buffer.get(); val |= (data & 0x7F) << bits; if((data & 0x80) == 0) { return val; } bits += 7; if(bits > 35) { throw new IOException("Variable length quantity is too long for expected integer."); } } }
java
public static int readUnsignedVarint(ByteBuffer buffer) throws IOException { int val = 0; int bits = 0; while(true) { final int data = buffer.get(); val |= (data & 0x7F) << bits; if((data & 0x80) == 0) { return val; } bits += 7; if(bits > 35) { throw new IOException("Variable length quantity is too long for expected integer."); } } }
[ "public", "static", "int", "readUnsignedVarint", "(", "ByteBuffer", "buffer", ")", "throws", "IOException", "{", "int", "val", "=", "0", ";", "int", "bits", "=", "0", ";", "while", "(", "true", ")", "{", "final", "int", "data", "=", "buffer", ".", "get...
Read an unsigned integer. @param buffer Buffer to read from @return Integer value
[ "Read", "an", "unsigned", "integer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L775-L789
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java
ByteArrayUtil.unmapByteBuffer
public static void unmapByteBuffer(final MappedByteBuffer map) { if(map == null) { return; } map.force(); try { if(Runtime.class.getDeclaredMethod("version") != null) return; // At later Java, the hack below will not work anymore. } catch(NoSuchMethodException e) { // This is an ugly hack, but all that Java <8 offers to help freeing // memory allocated using such buffers. // See also: http://bugs.sun.com/view_bug.do?bug_id=4724038 AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { try { Method getCleanerMethod = map.getClass().getMethod("cleaner", new Class[0]); if(getCleanerMethod == null) { return null; } getCleanerMethod.setAccessible(true); Object cleaner = getCleanerMethod.invoke(map, new Object[0]); Method cleanMethod = cleaner.getClass().getMethod("clean"); if(cleanMethod == null) { return null; } cleanMethod.invoke(cleaner); } catch(Exception e) { LoggingUtil.exception(e); } return null; } }); } catch(SecurityException e1) { // Ignore. } }
java
public static void unmapByteBuffer(final MappedByteBuffer map) { if(map == null) { return; } map.force(); try { if(Runtime.class.getDeclaredMethod("version") != null) return; // At later Java, the hack below will not work anymore. } catch(NoSuchMethodException e) { // This is an ugly hack, but all that Java <8 offers to help freeing // memory allocated using such buffers. // See also: http://bugs.sun.com/view_bug.do?bug_id=4724038 AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { try { Method getCleanerMethod = map.getClass().getMethod("cleaner", new Class[0]); if(getCleanerMethod == null) { return null; } getCleanerMethod.setAccessible(true); Object cleaner = getCleanerMethod.invoke(map, new Object[0]); Method cleanMethod = cleaner.getClass().getMethod("clean"); if(cleanMethod == null) { return null; } cleanMethod.invoke(cleaner); } catch(Exception e) { LoggingUtil.exception(e); } return null; } }); } catch(SecurityException e1) { // Ignore. } }
[ "public", "static", "void", "unmapByteBuffer", "(", "final", "MappedByteBuffer", "map", ")", "{", "if", "(", "map", "==", "null", ")", "{", "return", ";", "}", "map", ".", "force", "(", ")", ";", "try", "{", "if", "(", "Runtime", ".", "class", ".", ...
Unmap a byte buffer. @param map Byte buffer to unmap.
[ "Unmap", "a", "byte", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L842-L881
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/Parallel3DRenderer.java
Parallel3DRenderer.sortAxes
private void sortAxes() { for(int d = 0; d < shared.dim; d++) { double dist = shared.camera.squaredDistanceFromCamera(shared.layout.getNode(d).getX(), shared.layout.getNode(d).getY()); axes[d].first = -dist; axes[d].second = d; } Arrays.sort(axes); for(int i = 0; i < shared.dim; i++) { dindex[axes[i].second] = i; } }
java
private void sortAxes() { for(int d = 0; d < shared.dim; d++) { double dist = shared.camera.squaredDistanceFromCamera(shared.layout.getNode(d).getX(), shared.layout.getNode(d).getY()); axes[d].first = -dist; axes[d].second = d; } Arrays.sort(axes); for(int i = 0; i < shared.dim; i++) { dindex[axes[i].second] = i; } }
[ "private", "void", "sortAxes", "(", ")", "{", "for", "(", "int", "d", "=", "0", ";", "d", "<", "shared", ".", "dim", ";", "d", "++", ")", "{", "double", "dist", "=", "shared", ".", "camera", ".", "squaredDistanceFromCamera", "(", "shared", ".", "la...
Depth-sort the axes.
[ "Depth", "-", "sort", "the", "axes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/Parallel3DRenderer.java#L453-L463
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/Parallel3DRenderer.java
Parallel3DRenderer.sortEdges
private IntIntPair[] sortEdges(int[] dindex) { IntIntPair[] edgesort = new IntIntPair[shared.layout.edges.size()]; int e = 0; for(Layout.Edge edge : shared.layout.edges) { int i1 = dindex[edge.dim1], i2 = dindex[edge.dim2]; edgesort[e] = new IntIntPair(Math.min(i1, i2), e); e++; } Arrays.sort(edgesort); return edgesort; }
java
private IntIntPair[] sortEdges(int[] dindex) { IntIntPair[] edgesort = new IntIntPair[shared.layout.edges.size()]; int e = 0; for(Layout.Edge edge : shared.layout.edges) { int i1 = dindex[edge.dim1], i2 = dindex[edge.dim2]; edgesort[e] = new IntIntPair(Math.min(i1, i2), e); e++; } Arrays.sort(edgesort); return edgesort; }
[ "private", "IntIntPair", "[", "]", "sortEdges", "(", "int", "[", "]", "dindex", ")", "{", "IntIntPair", "[", "]", "edgesort", "=", "new", "IntIntPair", "[", "shared", ".", "layout", ".", "edges", ".", "size", "(", ")", "]", ";", "int", "e", "=", "0...
Sort the edges for rendering. FIXME: THIS STILL HAS ERRORS SOMETIME! @param dindex depth index of axes. @return Sorted array of (minaxis, edgeid)
[ "Sort", "the", "edges", "for", "rendering", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/Parallel3DRenderer.java#L473-L483
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/em/TwoPassMultivariateGaussianModel.java
TwoPassMultivariateGaussianModel.finalizeFirstPassE
@Override public void finalizeFirstPassE() { double s = 1. / wsum; for(int i = 0; i < mean.length; i++) { mean[i] *= s; } }
java
@Override public void finalizeFirstPassE() { double s = 1. / wsum; for(int i = 0; i < mean.length; i++) { mean[i] *= s; } }
[ "@", "Override", "public", "void", "finalizeFirstPassE", "(", ")", "{", "double", "s", "=", "1.", "/", "wsum", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mean", ".", "length", ";", "i", "++", ")", "{", "mean", "[", "i", "]", "*=", ...
Finish computation of the mean.
[ "Finish", "computation", "of", "the", "mean", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/em/TwoPassMultivariateGaussianModel.java#L155-L161
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/normalization/columnwise/AttributeWiseMeanNormalization.java
AttributeWiseMeanNormalization.restore
private double restore(int d, double val) { d = (mean.length == 1) ? 0 : d; return val * mean[d]; }
java
private double restore(int d, double val) { d = (mean.length == 1) ? 0 : d; return val * mean[d]; }
[ "private", "double", "restore", "(", "int", "d", ",", "double", "val", ")", "{", "d", "=", "(", "mean", ".", "length", "==", "1", ")", "?", "0", ":", "d", ";", "return", "val", "*", "mean", "[", "d", "]", ";", "}" ]
Restore a single dimension. @param d Dimension @param val Value @return Normalized value
[ "Restore", "a", "single", "dimension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/normalization/columnwise/AttributeWiseMeanNormalization.java#L162-L165
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java
OUTRES.run
public OutlierResult run(Relation<? extends NumberVector> relation) { final DBIDs ids = relation.getDBIDs(); WritableDoubleDataStore ranks = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_STATIC); DoubleMinMax minmax = new DoubleMinMax(); KernelDensityEstimator kernel = new KernelDensityEstimator(relation, eps); long[] subspace = BitsUtil.zero(kernel.dim); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("OUTRES scores", ids.size(), LOG) : null; for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitsUtil.zeroI(subspace); double score = outresScore(0, subspace, iditer, kernel, ids); ranks.putDouble(iditer, score); minmax.put(score); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); OutlierScoreMeta meta = new InvertedOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0., 1., 1.); return new OutlierResult(meta, new MaterializedDoubleRelation("OUTRES", "outres-score", ranks, ids)); }
java
public OutlierResult run(Relation<? extends NumberVector> relation) { final DBIDs ids = relation.getDBIDs(); WritableDoubleDataStore ranks = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_STATIC); DoubleMinMax minmax = new DoubleMinMax(); KernelDensityEstimator kernel = new KernelDensityEstimator(relation, eps); long[] subspace = BitsUtil.zero(kernel.dim); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("OUTRES scores", ids.size(), LOG) : null; for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) { BitsUtil.zeroI(subspace); double score = outresScore(0, subspace, iditer, kernel, ids); ranks.putDouble(iditer, score); minmax.put(score); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); OutlierScoreMeta meta = new InvertedOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0., 1., 1.); return new OutlierResult(meta, new MaterializedDoubleRelation("OUTRES", "outres-score", ranks, ids)); }
[ "public", "OutlierResult", "run", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "relation", ")", "{", "final", "DBIDs", "ids", "=", "relation", ".", "getDBIDs", "(", ")", ";", "WritableDoubleDataStore", "ranks", "=", "DataStoreUtil", ".", "makeDou...
Main loop for OUTRES @param relation Relation to process @return Outlier detection result
[ "Main", "loop", "for", "OUTRES" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java#L118-L139
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java
OUTRES.outresScore
public double outresScore(final int s, long[] subspace, DBIDRef id, KernelDensityEstimator kernel, DBIDs cands) { double score = 1.0; // Initial score is 1.0 final SubspaceEuclideanDistanceFunction df = new SubspaceEuclideanDistanceFunction(subspace); MeanVariance meanv = new MeanVariance(); ModifiableDoubleDBIDList neighcand = DBIDUtil.newDistanceDBIDList(cands.size()); ModifiableDoubleDBIDList nn = DBIDUtil.newDistanceDBIDList(cands.size()); for(int i = s; i < kernel.dim; i++) { assert !BitsUtil.get(subspace, i); BitsUtil.setI(subspace, i); df.setSelectedDimensions(subspace); final double adjustedEps = kernel.adjustedEps(kernel.dim); DoubleDBIDList neigh = initialRange(id, cands, df, adjustedEps * 2, kernel, neighcand); // Relevance test if(neigh.size() > 2) { if(relevantSubspace(subspace, neigh, kernel)) { final double density = kernel.subspaceDensity(subspace, neigh); // Compute mean and standard deviation for densities of neighbors. meanv.reset(); for(DoubleDBIDListIter neighbor = neigh.iter(); neighbor.valid(); neighbor.advance()) { subsetNeighborhoodQuery(neighcand, neighbor, df, adjustedEps, kernel, nn); meanv.put(kernel.subspaceDensity(subspace, nn)); } final double deviation = (meanv.getMean() - density) / (2. * meanv.getSampleStddev()); // High deviation: if(deviation >= 1) { score *= density / deviation; } // Recursion score *= outresScore(i + 1, subspace, id, kernel, neighcand); } } BitsUtil.clearI(subspace, i); } return score; }
java
public double outresScore(final int s, long[] subspace, DBIDRef id, KernelDensityEstimator kernel, DBIDs cands) { double score = 1.0; // Initial score is 1.0 final SubspaceEuclideanDistanceFunction df = new SubspaceEuclideanDistanceFunction(subspace); MeanVariance meanv = new MeanVariance(); ModifiableDoubleDBIDList neighcand = DBIDUtil.newDistanceDBIDList(cands.size()); ModifiableDoubleDBIDList nn = DBIDUtil.newDistanceDBIDList(cands.size()); for(int i = s; i < kernel.dim; i++) { assert !BitsUtil.get(subspace, i); BitsUtil.setI(subspace, i); df.setSelectedDimensions(subspace); final double adjustedEps = kernel.adjustedEps(kernel.dim); DoubleDBIDList neigh = initialRange(id, cands, df, adjustedEps * 2, kernel, neighcand); // Relevance test if(neigh.size() > 2) { if(relevantSubspace(subspace, neigh, kernel)) { final double density = kernel.subspaceDensity(subspace, neigh); // Compute mean and standard deviation for densities of neighbors. meanv.reset(); for(DoubleDBIDListIter neighbor = neigh.iter(); neighbor.valid(); neighbor.advance()) { subsetNeighborhoodQuery(neighcand, neighbor, df, adjustedEps, kernel, nn); meanv.put(kernel.subspaceDensity(subspace, nn)); } final double deviation = (meanv.getMean() - density) / (2. * meanv.getSampleStddev()); // High deviation: if(deviation >= 1) { score *= density / deviation; } // Recursion score *= outresScore(i + 1, subspace, id, kernel, neighcand); } } BitsUtil.clearI(subspace, i); } return score; }
[ "public", "double", "outresScore", "(", "final", "int", "s", ",", "long", "[", "]", "subspace", ",", "DBIDRef", "id", ",", "KernelDensityEstimator", "kernel", ",", "DBIDs", "cands", ")", "{", "double", "score", "=", "1.0", ";", "// Initial score is 1.0", "fi...
Main loop of OUTRES. Run for each object @param s start dimension @param subspace Current subspace @param id Current object ID @param kernel Kernel @param cands neighbor candidates @return Score
[ "Main", "loop", "of", "OUTRES", ".", "Run", "for", "each", "object" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java#L151-L186
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java
OUTRES.initialRange
private DoubleDBIDList initialRange(DBIDRef obj, DBIDs cands, PrimitiveDistanceFunction<? super NumberVector> df, double eps, KernelDensityEstimator kernel, ModifiableDoubleDBIDList n) { n.clear(); NumberVector o = kernel.relation.get(obj); final double twoeps = eps * 2; int matches = 0; for(DBIDIter cand = cands.iter(); cand.valid(); cand.advance()) { final double dist = df.distance(o, kernel.relation.get(cand)); if(dist <= twoeps) { n.add(dist, cand); if(dist <= eps) { ++matches; } } } n.sort(); return n.slice(0, matches); }
java
private DoubleDBIDList initialRange(DBIDRef obj, DBIDs cands, PrimitiveDistanceFunction<? super NumberVector> df, double eps, KernelDensityEstimator kernel, ModifiableDoubleDBIDList n) { n.clear(); NumberVector o = kernel.relation.get(obj); final double twoeps = eps * 2; int matches = 0; for(DBIDIter cand = cands.iter(); cand.valid(); cand.advance()) { final double dist = df.distance(o, kernel.relation.get(cand)); if(dist <= twoeps) { n.add(dist, cand); if(dist <= eps) { ++matches; } } } n.sort(); return n.slice(0, matches); }
[ "private", "DoubleDBIDList", "initialRange", "(", "DBIDRef", "obj", ",", "DBIDs", "cands", ",", "PrimitiveDistanceFunction", "<", "?", "super", "NumberVector", ">", "df", ",", "double", "eps", ",", "KernelDensityEstimator", "kernel", ",", "ModifiableDoubleDBIDList", ...
Initial range query. @param obj Object @param cands Candidates @param df Distance function @param eps Epsilon radius @param kernel Kernel @param n Output buffer @return Neighbors
[ "Initial", "range", "query", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java#L199-L215
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java
OUTRES.subsetNeighborhoodQuery
private DoubleDBIDList subsetNeighborhoodQuery(DoubleDBIDList neighc, DBIDRef dbid, PrimitiveDistanceFunction<? super NumberVector> df, double adjustedEps, KernelDensityEstimator kernel, ModifiableDoubleDBIDList n) { n.clear(); NumberVector query = kernel.relation.get(dbid); for(DoubleDBIDListIter neighbor = neighc.iter(); neighbor.valid(); neighbor.advance()) { // TODO: use triangle inequality for pruning double dist = df.distance(query, kernel.relation.get(neighbor)); if(dist <= adjustedEps) { n.add(dist, neighbor); } } return n; }
java
private DoubleDBIDList subsetNeighborhoodQuery(DoubleDBIDList neighc, DBIDRef dbid, PrimitiveDistanceFunction<? super NumberVector> df, double adjustedEps, KernelDensityEstimator kernel, ModifiableDoubleDBIDList n) { n.clear(); NumberVector query = kernel.relation.get(dbid); for(DoubleDBIDListIter neighbor = neighc.iter(); neighbor.valid(); neighbor.advance()) { // TODO: use triangle inequality for pruning double dist = df.distance(query, kernel.relation.get(neighbor)); if(dist <= adjustedEps) { n.add(dist, neighbor); } } return n; }
[ "private", "DoubleDBIDList", "subsetNeighborhoodQuery", "(", "DoubleDBIDList", "neighc", ",", "DBIDRef", "dbid", ",", "PrimitiveDistanceFunction", "<", "?", "super", "NumberVector", ">", "df", ",", "double", "adjustedEps", ",", "KernelDensityEstimator", "kernel", ",", ...
Refine neighbors within a subset. @param neighc Neighbor candidates @param dbid Query object @param df distance function @param adjustedEps Epsilon range @param kernel Kernel @param n Output list @return Neighbors of neighbor object
[ "Refine", "neighbors", "within", "a", "subset", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java#L228-L239
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java
OUTRES.relevantSubspace
protected boolean relevantSubspace(long[] subspace, DoubleDBIDList neigh, KernelDensityEstimator kernel) { final double crit = K_S_CRITICAL001 / FastMath.sqrt(neigh.size() - 2); double[] data = new double[neigh.size()]; Relation<? extends NumberVector> relation = kernel.relation; for(int dim = BitsUtil.nextSetBit(subspace, 0); dim >= 0; dim = BitsUtil.nextSetBit(subspace, dim + 1)) { // TODO: can/should we save this copy? int count = 0; for(DBIDIter neighbor = neigh.iter(); neighbor.valid(); neighbor.advance()) { data[count++] = relation.get(neighbor).doubleValue(dim); } assert (count == neigh.size()); Arrays.sort(data); final double min = data[0], norm = data[data.length - 1] - min; // Kolmogorow-Smirnow-Test against uniform distribution: boolean flag = false; for(int j = 1, end = data.length - 1; j < end; j++) { if(Math.abs(j / (data.length - 2.) - (data[j] - min) / norm) > crit) { flag = true; break; } } if(!flag) { return false; } } return true; }
java
protected boolean relevantSubspace(long[] subspace, DoubleDBIDList neigh, KernelDensityEstimator kernel) { final double crit = K_S_CRITICAL001 / FastMath.sqrt(neigh.size() - 2); double[] data = new double[neigh.size()]; Relation<? extends NumberVector> relation = kernel.relation; for(int dim = BitsUtil.nextSetBit(subspace, 0); dim >= 0; dim = BitsUtil.nextSetBit(subspace, dim + 1)) { // TODO: can/should we save this copy? int count = 0; for(DBIDIter neighbor = neigh.iter(); neighbor.valid(); neighbor.advance()) { data[count++] = relation.get(neighbor).doubleValue(dim); } assert (count == neigh.size()); Arrays.sort(data); final double min = data[0], norm = data[data.length - 1] - min; // Kolmogorow-Smirnow-Test against uniform distribution: boolean flag = false; for(int j = 1, end = data.length - 1; j < end; j++) { if(Math.abs(j / (data.length - 2.) - (data[j] - min) / norm) > crit) { flag = true; break; } } if(!flag) { return false; } } return true; }
[ "protected", "boolean", "relevantSubspace", "(", "long", "[", "]", "subspace", ",", "DoubleDBIDList", "neigh", ",", "KernelDensityEstimator", "kernel", ")", "{", "final", "double", "crit", "=", "K_S_CRITICAL001", "/", "FastMath", ".", "sqrt", "(", "neigh", ".", ...
Subspace relevance test. @param subspace Subspace to test @param neigh Neighbor list @param kernel Kernel density estimator @return relevance test result
[ "Subspace", "relevance", "test", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/OUTRES.java#L249-L277
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/Mean.java
Mean.of
public static double of(double... data) { double sum = 0.; for(double v : data) { sum += v; } return sum / data.length; }
java
public static double of(double... data) { double sum = 0.; for(double v : data) { sum += v; } return sum / data.length; }
[ "public", "static", "double", "of", "(", "double", "...", "data", ")", "{", "double", "sum", "=", "0.", ";", "for", "(", "double", "v", ":", "data", ")", "{", "sum", "+=", "v", ";", "}", "return", "sum", "/", "data", ".", "length", ";", "}" ]
Static helper function. @param data Data to compute the mean for. @return Mean
[ "Static", "helper", "function", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/Mean.java#L185-L191
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/Mean.java
Mean.highPrecision
@Reference(authors = "P. M. Neely", // title = "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients", // booktitle = "Communications of the ACM 9(7), 1966", // url = "https://doi.org/10.1145/365719.365958", // bibkey = "doi:10.1145/365719.365958") public static double highPrecision(double... data) { double sum = 0.; for(double v : data) { sum += v; } sum /= data.length; // Perform a second pass to increase precision // In ideal math, this would sum to 0. double err = 0; for(double v : data) { err += v - sum; } return sum + err / data.length; }
java
@Reference(authors = "P. M. Neely", // title = "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients", // booktitle = "Communications of the ACM 9(7), 1966", // url = "https://doi.org/10.1145/365719.365958", // bibkey = "doi:10.1145/365719.365958") public static double highPrecision(double... data) { double sum = 0.; for(double v : data) { sum += v; } sum /= data.length; // Perform a second pass to increase precision // In ideal math, this would sum to 0. double err = 0; for(double v : data) { err += v - sum; } return sum + err / data.length; }
[ "@", "Reference", "(", "authors", "=", "\"P. M. Neely\"", ",", "//", "title", "=", "\"Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients\"", ",", "//", "booktitle", "=", "\"Communications of the ACM 9(7), 1966\"", ",", "//", ...
Static helper function, with extra precision @param data Data to compute the mean for. @return Mean
[ "Static", "helper", "function", "with", "extra", "precision" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/Mean.java#L199-L217
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/AbstractMTree.java
AbstractMTree.insertAll
public void insertAll(List<E> entries) { if(!initialized && !entries.isEmpty()) { initialize(entries.get(0)); } for(E entry : entries) { insert(entry, false); } }
java
public void insertAll(List<E> entries) { if(!initialized && !entries.isEmpty()) { initialize(entries.get(0)); } for(E entry : entries) { insert(entry, false); } }
[ "public", "void", "insertAll", "(", "List", "<", "E", ">", "entries", ")", "{", "if", "(", "!", "initialized", "&&", "!", "entries", ".", "isEmpty", "(", ")", ")", "{", "initialize", "(", "entries", ".", "get", "(", "0", ")", ")", ";", "}", "for"...
Bulk insert. @param entries Entries to insert
[ "Bulk", "insert", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/AbstractMTree.java#L199-L206
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/AbstractMTree.java
AbstractMTree.getSortedEntries
protected final List<DoubleIntPair> getSortedEntries(N node, DBID q) { List<DoubleIntPair> result = new ArrayList<>(); for(int i = 0; i < node.getNumEntries(); i++) { E entry = node.getEntry(i); double distance = distance(entry.getRoutingObjectID(), q); double radius = entry.getCoveringRadius(); double minDist = (radius > distance) ? 0.0 : distance - radius; result.add(new DoubleIntPair(minDist, i)); } Collections.sort(result); return result; }
java
protected final List<DoubleIntPair> getSortedEntries(N node, DBID q) { List<DoubleIntPair> result = new ArrayList<>(); for(int i = 0; i < node.getNumEntries(); i++) { E entry = node.getEntry(i); double distance = distance(entry.getRoutingObjectID(), q); double radius = entry.getCoveringRadius(); double minDist = (radius > distance) ? 0.0 : distance - radius; result.add(new DoubleIntPair(minDist, i)); } Collections.sort(result); return result; }
[ "protected", "final", "List", "<", "DoubleIntPair", ">", "getSortedEntries", "(", "N", "node", ",", "DBID", "q", ")", "{", "List", "<", "DoubleIntPair", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";...
Sorts the entries of the specified node according to their minimum distance to the specified object. @param node the node @param q the id of the object @return a list of the sorted entries
[ "Sorts", "the", "entries", "of", "the", "specified", "node", "according", "to", "their", "minimum", "distance", "to", "the", "specified", "object", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/AbstractMTree.java#L221-L235
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/AbstractMTree.java
AbstractMTree.distance
public final double distance(E e1, E e2) { return distance(e1.getRoutingObjectID(), e2.getRoutingObjectID()); }
java
public final double distance(E e1, E e2) { return distance(e1.getRoutingObjectID(), e2.getRoutingObjectID()); }
[ "public", "final", "double", "distance", "(", "E", "e1", ",", "E", "e2", ")", "{", "return", "distance", "(", "e1", ".", "getRoutingObjectID", "(", ")", ",", "e2", ".", "getRoutingObjectID", "(", ")", ")", ";", "}" ]
Returns the distance between the routing object of two entries. @param e1 First entry @param e2 Second entry @return the distance between the two routing objects
[ "Returns", "the", "distance", "between", "the", "routing", "object", "of", "two", "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/AbstractMTree.java#L253-L255
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java
ProbabilityWeightedMoments.alphaPWM
public static <A> double[] alphaPWM(A data, NumberArrayAdapter<?, A> adapter, final int nmom) { final int n = adapter.size(data); final double[] xmom = new double[nmom]; double weight = 1. / n; for(int i = 0; i < n; i++) { final double val = adapter.getDouble(data, i); xmom[0] += weight * val; for(int j = 1; j < nmom; j++) { weight *= (n - i - j + 1) / (n - j + 1); xmom[j] += weight * val; } } return xmom; }
java
public static <A> double[] alphaPWM(A data, NumberArrayAdapter<?, A> adapter, final int nmom) { final int n = adapter.size(data); final double[] xmom = new double[nmom]; double weight = 1. / n; for(int i = 0; i < n; i++) { final double val = adapter.getDouble(data, i); xmom[0] += weight * val; for(int j = 1; j < nmom; j++) { weight *= (n - i - j + 1) / (n - j + 1); xmom[j] += weight * val; } } return xmom; }
[ "public", "static", "<", "A", ">", "double", "[", "]", "alphaPWM", "(", "A", "data", ",", "NumberArrayAdapter", "<", "?", ",", "A", ">", "adapter", ",", "final", "int", "nmom", ")", "{", "final", "int", "n", "=", "adapter", ".", "size", "(", "data"...
Compute the alpha_r factors using the method of probability-weighted moments. @param data <b>Presorted</b> data array. @param adapter Array adapter. @param nmom Number of moments to compute @return Alpha moments (0-indexed)
[ "Compute", "the", "alpha_r", "factors", "using", "the", "method", "of", "probability", "-", "weighted", "moments", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java#L71-L84
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java
ProbabilityWeightedMoments.alphaBetaPWM
public static <A> double[] alphaBetaPWM(A data, NumberArrayAdapter<?, A> adapter, final int nmom) { final int n = adapter.size(data); final double[] xmom = new double[nmom << 1]; double aweight = 1. / n, bweight = aweight; for(int i = 0; i < n; i++) { final double val = adapter.getDouble(data, i); xmom[0] += aweight * val; xmom[1] += bweight * val; for(int j = 1, k = 2; j < nmom; j++, k += 2) { aweight *= (n - i - j + 1) / (n - j + 1); bweight *= (i - j + 1) / (n - j + 1); xmom[k + 1] += aweight * val; xmom[k + 1] += bweight * val; } } return xmom; }
java
public static <A> double[] alphaBetaPWM(A data, NumberArrayAdapter<?, A> adapter, final int nmom) { final int n = adapter.size(data); final double[] xmom = new double[nmom << 1]; double aweight = 1. / n, bweight = aweight; for(int i = 0; i < n; i++) { final double val = adapter.getDouble(data, i); xmom[0] += aweight * val; xmom[1] += bweight * val; for(int j = 1, k = 2; j < nmom; j++, k += 2) { aweight *= (n - i - j + 1) / (n - j + 1); bweight *= (i - j + 1) / (n - j + 1); xmom[k + 1] += aweight * val; xmom[k + 1] += bweight * val; } } return xmom; }
[ "public", "static", "<", "A", ">", "double", "[", "]", "alphaBetaPWM", "(", "A", "data", ",", "NumberArrayAdapter", "<", "?", ",", "A", ">", "adapter", ",", "final", "int", "nmom", ")", "{", "final", "int", "n", "=", "adapter", ".", "size", "(", "d...
Compute the alpha_r and beta_r factors in parallel using the method of probability-weighted moments. Usually cheaper than computing them separately. @param data <b>Presorted</b> data array. @param adapter Array adapter. @param nmom Number of moments to compute @return Alpha and Beta moments (0-indexed, interleaved)
[ "Compute", "the", "alpha_r", "and", "beta_r", "factors", "in", "parallel", "using", "the", "method", "of", "probability", "-", "weighted", "moments", ".", "Usually", "cheaper", "than", "computing", "them", "separately", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java#L120-L136
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java
ProbabilityWeightedMoments.samLMR
public static <A> double[] samLMR(A sorted, NumberArrayAdapter<?, A> adapter, int nmom) { final int n = adapter.size(sorted); final double[] sum = new double[nmom]; nmom = n < nmom ? n : nmom; // Estimate probability weighted moments (unbiased) for(int i = 0; i < n; i++) { double term = adapter.getDouble(sorted, i); // Robustness: skip bad values if(Double.isInfinite(term) || Double.isNaN(term)) { continue; } sum[0] += term; for(int j = 1, z = i; j < nmom; j++, z--) { term *= z; sum[j] += term; } } // Normalize by "n choose (j + 1)" sum[0] /= n; double z = n; for(int j = 1; j < nmom; j++) { z *= n - j; sum[j] /= z; } normalizeLMR(sum, nmom); // Handle case when lambda2 == 0, by setting tau3...tauN = 0: if(sum[1] == 0) { for(int i = 2; i < nmom; i++) { sum[i] = 0.; // tau3...tauN = 0. } return sum; } // Map lambda3...lambdaN to tau3...tauN for(int i = 2; i < nmom; i++) { sum[i] /= sum[1]; } return sum; }
java
public static <A> double[] samLMR(A sorted, NumberArrayAdapter<?, A> adapter, int nmom) { final int n = adapter.size(sorted); final double[] sum = new double[nmom]; nmom = n < nmom ? n : nmom; // Estimate probability weighted moments (unbiased) for(int i = 0; i < n; i++) { double term = adapter.getDouble(sorted, i); // Robustness: skip bad values if(Double.isInfinite(term) || Double.isNaN(term)) { continue; } sum[0] += term; for(int j = 1, z = i; j < nmom; j++, z--) { term *= z; sum[j] += term; } } // Normalize by "n choose (j + 1)" sum[0] /= n; double z = n; for(int j = 1; j < nmom; j++) { z *= n - j; sum[j] /= z; } normalizeLMR(sum, nmom); // Handle case when lambda2 == 0, by setting tau3...tauN = 0: if(sum[1] == 0) { for(int i = 2; i < nmom; i++) { sum[i] = 0.; // tau3...tauN = 0. } return sum; } // Map lambda3...lambdaN to tau3...tauN for(int i = 2; i < nmom; i++) { sum[i] /= sum[1]; } return sum; }
[ "public", "static", "<", "A", ">", "double", "[", "]", "samLMR", "(", "A", "sorted", ",", "NumberArrayAdapter", "<", "?", ",", "A", ">", "adapter", ",", "int", "nmom", ")", "{", "final", "int", "n", "=", "adapter", ".", "size", "(", "sorted", ")", ...
Compute the sample L-Moments using probability weighted moments. @param sorted <b>Presorted</b> data array. @param adapter Array adapter. @param nmom Number of moments to compute @return Array containing Lambda1, Lambda2, Tau3 ... TauN
[ "Compute", "the", "sample", "L", "-", "Moments", "using", "probability", "weighted", "moments", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java#L146-L183
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java
ProbabilityWeightedMoments.normalizeLMR
private static void normalizeLMR(double[] sum, int nmom) { for(int k = nmom - 1; k >= 1; --k) { double p = ((k & 1) == 0) ? +1 : -1; double temp = p * sum[0]; for(int i = 0; i < k; i++) { double ai = i + 1.; p *= -(k + ai) * (k - i) / (ai * ai); temp += p * sum[i + 1]; } sum[k] = temp; } }
java
private static void normalizeLMR(double[] sum, int nmom) { for(int k = nmom - 1; k >= 1; --k) { double p = ((k & 1) == 0) ? +1 : -1; double temp = p * sum[0]; for(int i = 0; i < k; i++) { double ai = i + 1.; p *= -(k + ai) * (k - i) / (ai * ai); temp += p * sum[i + 1]; } sum[k] = temp; } }
[ "private", "static", "void", "normalizeLMR", "(", "double", "[", "]", "sum", ",", "int", "nmom", ")", "{", "for", "(", "int", "k", "=", "nmom", "-", "1", ";", "k", ">=", "1", ";", "--", "k", ")", "{", "double", "p", "=", "(", "(", "k", "&", ...
Normalize the moments @param sum Sums @param nmom Number of moments
[ "Normalize", "the", "moments" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/ProbabilityWeightedMoments.java#L191-L202
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java
FPGrowth.countItemSupport
private int[] countItemSupport(final Relation<BitVector> relation, final int dim) { final int[] counts = new int[dim]; FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Finding frequent 1-items", relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { SparseFeatureVector<?> bv = relation.get(iditer); // TODO: only count those which satisfy minlength? for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) { counts[bv.iterDim(it)]++; } LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); return counts; }
java
private int[] countItemSupport(final Relation<BitVector> relation, final int dim) { final int[] counts = new int[dim]; FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Finding frequent 1-items", relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { SparseFeatureVector<?> bv = relation.get(iditer); // TODO: only count those which satisfy minlength? for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) { counts[bv.iterDim(it)]++; } LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); return counts; }
[ "private", "int", "[", "]", "countItemSupport", "(", "final", "Relation", "<", "BitVector", ">", "relation", ",", "final", "int", "dim", ")", "{", "final", "int", "[", "]", "counts", "=", "new", "int", "[", "dim", "]", ";", "FiniteProgress", "prog", "=...
Count the support of each 1-item. @param relation Data @param dim Maximum dimensionality @return Item counts
[ "Count", "the", "support", "of", "each", "1", "-", "item", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java#L194-L207
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java
FPGrowth.buildFPTree
private FPTree buildFPTree(final Relation<BitVector> relation, int[] iidx, final int items) { FPTree tree = new FPTree(items); FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Building FP-tree", relation.size(), LOG) : null; int[] buf = new int[items]; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { // Convert item to index representation: int l = 0; SparseFeatureVector<?> bv = relation.get(iditer); for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) { int i = iidx[bv.iterDim(it)]; if(i < 0) { continue; // Skip non-frequent items } buf[l++] = i; } // Skip too short entries if(l >= minlength) { Arrays.sort(buf, 0, l); // Sort ascending tree.insert(buf, 0, l, 1); } LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); return tree; }
java
private FPTree buildFPTree(final Relation<BitVector> relation, int[] iidx, final int items) { FPTree tree = new FPTree(items); FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Building FP-tree", relation.size(), LOG) : null; int[] buf = new int[items]; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { // Convert item to index representation: int l = 0; SparseFeatureVector<?> bv = relation.get(iditer); for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) { int i = iidx[bv.iterDim(it)]; if(i < 0) { continue; // Skip non-frequent items } buf[l++] = i; } // Skip too short entries if(l >= minlength) { Arrays.sort(buf, 0, l); // Sort ascending tree.insert(buf, 0, l, 1); } LOG.incrementProcessed(prog); } LOG.ensureCompleted(prog); return tree; }
[ "private", "FPTree", "buildFPTree", "(", "final", "Relation", "<", "BitVector", ">", "relation", ",", "int", "[", "]", "iidx", ",", "final", "int", "items", ")", "{", "FPTree", "tree", "=", "new", "FPTree", "(", "items", ")", ";", "FiniteProgress", "prog...
Build the actual FP-tree structure. @param relation Data @param iidx Inverse index (dimension to item rank) @param items Number of items @return FP-tree
[ "Build", "the", "actual", "FP", "-", "tree", "structure", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java#L217-L241
train
elki-project/elki
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/associationrules/AssociationRule.java
AssociationRule.appendTo
public StringBuilder appendTo(StringBuilder buf, VectorFieldTypeInformation<BitVector> meta) { this.antecedent.appendTo(buf, meta); buf.append(" --> "); this.consequent.appendItemsTo(buf, meta); buf.append(": "); buf.append(union.getSupport()); buf.append(" : "); buf.append(this.measure); return buf; }
java
public StringBuilder appendTo(StringBuilder buf, VectorFieldTypeInformation<BitVector> meta) { this.antecedent.appendTo(buf, meta); buf.append(" --> "); this.consequent.appendItemsTo(buf, meta); buf.append(": "); buf.append(union.getSupport()); buf.append(" : "); buf.append(this.measure); return buf; }
[ "public", "StringBuilder", "appendTo", "(", "StringBuilder", "buf", ",", "VectorFieldTypeInformation", "<", "BitVector", ">", "meta", ")", "{", "this", ".", "antecedent", ".", "appendTo", "(", "buf", ",", "meta", ")", ";", "buf", ".", "append", "(", "\" --> ...
Append to a string buffer. @param buf Buffer @param meta Relation metadata (for labels) @return String buffer for chaining.
[ "Append", "to", "a", "string", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/associationrules/AssociationRule.java#L123-L132
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/ClusterContingencyTable.java
ClusterContingencyTable.process
public void process(Clustering<?> result1, Clustering<?> result2) { // Get the clusters final List<? extends Cluster<?>> cs1 = result1.getAllClusters(); final List<? extends Cluster<?>> cs2 = result2.getAllClusters(); // Initialize size1 = cs1.size(); size2 = cs2.size(); contingency = new int[size1 + 2][size2 + 2]; noise1 = BitsUtil.zero(size1); noise2 = BitsUtil.zero(size2); // Fill main part of matrix { final Iterator<? extends Cluster<?>> it2 = cs2.iterator(); for(int i2 = 0; it2.hasNext(); i2++) { final Cluster<?> c2 = it2.next(); if(c2.isNoise()) { BitsUtil.setI(noise2, i2); } contingency[size1 + 1][i2] = c2.size(); contingency[size1 + 1][size2] += c2.size(); } } final Iterator<? extends Cluster<?>> it1 = cs1.iterator(); for(int i1 = 0; it1.hasNext(); i1++) { final Cluster<?> c1 = it1.next(); if(c1.isNoise()) { BitsUtil.setI(noise1, i1); } final DBIDs ids = DBIDUtil.ensureSet(c1.getIDs()); contingency[i1][size2 + 1] = c1.size(); contingency[size1][size2 + 1] += c1.size(); final Iterator<? extends Cluster<?>> it2 = cs2.iterator(); for(int i2 = 0; it2.hasNext(); i2++) { final Cluster<?> c2 = it2.next(); int count = DBIDUtil.intersectionSize(ids, c2.getIDs()); contingency[i1][i2] = count; contingency[i1][size2] += count; contingency[size1][i2] += count; contingency[size1][size2] += count; } } }
java
public void process(Clustering<?> result1, Clustering<?> result2) { // Get the clusters final List<? extends Cluster<?>> cs1 = result1.getAllClusters(); final List<? extends Cluster<?>> cs2 = result2.getAllClusters(); // Initialize size1 = cs1.size(); size2 = cs2.size(); contingency = new int[size1 + 2][size2 + 2]; noise1 = BitsUtil.zero(size1); noise2 = BitsUtil.zero(size2); // Fill main part of matrix { final Iterator<? extends Cluster<?>> it2 = cs2.iterator(); for(int i2 = 0; it2.hasNext(); i2++) { final Cluster<?> c2 = it2.next(); if(c2.isNoise()) { BitsUtil.setI(noise2, i2); } contingency[size1 + 1][i2] = c2.size(); contingency[size1 + 1][size2] += c2.size(); } } final Iterator<? extends Cluster<?>> it1 = cs1.iterator(); for(int i1 = 0; it1.hasNext(); i1++) { final Cluster<?> c1 = it1.next(); if(c1.isNoise()) { BitsUtil.setI(noise1, i1); } final DBIDs ids = DBIDUtil.ensureSet(c1.getIDs()); contingency[i1][size2 + 1] = c1.size(); contingency[size1][size2 + 1] += c1.size(); final Iterator<? extends Cluster<?>> it2 = cs2.iterator(); for(int i2 = 0; it2.hasNext(); i2++) { final Cluster<?> c2 = it2.next(); int count = DBIDUtil.intersectionSize(ids, c2.getIDs()); contingency[i1][i2] = count; contingency[i1][size2] += count; contingency[size1][i2] += count; contingency[size1][size2] += count; } } }
[ "public", "void", "process", "(", "Clustering", "<", "?", ">", "result1", ",", "Clustering", "<", "?", ">", "result2", ")", "{", "// Get the clusters", "final", "List", "<", "?", "extends", "Cluster", "<", "?", ">", ">", "cs1", "=", "result1", ".", "ge...
Process two clustering results. @param result1 First clustering @param result2 Second clustering
[ "Process", "two", "clustering", "results", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/ClusterContingencyTable.java#L117-L161
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/FeatureBagging.java
FeatureBagging.randomSubspace
private long[] randomSubspace(final int alldim, final int mindim, final int maxdim, final Random rand) { long[] dimset = BitsUtil.zero(alldim); // Fill with all dimensions int[] dims = new int[alldim]; for(int d = 0; d < alldim; d++) { dims[d] = d; } // Target dimensionality: int subdim = mindim + rand.nextInt(maxdim - mindim); // Shrink the subspace to the destination size for(int d = 0; d < alldim - subdim; d++) { int s = rand.nextInt(alldim - d); BitsUtil.setI(dimset, dims[s]); dims[s] = dims[alldim - d - 1]; } return dimset; }
java
private long[] randomSubspace(final int alldim, final int mindim, final int maxdim, final Random rand) { long[] dimset = BitsUtil.zero(alldim); // Fill with all dimensions int[] dims = new int[alldim]; for(int d = 0; d < alldim; d++) { dims[d] = d; } // Target dimensionality: int subdim = mindim + rand.nextInt(maxdim - mindim); // Shrink the subspace to the destination size for(int d = 0; d < alldim - subdim; d++) { int s = rand.nextInt(alldim - d); BitsUtil.setI(dimset, dims[s]); dims[s] = dims[alldim - d - 1]; } return dimset; }
[ "private", "long", "[", "]", "randomSubspace", "(", "final", "int", "alldim", ",", "final", "int", "mindim", ",", "final", "int", "maxdim", ",", "final", "Random", "rand", ")", "{", "long", "[", "]", "dimset", "=", "BitsUtil", ".", "zero", "(", "alldim...
Choose a random subspace. @param alldim Number of total dimensions @param mindim Minimum number to choose @param maxdim Maximum number to choose @return Subspace as bits.
[ "Choose", "a", "random", "subspace", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/FeatureBagging.java#L224-L240
train