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-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java
ClusteringFeature.addToStatistics
protected void addToStatistics(NumberVector nv) { final int d = nv.getDimensionality(); assert (d == ls.length); this.n++; for(int i = 0; i < d; i++) { double v = nv.doubleValue(i); ls[i] += v; ss += v * v; } }
java
protected void addToStatistics(NumberVector nv) { final int d = nv.getDimensionality(); assert (d == ls.length); this.n++; for(int i = 0; i < d; i++) { double v = nv.doubleValue(i); ls[i] += v; ss += v * v; } }
[ "protected", "void", "addToStatistics", "(", "NumberVector", "nv", ")", "{", "final", "int", "d", "=", "nv", ".", "getDimensionality", "(", ")", ";", "assert", "(", "d", "==", "ls", ".", "length", ")", ";", "this", ".", "n", "++", ";", "for", "(", ...
Add a number vector to the current node. @param nv Vector to add
[ "Add", "a", "number", "vector", "to", "the", "current", "node", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java#L65-L74
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java
ClusteringFeature.addToStatistics
protected void addToStatistics(ClusteringFeature other) { n += other.n; VMath.plusEquals(ls, other.ls); ss += other.ss; }
java
protected void addToStatistics(ClusteringFeature other) { n += other.n; VMath.plusEquals(ls, other.ls); ss += other.ss; }
[ "protected", "void", "addToStatistics", "(", "ClusteringFeature", "other", ")", "{", "n", "+=", "other", ".", "n", ";", "VMath", ".", "plusEquals", "(", "ls", ",", "other", ".", "ls", ")", ";", "ss", "+=", "other", ".", "ss", ";", "}" ]
Merge an other clustering features. @param other Other CF
[ "Merge", "an", "other", "clustering", "features", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java#L81-L85
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java
ClusteringFeature.sumOfSquaresOfSums
public double sumOfSquaresOfSums() { double sum = 0.; for(int i = 0; i < ls.length; i++) { double v = ls[i]; sum += v * v; } return sum; }
java
public double sumOfSquaresOfSums() { double sum = 0.; for(int i = 0; i < ls.length; i++) { double v = ls[i]; sum += v * v; } return sum; }
[ "public", "double", "sumOfSquaresOfSums", "(", ")", "{", "double", "sum", "=", "0.", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ls", ".", "length", ";", "i", "++", ")", "{", "double", "v", "=", "ls", "[", "i", "]", ";", "sum", "+=...
Sum over all dimensions of squares of linear sums. @return Sum of LS
[ "Sum", "over", "all", "dimensions", "of", "squares", "of", "linear", "sums", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java#L120-L127
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java
ClusteringFeature.sumOfSquares
public static double sumOfSquares(NumberVector v) { final int dim = v.getDimensionality(); double sum = 0; for(int d = 0; d < dim; d++) { double x = v.doubleValue(d); sum += x * x; } return sum; }
java
public static double sumOfSquares(NumberVector v) { final int dim = v.getDimensionality(); double sum = 0; for(int d = 0; d < dim; d++) { double x = v.doubleValue(d); sum += x * x; } return sum; }
[ "public", "static", "double", "sumOfSquares", "(", "NumberVector", "v", ")", "{", "final", "int", "dim", "=", "v", ".", "getDimensionality", "(", ")", ";", "double", "sum", "=", "0", ";", "for", "(", "int", "d", "=", "0", ";", "d", "<", "dim", ";",...
Compute the sum of squares of a vector. @param v Vector @return Sum of squares
[ "Compute", "the", "sum", "of", "squares", "of", "a", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/ClusteringFeature.java#L144-L152
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/arrays/IntegerArrayQuickSort.java
IntegerArrayQuickSort.insertionSort
private static void insertionSort(int[] data, final int start, final int end, IntComparator comp) { // Classic insertion sort. for(int i = start + 1; i < end; i++) { final int cur = data[i]; int j = i - 1; while(j >= start) { final int pre = data[j]; if(comp.compare(cur, pre) >= 0) { break; } data[j + 1] = pre; --j; } data[j + 1] = cur; } }
java
private static void insertionSort(int[] data, final int start, final int end, IntComparator comp) { // Classic insertion sort. for(int i = start + 1; i < end; i++) { final int cur = data[i]; int j = i - 1; while(j >= start) { final int pre = data[j]; if(comp.compare(cur, pre) >= 0) { break; } data[j + 1] = pre; --j; } data[j + 1] = cur; } }
[ "private", "static", "void", "insertionSort", "(", "int", "[", "]", "data", ",", "final", "int", "start", ",", "final", "int", "end", ",", "IntComparator", "comp", ")", "{", "// Classic insertion sort.", "for", "(", "int", "i", "=", "start", "+", "1", ";...
Insertion sort, for short arrays. @param data Data to sort @param start First index @param end Last index (exclusive!) @param comp Comparator
[ "Insertion", "sort", "for", "short", "arrays", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/arrays/IntegerArrayQuickSort.java#L193-L208
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/WeightedCovarianceMatrixBuilder.java
WeightedCovarianceMatrixBuilder.processIds
@Override public double[][] processIds(DBIDs ids, Relation<? extends NumberVector> relation) { final int dim = RelationUtil.dimensionality(relation); final CovarianceMatrix cmat = new CovarianceMatrix(dim); final Centroid centroid = Centroid.make(relation, ids); // find maximum distance double maxdist = 0.0, stddev = 0.0; { for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double distance = weightDistance.distance(centroid, relation.get(iter)); stddev += distance * distance; if(distance > maxdist) { maxdist = distance; } } if(maxdist == 0.0) { maxdist = 1.0; } // compute standard deviation. stddev = FastMath.sqrt(stddev / ids.size()); } for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { NumberVector obj = relation.get(iter); double distance = weightDistance.distance(centroid, obj); double weight = weightfunction.getWeight(distance, maxdist, stddev); cmat.put(obj, weight); } return cmat.destroyToPopulationMatrix(); }
java
@Override public double[][] processIds(DBIDs ids, Relation<? extends NumberVector> relation) { final int dim = RelationUtil.dimensionality(relation); final CovarianceMatrix cmat = new CovarianceMatrix(dim); final Centroid centroid = Centroid.make(relation, ids); // find maximum distance double maxdist = 0.0, stddev = 0.0; { for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double distance = weightDistance.distance(centroid, relation.get(iter)); stddev += distance * distance; if(distance > maxdist) { maxdist = distance; } } if(maxdist == 0.0) { maxdist = 1.0; } // compute standard deviation. stddev = FastMath.sqrt(stddev / ids.size()); } for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { NumberVector obj = relation.get(iter); double distance = weightDistance.distance(centroid, obj); double weight = weightfunction.getWeight(distance, maxdist, stddev); cmat.put(obj, weight); } return cmat.destroyToPopulationMatrix(); }
[ "@", "Override", "public", "double", "[", "]", "[", "]", "processIds", "(", "DBIDs", "ids", ",", "Relation", "<", "?", "extends", "NumberVector", ">", "relation", ")", "{", "final", "int", "dim", "=", "RelationUtil", ".", "dimensionality", "(", "relation",...
Weighted Covariance Matrix for a set of IDs. Since we are not supplied any distance information, we'll need to compute it ourselves. Covariance is tied to Euclidean distance, so it probably does not make much sense to add support for other distance functions? @param ids Database ids to process @param relation Relation to process @return Covariance matrix
[ "Weighted", "Covariance", "Matrix", "for", "a", "set", "of", "IDs", ".", "Since", "we", "are", "not", "supplied", "any", "distance", "information", "we", "ll", "need", "to", "compute", "it", "ourselves", ".", "Covariance", "is", "tied", "to", "Euclidean", ...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/WeightedCovarianceMatrixBuilder.java#L105-L135
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/WeightedCovarianceMatrixBuilder.java
WeightedCovarianceMatrixBuilder.processQueryResults
@Override public double[][] processQueryResults(DoubleDBIDList results, Relation<? extends NumberVector> database, int k) { final int dim = RelationUtil.dimensionality(database); final CovarianceMatrix cmat = new CovarianceMatrix(dim); // avoid bad parameters k = k <= results.size() ? k : results.size(); // find maximum distance double maxdist = 0.0, stddev = 0.0; { int i = 0; for(DoubleDBIDListIter it = results.iter(); it.valid() && i < k; it.advance(), k++) { final double dist = it.doubleValue(); stddev += dist * dist; if(dist > maxdist) { maxdist = dist; } } if(maxdist == 0.0) { maxdist = 1.0; } stddev = FastMath.sqrt(stddev / k); } // calculate weighted PCA int i = 0; for(DoubleDBIDListIter it = results.iter(); it.valid() && i < k; it.advance(), k++) { final double dist = it.doubleValue(); NumberVector obj = database.get(it); double weight = weightfunction.getWeight(dist, maxdist, stddev); cmat.put(obj, weight); } return cmat.destroyToPopulationMatrix(); }
java
@Override public double[][] processQueryResults(DoubleDBIDList results, Relation<? extends NumberVector> database, int k) { final int dim = RelationUtil.dimensionality(database); final CovarianceMatrix cmat = new CovarianceMatrix(dim); // avoid bad parameters k = k <= results.size() ? k : results.size(); // find maximum distance double maxdist = 0.0, stddev = 0.0; { int i = 0; for(DoubleDBIDListIter it = results.iter(); it.valid() && i < k; it.advance(), k++) { final double dist = it.doubleValue(); stddev += dist * dist; if(dist > maxdist) { maxdist = dist; } } if(maxdist == 0.0) { maxdist = 1.0; } stddev = FastMath.sqrt(stddev / k); } // calculate weighted PCA int i = 0; for(DoubleDBIDListIter it = results.iter(); it.valid() && i < k; it.advance(), k++) { final double dist = it.doubleValue(); NumberVector obj = database.get(it); double weight = weightfunction.getWeight(dist, maxdist, stddev); cmat.put(obj, weight); } return cmat.destroyToPopulationMatrix(); }
[ "@", "Override", "public", "double", "[", "]", "[", "]", "processQueryResults", "(", "DoubleDBIDList", "results", ",", "Relation", "<", "?", "extends", "NumberVector", ">", "database", ",", "int", "k", ")", "{", "final", "int", "dim", "=", "RelationUtil", ...
Compute Covariance Matrix for a QueryResult Collection. By default it will just collect the ids and run processIds @param results a collection of QueryResults @param database the database used @param k number of elements to process @return Covariance Matrix
[ "Compute", "Covariance", "Matrix", "for", "a", "QueryResult", "Collection", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/WeightedCovarianceMatrixBuilder.java#L147-L181
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/ERiCNeighborPredicate.java
ERiCNeighborPredicate.instantiate
public Instance instantiate(Database database, Relation<V> relation) { DistanceQuery<V> dq = database.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = database.getKNNQuery(dq, settings.k); WritableDataStore<PCAFilteredResult> storage = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, PCAFilteredResult.class); PCARunner pca = settings.pca; EigenPairFilter filter = settings.filter; Duration time = LOG.newDuration(this.getClass().getName() + ".preprocessing-time").begin(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress(this.getClass().getName(), relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { DoubleDBIDList ref = knnq.getKNNForDBID(iditer, settings.k); PCAResult pcares = pca.processQueryResult(ref, relation); storage.put(iditer, new PCAFilteredResult(pcares.getEigenPairs(), filter.filter(pcares.getEigenvalues()), 1., 0.)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); LOG.statistics(time.end()); return new Instance(relation.getDBIDs(), storage, relation); }
java
public Instance instantiate(Database database, Relation<V> relation) { DistanceQuery<V> dq = database.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = database.getKNNQuery(dq, settings.k); WritableDataStore<PCAFilteredResult> storage = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, PCAFilteredResult.class); PCARunner pca = settings.pca; EigenPairFilter filter = settings.filter; Duration time = LOG.newDuration(this.getClass().getName() + ".preprocessing-time").begin(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress(this.getClass().getName(), relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { DoubleDBIDList ref = knnq.getKNNForDBID(iditer, settings.k); PCAResult pcares = pca.processQueryResult(ref, relation); storage.put(iditer, new PCAFilteredResult(pcares.getEigenPairs(), filter.filter(pcares.getEigenvalues()), 1., 0.)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); LOG.statistics(time.end()); return new Instance(relation.getDBIDs(), storage, relation); }
[ "public", "Instance", "instantiate", "(", "Database", "database", ",", "Relation", "<", "V", ">", "relation", ")", "{", "DistanceQuery", "<", "V", ">", "dq", "=", "database", ".", "getDistanceQuery", "(", "relation", ",", "EuclideanDistanceFunction", ".", "STA...
Full instantiation interface. @param database Database @param relation Relation @return Instance
[ "Full", "instantiation", "interface", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/ERiCNeighborPredicate.java#L115-L134
train
elki-project/elki
elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/HTMLUtil.java
HTMLUtil.writeXHTML
public static void writeXHTML(Document htmldoc, OutputStream out) throws IOException { javax.xml.transform.Result result = new StreamResult(out); // Use a transformer for pretty printing Transformer xformer; try { xformer = TransformerFactory.newInstance().newTransformer(); xformer.setOutputProperty(OutputKeys.INDENT, "yes"); // TODO: ensure the "meta" tag doesn't claim a different encoding! xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); xformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, HTML_XHTML_TRANSITIONAL_DOCTYPE_PUBLIC); xformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, HTML_XHTML_TRANSITIONAL_DOCTYPE_SYSTEM); xformer.transform(new DOMSource(htmldoc), result); } catch(TransformerException e1) { throw new IOException(e1); } out.flush(); }
java
public static void writeXHTML(Document htmldoc, OutputStream out) throws IOException { javax.xml.transform.Result result = new StreamResult(out); // Use a transformer for pretty printing Transformer xformer; try { xformer = TransformerFactory.newInstance().newTransformer(); xformer.setOutputProperty(OutputKeys.INDENT, "yes"); // TODO: ensure the "meta" tag doesn't claim a different encoding! xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); xformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, HTML_XHTML_TRANSITIONAL_DOCTYPE_PUBLIC); xformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, HTML_XHTML_TRANSITIONAL_DOCTYPE_SYSTEM); xformer.transform(new DOMSource(htmldoc), result); } catch(TransformerException e1) { throw new IOException(e1); } out.flush(); }
[ "public", "static", "void", "writeXHTML", "(", "Document", "htmldoc", ",", "OutputStream", "out", ")", "throws", "IOException", "{", "javax", ".", "xml", ".", "transform", ".", "Result", "result", "=", "new", "StreamResult", "(", "out", ")", ";", "// Use a t...
Write an HTML document to an output stream. @param htmldoc Document to output @param out Stream to write to @throws IOException thrown on IO errors
[ "Write", "an", "HTML", "document", "to", "an", "output", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/HTMLUtil.java#L267-L284
train
elki-project/elki
elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/HTMLUtil.java
HTMLUtil.appendMultilineText
public static Element appendMultilineText(Document htmldoc, Element parent, String text) { String[] parts = text != null ? text.split("\n") : null; if(parts == null || parts.length == 0) { return parent; } parent.appendChild(htmldoc.createTextNode(parts[0])); for(int i = 1; i < parts.length; i++) { parent.appendChild(htmldoc.createElement(HTML_BR_TAG)); parent.appendChild(htmldoc.createTextNode(parts[i])); } return parent; }
java
public static Element appendMultilineText(Document htmldoc, Element parent, String text) { String[] parts = text != null ? text.split("\n") : null; if(parts == null || parts.length == 0) { return parent; } parent.appendChild(htmldoc.createTextNode(parts[0])); for(int i = 1; i < parts.length; i++) { parent.appendChild(htmldoc.createElement(HTML_BR_TAG)); parent.appendChild(htmldoc.createTextNode(parts[i])); } return parent; }
[ "public", "static", "Element", "appendMultilineText", "(", "Document", "htmldoc", ",", "Element", "parent", ",", "String", "text", ")", "{", "String", "[", "]", "parts", "=", "text", "!=", "null", "?", "text", ".", "split", "(", "\"\\n\"", ")", ":", "nul...
Append a multiline text to a node, transforming linewraps into BR tags. @param htmldoc Document @param parent Parent node @param text Text to add. @return parent node
[ "Append", "a", "multiline", "text", "to", "a", "node", "transforming", "linewraps", "into", "BR", "tags", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-docutil/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/HTMLUtil.java#L294-L305
train
elki-project/elki
elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTreePath.java
IndexTreePath.getPathCount
public int getPathCount() { int result = 0; for(IndexTreePath<E> path = this; path != null; path = path.parentPath) { result++; } return result; }
java
public int getPathCount() { int result = 0; for(IndexTreePath<E> path = this; path != null; path = path.parentPath) { result++; } return result; }
[ "public", "int", "getPathCount", "(", ")", "{", "int", "result", "=", "0", ";", "for", "(", "IndexTreePath", "<", "E", ">", "path", "=", "this", ";", "path", "!=", "null", ";", "path", "=", "path", ".", "parentPath", ")", "{", "result", "++", ";", ...
Returns the number of elements in the path. @return an int giving a count of items the path
[ "Returns", "the", "number", "of", "elements", "in", "the", "path", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTreePath.java#L91-L97
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/clustering/CBLOF.java
CBLOF.run
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress("CBLOF", 3) : null; DBIDs ids = relation.getDBIDs(); LOG.beginStep(stepprog, 1, "Computing clustering."); Clustering<MeanModel> clustering = clusteringAlgorithm.run(database); LOG.beginStep(stepprog, 2, "Computing boundary between large and small clusters."); List<? extends Cluster<MeanModel>> clusters = clustering.getAllClusters(); Collections.sort(clusters, new Comparator<Cluster<MeanModel>>() { @Override public int compare(Cluster<MeanModel> o1, Cluster<MeanModel> o2) { // Sort in descending order by size return Integer.compare(o2.size(), o1.size()); } }); int clusterBoundary = getClusterBoundary(relation, clusters); List<? extends Cluster<MeanModel>> largeClusters = clusters.subList(0, clusterBoundary + 1); List<? extends Cluster<MeanModel>> smallClusters = clusters.subList(clusterBoundary + 1, clusters.size()); LOG.beginStep(stepprog, 3, "Computing Cluster-Based Local Outlier Factors (CBLOF)."); WritableDoubleDataStore cblofs = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); DoubleMinMax cblofMinMax = new DoubleMinMax(); computeCBLOFs(relation, distance, cblofs, cblofMinMax, largeClusters, smallClusters); LOG.setCompleted(stepprog); DoubleRelation scoreResult = new MaterializedDoubleRelation("Cluster-Based Local Outlier Factor", "cblof-outlier", cblofs, ids); OutlierScoreMeta scoreMeta = new QuotientOutlierScoreMeta(cblofMinMax.getMin(), cblofMinMax.getMax(), 0.0, Double.POSITIVE_INFINITY, 1.0); return new OutlierResult(scoreMeta, scoreResult); }
java
public OutlierResult run(Database database, Relation<O> relation) { StepProgress stepprog = LOG.isVerbose() ? new StepProgress("CBLOF", 3) : null; DBIDs ids = relation.getDBIDs(); LOG.beginStep(stepprog, 1, "Computing clustering."); Clustering<MeanModel> clustering = clusteringAlgorithm.run(database); LOG.beginStep(stepprog, 2, "Computing boundary between large and small clusters."); List<? extends Cluster<MeanModel>> clusters = clustering.getAllClusters(); Collections.sort(clusters, new Comparator<Cluster<MeanModel>>() { @Override public int compare(Cluster<MeanModel> o1, Cluster<MeanModel> o2) { // Sort in descending order by size return Integer.compare(o2.size(), o1.size()); } }); int clusterBoundary = getClusterBoundary(relation, clusters); List<? extends Cluster<MeanModel>> largeClusters = clusters.subList(0, clusterBoundary + 1); List<? extends Cluster<MeanModel>> smallClusters = clusters.subList(clusterBoundary + 1, clusters.size()); LOG.beginStep(stepprog, 3, "Computing Cluster-Based Local Outlier Factors (CBLOF)."); WritableDoubleDataStore cblofs = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB); DoubleMinMax cblofMinMax = new DoubleMinMax(); computeCBLOFs(relation, distance, cblofs, cblofMinMax, largeClusters, smallClusters); LOG.setCompleted(stepprog); DoubleRelation scoreResult = new MaterializedDoubleRelation("Cluster-Based Local Outlier Factor", "cblof-outlier", cblofs, ids); OutlierScoreMeta scoreMeta = new QuotientOutlierScoreMeta(cblofMinMax.getMin(), cblofMinMax.getMax(), 0.0, Double.POSITIVE_INFINITY, 1.0); return new OutlierResult(scoreMeta, scoreResult); }
[ "public", "OutlierResult", "run", "(", "Database", "database", ",", "Relation", "<", "O", ">", "relation", ")", "{", "StepProgress", "stepprog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "StepProgress", "(", "\"CBLOF\"", ",", "3", ")", ":", "nu...
Runs the CBLOF algorithm on the given database. @param database Database to query @param relation Data to process @return CBLOF outlier result
[ "Runs", "the", "CBLOF", "algorithm", "on", "the", "given", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/clustering/CBLOF.java#L150-L181
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/clustering/CBLOF.java
CBLOF.getClusterBoundary
private int getClusterBoundary(Relation<O> relation, List<? extends Cluster<MeanModel>> clusters) { int totalSize = relation.size(); int clusterBoundary = clusters.size() - 1; int cumulativeSize = 0; for(int i = 0; i < clusters.size() - 1; i++) { cumulativeSize += clusters.get(i).size(); // Given majority covered by large cluster if(cumulativeSize >= totalSize * alpha) { clusterBoundary = i; break; } // Relative difference in cluster size between two consecutive clusters if(clusters.get(i).size() / (double) clusters.get(i + 1).size() >= beta) { clusterBoundary = i; break; } } return clusterBoundary; }
java
private int getClusterBoundary(Relation<O> relation, List<? extends Cluster<MeanModel>> clusters) { int totalSize = relation.size(); int clusterBoundary = clusters.size() - 1; int cumulativeSize = 0; for(int i = 0; i < clusters.size() - 1; i++) { cumulativeSize += clusters.get(i).size(); // Given majority covered by large cluster if(cumulativeSize >= totalSize * alpha) { clusterBoundary = i; break; } // Relative difference in cluster size between two consecutive clusters if(clusters.get(i).size() / (double) clusters.get(i + 1).size() >= beta) { clusterBoundary = i; break; } } return clusterBoundary; }
[ "private", "int", "getClusterBoundary", "(", "Relation", "<", "O", ">", "relation", ",", "List", "<", "?", "extends", "Cluster", "<", "MeanModel", ">", ">", "clusters", ")", "{", "int", "totalSize", "=", "relation", ".", "size", "(", ")", ";", "int", "...
Compute the boundary index separating the large cluster from the small cluster. @param relation Data to process @param clusters All clusters that were found @return Index of boundary between large and small cluster.
[ "Compute", "the", "boundary", "index", "separating", "the", "large", "cluster", "from", "the", "small", "cluster", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/clustering/CBLOF.java#L191-L211
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/clustering/CBLOF.java
CBLOF.computeCBLOFs
private void computeCBLOFs(Relation<O> relation, NumberVectorDistanceFunction<? super O> distance, WritableDoubleDataStore cblofs, DoubleMinMax cblofMinMax, List<? extends Cluster<MeanModel>> largeClusters, List<? extends Cluster<MeanModel>> smallClusters) { List<NumberVector> largeClusterMeans = new ArrayList<>(largeClusters.size()); for(Cluster<MeanModel> largeCluster : largeClusters) { NumberVector mean = ModelUtil.getPrototypeOrCentroid(largeCluster.getModel(), relation, largeCluster.getIDs()); largeClusterMeans.add(mean); // Compute CBLOF scores for members of large clusters for(DBIDIter iter = largeCluster.getIDs().iter(); iter.valid(); iter.advance()) { double cblof = computeLargeClusterCBLOF(relation.get(iter), distance, mean, largeCluster); storeCBLOFScore(cblofs, cblofMinMax, cblof, iter); } } for(Cluster<MeanModel> smallCluster : smallClusters) { for(DBIDIter iter = smallCluster.getIDs().iter(); iter.valid(); iter.advance()) { double cblof = computeSmallClusterCBLOF(relation.get(iter), distance, largeClusterMeans, smallCluster); storeCBLOFScore(cblofs, cblofMinMax, cblof, iter); } } }
java
private void computeCBLOFs(Relation<O> relation, NumberVectorDistanceFunction<? super O> distance, WritableDoubleDataStore cblofs, DoubleMinMax cblofMinMax, List<? extends Cluster<MeanModel>> largeClusters, List<? extends Cluster<MeanModel>> smallClusters) { List<NumberVector> largeClusterMeans = new ArrayList<>(largeClusters.size()); for(Cluster<MeanModel> largeCluster : largeClusters) { NumberVector mean = ModelUtil.getPrototypeOrCentroid(largeCluster.getModel(), relation, largeCluster.getIDs()); largeClusterMeans.add(mean); // Compute CBLOF scores for members of large clusters for(DBIDIter iter = largeCluster.getIDs().iter(); iter.valid(); iter.advance()) { double cblof = computeLargeClusterCBLOF(relation.get(iter), distance, mean, largeCluster); storeCBLOFScore(cblofs, cblofMinMax, cblof, iter); } } for(Cluster<MeanModel> smallCluster : smallClusters) { for(DBIDIter iter = smallCluster.getIDs().iter(); iter.valid(); iter.advance()) { double cblof = computeSmallClusterCBLOF(relation.get(iter), distance, largeClusterMeans, smallCluster); storeCBLOFScore(cblofs, cblofMinMax, cblof, iter); } } }
[ "private", "void", "computeCBLOFs", "(", "Relation", "<", "O", ">", "relation", ",", "NumberVectorDistanceFunction", "<", "?", "super", "O", ">", "distance", ",", "WritableDoubleDataStore", "cblofs", ",", "DoubleMinMax", "cblofMinMax", ",", "List", "<", "?", "ex...
Compute the CBLOF scores for all the data. @param relation Data to process @param distance The distance function @param cblofs CBLOF scores @param cblofMinMax Minimum/maximum score tracker @param largeClusters Large clusters output @param smallClusters Small clusters output
[ "Compute", "the", "CBLOF", "scores", "for", "all", "the", "data", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/clustering/CBLOF.java#L223-L242
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.loadXMLSpecification
private GeneratorMain loadXMLSpecification() { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); URL url = ClassLoader.getSystemResource(GENERATOR_SCHEMA_FILE); if(url != null) { try { Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(url); dbf.setSchema(schema); dbf.setIgnoringElementContentWhitespace(true); } catch(Exception e) { LOG.warning("Could not set up XML Schema validation for specification file.", e); } } else { LOG.warning("Could not set up XML Schema validation for specification file."); } Document doc = dbf.newDocumentBuilder().parse(specfile); Node root = doc.getDocumentElement(); if(TAG_DATASET.equals(root.getNodeName())) { GeneratorMain gen = new GeneratorMain(); processElementDataset(gen, root); return gen; } else { throw new AbortException("Experiment specification has incorrect document element: " + root.getNodeName()); } } catch(FileNotFoundException e) { throw new AbortException("Can't open specification file.", e); } catch(SAXException e) { throw new AbortException("Error parsing specification file.", e); } catch(IOException e) { throw new AbortException("IO Exception loading specification file.", e); } catch(ParserConfigurationException e) { throw new AbortException("Parser Configuration Error", e); } }
java
private GeneratorMain loadXMLSpecification() { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); URL url = ClassLoader.getSystemResource(GENERATOR_SCHEMA_FILE); if(url != null) { try { Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(url); dbf.setSchema(schema); dbf.setIgnoringElementContentWhitespace(true); } catch(Exception e) { LOG.warning("Could not set up XML Schema validation for specification file.", e); } } else { LOG.warning("Could not set up XML Schema validation for specification file."); } Document doc = dbf.newDocumentBuilder().parse(specfile); Node root = doc.getDocumentElement(); if(TAG_DATASET.equals(root.getNodeName())) { GeneratorMain gen = new GeneratorMain(); processElementDataset(gen, root); return gen; } else { throw new AbortException("Experiment specification has incorrect document element: " + root.getNodeName()); } } catch(FileNotFoundException e) { throw new AbortException("Can't open specification file.", e); } catch(SAXException e) { throw new AbortException("Error parsing specification file.", e); } catch(IOException e) { throw new AbortException("IO Exception loading specification file.", e); } catch(ParserConfigurationException e) { throw new AbortException("Parser Configuration Error", e); } }
[ "private", "GeneratorMain", "loadXMLSpecification", "(", ")", "{", "try", "{", "DocumentBuilderFactory", "dbf", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "dbf", ".", "setFeature", "(", "\"http://apache.org/xml/features/nonvalidating/load-external-dtd...
Load the XML configuration file. @return Generator
[ "Load", "the", "XML", "configuration", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L245-L286
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementDataset
private void processElementDataset(GeneratorMain gen, Node cur) { // *** get parameters String seedstr = ((Element) cur).getAttribute(ATTR_SEED); if(clusterRandom != RandomFactory.DEFAULT && seedstr != null && seedstr.length() > 0) { clusterRandom = new RandomFactory((long) (ParseUtil.parseIntBase10(seedstr) * sizescale)); } String testmod = ((Element) cur).getAttribute(ATTR_TEST); if(testmod != null && testmod.length() > 0) { testAgainstModel = Boolean.valueOf(ParseUtil.parseIntBase10(testmod) != 0); } // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(TAG_CLUSTER.equals(child.getNodeName())) { processElementCluster(gen, child); } else if(TAG_STATIC.equals(child.getNodeName())) { processElementStatic(gen, child); } else if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
java
private void processElementDataset(GeneratorMain gen, Node cur) { // *** get parameters String seedstr = ((Element) cur).getAttribute(ATTR_SEED); if(clusterRandom != RandomFactory.DEFAULT && seedstr != null && seedstr.length() > 0) { clusterRandom = new RandomFactory((long) (ParseUtil.parseIntBase10(seedstr) * sizescale)); } String testmod = ((Element) cur).getAttribute(ATTR_TEST); if(testmod != null && testmod.length() > 0) { testAgainstModel = Boolean.valueOf(ParseUtil.parseIntBase10(testmod) != 0); } // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(TAG_CLUSTER.equals(child.getNodeName())) { processElementCluster(gen, child); } else if(TAG_STATIC.equals(child.getNodeName())) { processElementStatic(gen, child); } else if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
[ "private", "void", "processElementDataset", "(", "GeneratorMain", "gen", ",", "Node", "cur", ")", "{", "// *** get parameters", "String", "seedstr", "=", "(", "(", "Element", ")", "cur", ")", ".", "getAttribute", "(", "ATTR_SEED", ")", ";", "if", "(", "clust...
Process a 'dataset' Element in the XML stream. @param gen Generator @param cur Current document nod
[ "Process", "a", "dataset", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L294-L318
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementCluster
private void processElementCluster(GeneratorMain gen, Node cur) { int size = -1; double overweight = 1.0; String sizestr = ((Element) cur).getAttribute(ATTR_SIZE); if(sizestr != null && sizestr.length() > 0) { size = (int) (ParseUtil.parseIntBase10(sizestr) * sizescale); } String name = ((Element) cur).getAttribute(ATTR_NAME); String dcostr = ((Element) cur).getAttribute(ATTR_DENSITY); if(dcostr != null && dcostr.length() > 0) { overweight = ParseUtil.parseDouble(dcostr); } if(size < 0) { throw new AbortException("No valid cluster size given in specification file."); } if(name == null || name.length() == 0) { throw new AbortException("No cluster name given in specification file."); } // *** add new cluster object Random newRand = clusterRandom.getSingleThreadedRandom(); GeneratorSingleCluster cluster = new GeneratorSingleCluster(name, size, overweight, newRand); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(TAG_UNIFORM.equals(child.getNodeName())) { processElementUniform(cluster, child); } else if(TAG_NORMAL.equals(child.getNodeName())) { processElementNormal(cluster, child); } else if(TAG_GAMMA.equals(child.getNodeName())) { processElementGamma(cluster, child); } else if(TAG_HALTON.equals(child.getNodeName())) { processElementHalton(cluster, child); } else if(TAG_ROTATE.equals(child.getNodeName())) { processElementRotate(cluster, child); } else if(TAG_TRANSLATE.equals(child.getNodeName())) { processElementTranslate(cluster, child); } else if(TAG_CLIP.equals(child.getNodeName())) { processElementClipping(cluster, child); } else if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } gen.addCluster(cluster); }
java
private void processElementCluster(GeneratorMain gen, Node cur) { int size = -1; double overweight = 1.0; String sizestr = ((Element) cur).getAttribute(ATTR_SIZE); if(sizestr != null && sizestr.length() > 0) { size = (int) (ParseUtil.parseIntBase10(sizestr) * sizescale); } String name = ((Element) cur).getAttribute(ATTR_NAME); String dcostr = ((Element) cur).getAttribute(ATTR_DENSITY); if(dcostr != null && dcostr.length() > 0) { overweight = ParseUtil.parseDouble(dcostr); } if(size < 0) { throw new AbortException("No valid cluster size given in specification file."); } if(name == null || name.length() == 0) { throw new AbortException("No cluster name given in specification file."); } // *** add new cluster object Random newRand = clusterRandom.getSingleThreadedRandom(); GeneratorSingleCluster cluster = new GeneratorSingleCluster(name, size, overweight, newRand); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(TAG_UNIFORM.equals(child.getNodeName())) { processElementUniform(cluster, child); } else if(TAG_NORMAL.equals(child.getNodeName())) { processElementNormal(cluster, child); } else if(TAG_GAMMA.equals(child.getNodeName())) { processElementGamma(cluster, child); } else if(TAG_HALTON.equals(child.getNodeName())) { processElementHalton(cluster, child); } else if(TAG_ROTATE.equals(child.getNodeName())) { processElementRotate(cluster, child); } else if(TAG_TRANSLATE.equals(child.getNodeName())) { processElementTranslate(cluster, child); } else if(TAG_CLIP.equals(child.getNodeName())) { processElementClipping(cluster, child); } else if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } gen.addCluster(cluster); }
[ "private", "void", "processElementCluster", "(", "GeneratorMain", "gen", ",", "Node", "cur", ")", "{", "int", "size", "=", "-", "1", ";", "double", "overweight", "=", "1.0", ";", "String", "sizestr", "=", "(", "(", "Element", ")", "cur", ")", ".", "get...
Process a 'cluster' Element in the XML stream. @param gen Generator @param cur Current document nod
[ "Process", "a", "cluster", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L326-L384
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementUniform
private void processElementUniform(GeneratorSingleCluster cluster, Node cur) { double min = 0.0; double max = 1.0; String minstr = ((Element) cur).getAttribute(ATTR_MIN); if(minstr != null && minstr.length() > 0) { min = ParseUtil.parseDouble(minstr); } String maxstr = ((Element) cur).getAttribute(ATTR_MAX); if(maxstr != null && maxstr.length() > 0) { max = ParseUtil.parseDouble(maxstr); } // *** new uniform generator Random random = cluster.getNewRandomGenerator(); Distribution generator = new UniformDistribution(min, max, random); cluster.addGenerator(generator); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
java
private void processElementUniform(GeneratorSingleCluster cluster, Node cur) { double min = 0.0; double max = 1.0; String minstr = ((Element) cur).getAttribute(ATTR_MIN); if(minstr != null && minstr.length() > 0) { min = ParseUtil.parseDouble(minstr); } String maxstr = ((Element) cur).getAttribute(ATTR_MAX); if(maxstr != null && maxstr.length() > 0) { max = ParseUtil.parseDouble(maxstr); } // *** new uniform generator Random random = cluster.getNewRandomGenerator(); Distribution generator = new UniformDistribution(min, max, random); cluster.addGenerator(generator); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
[ "private", "void", "processElementUniform", "(", "GeneratorSingleCluster", "cluster", ",", "Node", "cur", ")", "{", "double", "min", "=", "0.0", ";", "double", "max", "=", "1.0", ";", "String", "minstr", "=", "(", "(", "Element", ")", "cur", ")", ".", "g...
Process a 'uniform' Element in the XML stream. @param cluster @param cur Current document nod
[ "Process", "a", "uniform", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L392-L418
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementNormal
private void processElementNormal(GeneratorSingleCluster cluster, Node cur) { double mean = 0.0; double stddev = 1.0; String meanstr = ((Element) cur).getAttribute(ATTR_MEAN); if(meanstr != null && meanstr.length() > 0) { mean = ParseUtil.parseDouble(meanstr); } String stddevstr = ((Element) cur).getAttribute(ATTR_STDDEV); if(stddevstr != null && stddevstr.length() > 0) { stddev = ParseUtil.parseDouble(stddevstr); } // *** New normal distribution generator Random random = cluster.getNewRandomGenerator(); Distribution generator = new NormalDistribution(mean, stddev, random); cluster.addGenerator(generator); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
java
private void processElementNormal(GeneratorSingleCluster cluster, Node cur) { double mean = 0.0; double stddev = 1.0; String meanstr = ((Element) cur).getAttribute(ATTR_MEAN); if(meanstr != null && meanstr.length() > 0) { mean = ParseUtil.parseDouble(meanstr); } String stddevstr = ((Element) cur).getAttribute(ATTR_STDDEV); if(stddevstr != null && stddevstr.length() > 0) { stddev = ParseUtil.parseDouble(stddevstr); } // *** New normal distribution generator Random random = cluster.getNewRandomGenerator(); Distribution generator = new NormalDistribution(mean, stddev, random); cluster.addGenerator(generator); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
[ "private", "void", "processElementNormal", "(", "GeneratorSingleCluster", "cluster", ",", "Node", "cur", ")", "{", "double", "mean", "=", "0.0", ";", "double", "stddev", "=", "1.0", ";", "String", "meanstr", "=", "(", "(", "Element", ")", "cur", ")", ".", ...
Process a 'normal' Element in the XML stream. @param cluster @param cur Current document nod
[ "Process", "a", "normal", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L426-L451
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementGamma
private void processElementGamma(GeneratorSingleCluster cluster, Node cur) { double k = 1.0; double theta = 1.0; String kstr = ((Element) cur).getAttribute(ATTR_K); if(kstr != null && kstr.length() > 0) { k = ParseUtil.parseDouble(kstr); } String thetastr = ((Element) cur).getAttribute(ATTR_THETA); if(thetastr != null && thetastr.length() > 0) { theta = ParseUtil.parseDouble(thetastr); } // *** New normal distribution generator Random random = cluster.getNewRandomGenerator(); Distribution generator = new GammaDistribution(k, theta, random); cluster.addGenerator(generator); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
java
private void processElementGamma(GeneratorSingleCluster cluster, Node cur) { double k = 1.0; double theta = 1.0; String kstr = ((Element) cur).getAttribute(ATTR_K); if(kstr != null && kstr.length() > 0) { k = ParseUtil.parseDouble(kstr); } String thetastr = ((Element) cur).getAttribute(ATTR_THETA); if(thetastr != null && thetastr.length() > 0) { theta = ParseUtil.parseDouble(thetastr); } // *** New normal distribution generator Random random = cluster.getNewRandomGenerator(); Distribution generator = new GammaDistribution(k, theta, random); cluster.addGenerator(generator); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
[ "private", "void", "processElementGamma", "(", "GeneratorSingleCluster", "cluster", ",", "Node", "cur", ")", "{", "double", "k", "=", "1.0", ";", "double", "theta", "=", "1.0", ";", "String", "kstr", "=", "(", "(", "Element", ")", "cur", ")", ".", "getAt...
Process a 'gamma' Element in the XML stream. @param cluster @param cur Current document nod
[ "Process", "a", "gamma", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L459-L484
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementRotate
private void processElementRotate(GeneratorSingleCluster cluster, Node cur) { int axis1 = 0; int axis2 = 0; double angle = 0.0; String a1str = ((Element) cur).getAttribute(ATTR_AXIS1); if(a1str != null && a1str.length() > 0) { axis1 = ParseUtil.parseIntBase10(a1str); } String a2str = ((Element) cur).getAttribute(ATTR_AXIS2); if(a2str != null && a2str.length() > 0) { axis2 = ParseUtil.parseIntBase10(a2str); } String anstr = ((Element) cur).getAttribute(ATTR_ANGLE); if(anstr != null && anstr.length() > 0) { angle = ParseUtil.parseDouble(anstr); } if(axis1 <= 0 || axis1 > cluster.getDim()) { throw new AbortException("Invalid axis1 number given in specification file."); } if(axis2 <= 0 || axis2 > cluster.getDim()) { throw new AbortException("Invalid axis2 number given in specification file."); } if(axis1 == axis2) { throw new AbortException("Invalid axis numbers given in specification file."); } // Add rotation to cluster. cluster.addRotation(axis1 - 1, axis2 - 1, Math.toRadians(angle)); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
java
private void processElementRotate(GeneratorSingleCluster cluster, Node cur) { int axis1 = 0; int axis2 = 0; double angle = 0.0; String a1str = ((Element) cur).getAttribute(ATTR_AXIS1); if(a1str != null && a1str.length() > 0) { axis1 = ParseUtil.parseIntBase10(a1str); } String a2str = ((Element) cur).getAttribute(ATTR_AXIS2); if(a2str != null && a2str.length() > 0) { axis2 = ParseUtil.parseIntBase10(a2str); } String anstr = ((Element) cur).getAttribute(ATTR_ANGLE); if(anstr != null && anstr.length() > 0) { angle = ParseUtil.parseDouble(anstr); } if(axis1 <= 0 || axis1 > cluster.getDim()) { throw new AbortException("Invalid axis1 number given in specification file."); } if(axis2 <= 0 || axis2 > cluster.getDim()) { throw new AbortException("Invalid axis2 number given in specification file."); } if(axis1 == axis2) { throw new AbortException("Invalid axis numbers given in specification file."); } // Add rotation to cluster. cluster.addRotation(axis1 - 1, axis2 - 1, Math.toRadians(angle)); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
[ "private", "void", "processElementRotate", "(", "GeneratorSingleCluster", "cluster", ",", "Node", "cur", ")", "{", "int", "axis1", "=", "0", ";", "int", "axis2", "=", "0", ";", "double", "angle", "=", "0.0", ";", "String", "a1str", "=", "(", "(", "Elemen...
Process a 'rotate' Element in the XML stream. @param cluster @param cur Current document nod
[ "Process", "a", "rotate", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L526-L564
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementTranslate
private void processElementTranslate(GeneratorSingleCluster cluster, Node cur) { double[] offset = null; String vstr = ((Element) cur).getAttribute(ATTR_VECTOR); if(vstr != null && vstr.length() > 0) { offset = parseVector(vstr); } if(offset == null) { throw new AbortException("No translation vector given."); } // *** add new translation cluster.addTranslation(offset); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
java
private void processElementTranslate(GeneratorSingleCluster cluster, Node cur) { double[] offset = null; String vstr = ((Element) cur).getAttribute(ATTR_VECTOR); if(vstr != null && vstr.length() > 0) { offset = parseVector(vstr); } if(offset == null) { throw new AbortException("No translation vector given."); } // *** add new translation cluster.addTranslation(offset); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
[ "private", "void", "processElementTranslate", "(", "GeneratorSingleCluster", "cluster", ",", "Node", "cur", ")", "{", "double", "[", "]", "offset", "=", "null", ";", "String", "vstr", "=", "(", "(", "Element", ")", "cur", ")", ".", "getAttribute", "(", "AT...
Process a 'translate' Element in the XML stream. @param cluster @param cur Current document nod
[ "Process", "a", "translate", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L572-L593
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementClipping
private void processElementClipping(GeneratorSingleCluster cluster, Node cur) { double[] cmin = null, cmax = null; String minstr = ((Element) cur).getAttribute(ATTR_MIN); if(minstr != null && minstr.length() > 0) { cmin = parseVector(minstr); } String maxstr = ((Element) cur).getAttribute(ATTR_MAX); if(maxstr != null && maxstr.length() > 0) { cmax = parseVector(maxstr); } if(cmin == null || cmax == null) { throw new AbortException("No or incomplete clipping vectors given."); } // *** set clipping cluster.setClipping(cmin, cmax); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
java
private void processElementClipping(GeneratorSingleCluster cluster, Node cur) { double[] cmin = null, cmax = null; String minstr = ((Element) cur).getAttribute(ATTR_MIN); if(minstr != null && minstr.length() > 0) { cmin = parseVector(minstr); } String maxstr = ((Element) cur).getAttribute(ATTR_MAX); if(maxstr != null && maxstr.length() > 0) { cmax = parseVector(maxstr); } if(cmin == null || cmax == null) { throw new AbortException("No or incomplete clipping vectors given."); } // *** set clipping cluster.setClipping(cmin, cmax); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } }
[ "private", "void", "processElementClipping", "(", "GeneratorSingleCluster", "cluster", ",", "Node", "cur", ")", "{", "double", "[", "]", "cmin", "=", "null", ",", "cmax", "=", "null", ";", "String", "minstr", "=", "(", "(", "Element", ")", "cur", ")", "....
Process a 'clipping' Element in the XML stream. @param cluster @param cur Current document nod
[ "Process", "a", "clipping", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L601-L627
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.processElementStatic
private void processElementStatic(GeneratorMain gen, Node cur) { String name = ((Element) cur).getAttribute(ATTR_NAME); if(name == null) { throw new AbortException("No cluster name given in specification file."); } ArrayList<double[]> points = new ArrayList<>(); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(TAG_POINT.equals(child.getNodeName())) { processElementPoint(points, child); } else if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } // *** add new cluster object GeneratorStatic cluster = new GeneratorStatic(name, points); gen.addCluster(cluster); if(LOG.isVerbose()) { LOG.verbose("Loaded cluster " + cluster.name + " from specification."); } }
java
private void processElementStatic(GeneratorMain gen, Node cur) { String name = ((Element) cur).getAttribute(ATTR_NAME); if(name == null) { throw new AbortException("No cluster name given in specification file."); } ArrayList<double[]> points = new ArrayList<>(); // TODO: check for unknown attributes. XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild()); while(iter.hasNext()) { Node child = iter.next(); if(TAG_POINT.equals(child.getNodeName())) { processElementPoint(points, child); } else if(child.getNodeType() == Node.ELEMENT_NODE) { LOG.warning("Unknown element in XML specification file: " + child.getNodeName()); } } // *** add new cluster object GeneratorStatic cluster = new GeneratorStatic(name, points); gen.addCluster(cluster); if(LOG.isVerbose()) { LOG.verbose("Loaded cluster " + cluster.name + " from specification."); } }
[ "private", "void", "processElementStatic", "(", "GeneratorMain", "gen", ",", "Node", "cur", ")", "{", "String", "name", "=", "(", "(", "Element", ")", "cur", ")", ".", "getAttribute", "(", "ATTR_NAME", ")", ";", "if", "(", "name", "==", "null", ")", "{...
Process a 'static' cluster Element in the XML stream. @param gen Generator @param cur Current document nod
[ "Process", "a", "static", "cluster", "Element", "in", "the", "XML", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L635-L660
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java
GeneratorXMLDatabaseConnection.parseVector
private double[] parseVector(String s) { String[] entries = WHITESPACE_PATTERN.split(s); double[] d = new double[entries.length]; for(int i = 0; i < entries.length; i++) { try { d[i] = ParseUtil.parseDouble(entries[i]); } catch(NumberFormatException e) { throw new AbortException("Could not parse vector."); } } return d; }
java
private double[] parseVector(String s) { String[] entries = WHITESPACE_PATTERN.split(s); double[] d = new double[entries.length]; for(int i = 0; i < entries.length; i++) { try { d[i] = ParseUtil.parseDouble(entries[i]); } catch(NumberFormatException e) { throw new AbortException("Could not parse vector."); } } return d; }
[ "private", "double", "[", "]", "parseVector", "(", "String", "s", ")", "{", "String", "[", "]", "entries", "=", "WHITESPACE_PATTERN", ".", "split", "(", "s", ")", ";", "double", "[", "]", "d", "=", "new", "double", "[", "entries", ".", "length", "]",...
Parse a string into a vector. TODO: move this into utility package? @param s String to parse @return Vector
[ "Parse", "a", "string", "into", "a", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/datasource/GeneratorXMLDatabaseConnection.java#L699-L711
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/data/model/ModelUtil.java
ModelUtil.getPrototype
public static NumberVector getPrototype(Model model, Relation<? extends NumberVector> relation) { // Mean model contains a numeric Vector if(model instanceof MeanModel) { return DoubleVector.wrap(((MeanModel) model).getMean()); } // Handle medoid models if(model instanceof MedoidModel) { return relation.get(((MedoidModel) model).getMedoid()); } if(model instanceof PrototypeModel) { Object p = ((PrototypeModel<?>) model).getPrototype(); if(p instanceof NumberVector) { return (NumberVector) p; } return null; // Inconvertible } return null; }
java
public static NumberVector getPrototype(Model model, Relation<? extends NumberVector> relation) { // Mean model contains a numeric Vector if(model instanceof MeanModel) { return DoubleVector.wrap(((MeanModel) model).getMean()); } // Handle medoid models if(model instanceof MedoidModel) { return relation.get(((MedoidModel) model).getMedoid()); } if(model instanceof PrototypeModel) { Object p = ((PrototypeModel<?>) model).getPrototype(); if(p instanceof NumberVector) { return (NumberVector) p; } return null; // Inconvertible } return null; }
[ "public", "static", "NumberVector", "getPrototype", "(", "Model", "model", ",", "Relation", "<", "?", "extends", "NumberVector", ">", "relation", ")", "{", "// Mean model contains a numeric Vector", "if", "(", "model", "instanceof", "MeanModel", ")", "{", "return", ...
Get the representative vector for a cluster model. <b>Only representative-based models are supported!</b> {@code null} is returned when the model is not supported! @param model Model @param relation Data relation (for representatives specified per DBID) @return Some {@link NumberVector}, {@code null} if not supported.
[ "Get", "the", "representative", "vector", "for", "a", "cluster", "model", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/data/model/ModelUtil.java#L99-L116
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java
DiSHPreferenceVectorIndex.determinePreferenceVectorByApriori
private long[] determinePreferenceVectorByApriori(Relation<V> relation, ModifiableDBIDs[] neighborIDs, StringBuilder msg) { int dimensionality = neighborIDs.length; // database for apriori UpdatableDatabase apriori_db = new HashmapDatabase(); SimpleTypeInformation<?> bitmeta = VectorFieldTypeInformation.typeRequest(BitVector.class, dimensionality, dimensionality); for(DBIDIter it = relation.iterDBIDs(); it.valid(); it.advance()) { long[] bits = BitsUtil.zero(dimensionality); boolean allFalse = true; for(int d = 0; d < dimensionality; d++) { if(neighborIDs[d].contains(it)) { BitsUtil.setI(bits, d); allFalse = false; } } if(!allFalse) { SingleObjectBundle oaa = new SingleObjectBundle(); oaa.append(bitmeta, new BitVector(bits, dimensionality)); apriori_db.insert(oaa); } } APRIORI apriori = new APRIORI(minpts); FrequentItemsetsResult aprioriResult = apriori.run(apriori_db); // result of apriori List<Itemset> frequentItemsets = aprioriResult.getItemsets(); if(msg != null) { msg.append("\n Frequent itemsets: ").append(frequentItemsets); } int maxSupport = 0, maxCardinality = 0; long[] preferenceVector = BitsUtil.zero(dimensionality); for(Itemset itemset : frequentItemsets) { if((maxCardinality < itemset.length()) || (maxCardinality == itemset.length() && maxSupport == itemset.getSupport())) { preferenceVector = Itemset.toBitset(itemset, BitsUtil.zero(dimensionality)); maxCardinality = itemset.length(); maxSupport = itemset.getSupport(); } } if(msg != null) { msg.append("\n preference ") // .append(BitsUtil.toStringLow(preferenceVector, dimensionality)) // .append('\n'); LOG.debugFine(msg.toString()); } return preferenceVector; }
java
private long[] determinePreferenceVectorByApriori(Relation<V> relation, ModifiableDBIDs[] neighborIDs, StringBuilder msg) { int dimensionality = neighborIDs.length; // database for apriori UpdatableDatabase apriori_db = new HashmapDatabase(); SimpleTypeInformation<?> bitmeta = VectorFieldTypeInformation.typeRequest(BitVector.class, dimensionality, dimensionality); for(DBIDIter it = relation.iterDBIDs(); it.valid(); it.advance()) { long[] bits = BitsUtil.zero(dimensionality); boolean allFalse = true; for(int d = 0; d < dimensionality; d++) { if(neighborIDs[d].contains(it)) { BitsUtil.setI(bits, d); allFalse = false; } } if(!allFalse) { SingleObjectBundle oaa = new SingleObjectBundle(); oaa.append(bitmeta, new BitVector(bits, dimensionality)); apriori_db.insert(oaa); } } APRIORI apriori = new APRIORI(minpts); FrequentItemsetsResult aprioriResult = apriori.run(apriori_db); // result of apriori List<Itemset> frequentItemsets = aprioriResult.getItemsets(); if(msg != null) { msg.append("\n Frequent itemsets: ").append(frequentItemsets); } int maxSupport = 0, maxCardinality = 0; long[] preferenceVector = BitsUtil.zero(dimensionality); for(Itemset itemset : frequentItemsets) { if((maxCardinality < itemset.length()) || (maxCardinality == itemset.length() && maxSupport == itemset.getSupport())) { preferenceVector = Itemset.toBitset(itemset, BitsUtil.zero(dimensionality)); maxCardinality = itemset.length(); maxSupport = itemset.getSupport(); } } if(msg != null) { msg.append("\n preference ") // .append(BitsUtil.toStringLow(preferenceVector, dimensionality)) // .append('\n'); LOG.debugFine(msg.toString()); } return preferenceVector; }
[ "private", "long", "[", "]", "determinePreferenceVectorByApriori", "(", "Relation", "<", "V", ">", "relation", ",", "ModifiableDBIDs", "[", "]", "neighborIDs", ",", "StringBuilder", "msg", ")", "{", "int", "dimensionality", "=", "neighborIDs", ".", "length", ";"...
Determines the preference vector with the apriori strategy. @param relation the database storing the objects @param neighborIDs the list of ids of the neighbors in each dimension @param msg a string buffer for debug messages @return the preference vector
[ "Determines", "the", "preference", "vector", "with", "the", "apriori", "strategy", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java#L215-L262
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java
DiSHPreferenceVectorIndex.determinePreferenceVectorByMaxIntersection
private long[] determinePreferenceVectorByMaxIntersection(ModifiableDBIDs[] neighborIDs, StringBuilder msg) { int dimensionality = neighborIDs.length; long[] preferenceVector = BitsUtil.zero(dimensionality); Map<Integer, ModifiableDBIDs> candidates = new HashMap<>(dimensionality); for(int i = 0; i < dimensionality; i++) { ModifiableDBIDs s_i = neighborIDs[i]; if(s_i.size() > minpts) { candidates.put(i, s_i); } } if(msg != null) { msg.append("\n candidates ").append(candidates.keySet()); } if(!candidates.isEmpty()) { int i = max(candidates); ModifiableDBIDs intersection = candidates.remove(i); BitsUtil.setI(preferenceVector, i); while(!candidates.isEmpty()) { i = maxIntersection(candidates, intersection); candidates.remove(i); if(intersection.size() < minpts) { break; } BitsUtil.setI(preferenceVector, i); } } if(msg != null) { msg.append("\n preference ").append(BitsUtil.toStringLow(preferenceVector, dimensionality)); LOG.debug(msg.toString()); } return preferenceVector; }
java
private long[] determinePreferenceVectorByMaxIntersection(ModifiableDBIDs[] neighborIDs, StringBuilder msg) { int dimensionality = neighborIDs.length; long[] preferenceVector = BitsUtil.zero(dimensionality); Map<Integer, ModifiableDBIDs> candidates = new HashMap<>(dimensionality); for(int i = 0; i < dimensionality; i++) { ModifiableDBIDs s_i = neighborIDs[i]; if(s_i.size() > minpts) { candidates.put(i, s_i); } } if(msg != null) { msg.append("\n candidates ").append(candidates.keySet()); } if(!candidates.isEmpty()) { int i = max(candidates); ModifiableDBIDs intersection = candidates.remove(i); BitsUtil.setI(preferenceVector, i); while(!candidates.isEmpty()) { i = maxIntersection(candidates, intersection); candidates.remove(i); if(intersection.size() < minpts) { break; } BitsUtil.setI(preferenceVector, i); } } if(msg != null) { msg.append("\n preference ").append(BitsUtil.toStringLow(preferenceVector, dimensionality)); LOG.debug(msg.toString()); } return preferenceVector; }
[ "private", "long", "[", "]", "determinePreferenceVectorByMaxIntersection", "(", "ModifiableDBIDs", "[", "]", "neighborIDs", ",", "StringBuilder", "msg", ")", "{", "int", "dimensionality", "=", "neighborIDs", ".", "length", ";", "long", "[", "]", "preferenceVector", ...
Determines the preference vector with the max intersection strategy. @param neighborIDs the list of ids of the neighbors in each dimension @param msg a string buffer for debug messages @return the preference vector
[ "Determines", "the", "preference", "vector", "with", "the", "max", "intersection", "strategy", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java#L271-L306
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java
DiSHPreferenceVectorIndex.max
private int max(Map<Integer, ModifiableDBIDs> candidates) { int maxDim = -1, size = -1; for(Integer nextDim : candidates.keySet()) { int nextSet = candidates.get(nextDim).size(); if(size < nextSet) { size = nextSet; maxDim = nextDim; } } return maxDim; }
java
private int max(Map<Integer, ModifiableDBIDs> candidates) { int maxDim = -1, size = -1; for(Integer nextDim : candidates.keySet()) { int nextSet = candidates.get(nextDim).size(); if(size < nextSet) { size = nextSet; maxDim = nextDim; } } return maxDim; }
[ "private", "int", "max", "(", "Map", "<", "Integer", ",", "ModifiableDBIDs", ">", "candidates", ")", "{", "int", "maxDim", "=", "-", "1", ",", "size", "=", "-", "1", ";", "for", "(", "Integer", "nextDim", ":", "candidates", ".", "keySet", "(", ")", ...
Returns the set with the maximum size contained in the specified map. @param candidates the map containing the sets @return the set with the maximum size
[ "Returns", "the", "set", "with", "the", "maximum", "size", "contained", "in", "the", "specified", "map", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java#L314-L324
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java
DiSHPreferenceVectorIndex.maxIntersection
private int maxIntersection(Map<Integer, ModifiableDBIDs> candidates, ModifiableDBIDs set) { int maxDim = -1; ModifiableDBIDs maxIntersection = null; for(Integer nextDim : candidates.keySet()) { DBIDs nextSet = candidates.get(nextDim); ModifiableDBIDs nextIntersection = DBIDUtil.intersection(set, nextSet); if(maxDim < 0 || maxIntersection.size() < nextIntersection.size()) { maxIntersection = nextIntersection; maxDim = nextDim; } } if(maxDim >= 0) { set.clear(); set.addDBIDs(maxIntersection); } return maxDim; }
java
private int maxIntersection(Map<Integer, ModifiableDBIDs> candidates, ModifiableDBIDs set) { int maxDim = -1; ModifiableDBIDs maxIntersection = null; for(Integer nextDim : candidates.keySet()) { DBIDs nextSet = candidates.get(nextDim); ModifiableDBIDs nextIntersection = DBIDUtil.intersection(set, nextSet); if(maxDim < 0 || maxIntersection.size() < nextIntersection.size()) { maxIntersection = nextIntersection; maxDim = nextDim; } } if(maxDim >= 0) { set.clear(); set.addDBIDs(maxIntersection); } return maxDim; }
[ "private", "int", "maxIntersection", "(", "Map", "<", "Integer", ",", "ModifiableDBIDs", ">", "candidates", ",", "ModifiableDBIDs", "set", ")", "{", "int", "maxDim", "=", "-", "1", ";", "ModifiableDBIDs", "maxIntersection", "=", "null", ";", "for", "(", "Int...
Returns the index of the set having the maximum intersection set with the specified set contained in the specified map. @param candidates the map containing the sets @param set the set to intersect with and output the result to @return the set with the maximum size
[ "Returns", "the", "index", "of", "the", "set", "having", "the", "maximum", "intersection", "set", "with", "the", "specified", "set", "contained", "in", "the", "specified", "map", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java#L334-L350
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java
DiSHPreferenceVectorIndex.initRangeQueries
private RangeQuery<V>[] initRangeQueries(Relation<V> relation, int dimensionality) { @SuppressWarnings("unchecked") RangeQuery<V>[] rangeQueries = (RangeQuery<V>[]) new RangeQuery[dimensionality]; for(int d = 0; d < dimensionality; d++) { rangeQueries[d] = relation.getRangeQuery(new PrimitiveDistanceQuery<>(relation, new OnedimensionalDistanceFunction(d))); } return rangeQueries; }
java
private RangeQuery<V>[] initRangeQueries(Relation<V> relation, int dimensionality) { @SuppressWarnings("unchecked") RangeQuery<V>[] rangeQueries = (RangeQuery<V>[]) new RangeQuery[dimensionality]; for(int d = 0; d < dimensionality; d++) { rangeQueries[d] = relation.getRangeQuery(new PrimitiveDistanceQuery<>(relation, new OnedimensionalDistanceFunction(d))); } return rangeQueries; }
[ "private", "RangeQuery", "<", "V", ">", "[", "]", "initRangeQueries", "(", "Relation", "<", "V", ">", "relation", ",", "int", "dimensionality", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "RangeQuery", "<", "V", ">", "[", "]", "rangeQueri...
Initializes the dimension selecting distancefunctions to determine the preference vectors. @param relation the database storing the objects @param dimensionality the dimensionality of the objects @return the dimension selecting distancefunctions to determine the preference vectors
[ "Initializes", "the", "dimension", "selecting", "distancefunctions", "to", "determine", "the", "preference", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/preference/DiSHPreferenceVectorIndex.java#L361-L368
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateConcordantPairs.java
EvaluateConcordantPairs.computeTau
@Reference(authors = "F. J. Rohlf", title = "Methods of comparing classifications", // booktitle = "Annual Review of Ecology and Systematics", // url = "https://doi.org/10.1146/annurev.es.05.110174.000533", // bibkey = "doi:10.1146/annurev.es.05.110174.000533") public double computeTau(long c, long d, double m, long wd, long bd) { double tie = (wd * (wd - 1) + bd * (bd - 1)) >>> 1; return (c - d) / FastMath.sqrt((m - tie) * m); // return (4. * c - m) / m; }
java
@Reference(authors = "F. J. Rohlf", title = "Methods of comparing classifications", // booktitle = "Annual Review of Ecology and Systematics", // url = "https://doi.org/10.1146/annurev.es.05.110174.000533", // bibkey = "doi:10.1146/annurev.es.05.110174.000533") public double computeTau(long c, long d, double m, long wd, long bd) { double tie = (wd * (wd - 1) + bd * (bd - 1)) >>> 1; return (c - d) / FastMath.sqrt((m - tie) * m); // return (4. * c - m) / m; }
[ "@", "Reference", "(", "authors", "=", "\"F. J. Rohlf\"", ",", "title", "=", "\"Methods of comparing classifications\"", ",", "//", "booktitle", "=", "\"Annual Review of Ecology and Systematics\"", ",", "//", "url", "=", "\"https://doi.org/10.1146/annurev.es.05.110174.000533\""...
Compute the Tau correlation measure @param c Concordant pairs @param d Discordant pairs @param m Total number of pairs @param wd Number of within distances @param bd Number of between distances @return Gamma plus statistic
[ "Compute", "the", "Tau", "correlation", "measure" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateConcordantPairs.java#L280-L288
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/application/internal/CheckELKIServices.java
CheckELKIServices.checkServices
public void checkServices(String update) { TreeSet<String> props = new TreeSet<>(); Enumeration<URL> us; try { us = getClass().getClassLoader().getResources(ELKIServiceLoader.RESOURCE_PREFIX); } catch(IOException e) { throw new AbortException("Error enumerating service folders.", e); } while(us.hasMoreElements()) { URL u = us.nextElement(); try { if(("jar".equals(u.getProtocol()))) { JarURLConnection con = (JarURLConnection) u.openConnection(); try (JarFile jar = con.getJarFile()) { Enumeration<JarEntry> entries = jar.entries(); while(entries.hasMoreElements()) { String prop = entries.nextElement().getName(); if(prop.startsWith(ELKIServiceLoader.RESOURCE_PREFIX)) { props.add(prop.substring(ELKIServiceLoader.RESOURCE_PREFIX.length())); } else if(prop.startsWith(ELKIServiceLoader.FILENAME_PREFIX)) { props.add(prop.substring(ELKIServiceLoader.FILENAME_PREFIX.length())); } } } continue; } if("file".equals(u.getProtocol())) { props.addAll(Arrays.asList(new File(u.toURI()).list())); } } catch(IOException | URISyntaxException e) { throw new AbortException("Error enumerating service folders.", e); } } for(String prop : props) { if(LOG.isVerbose()) { LOG.verbose("Checking property: " + prop); } checkService(prop, update); } }
java
public void checkServices(String update) { TreeSet<String> props = new TreeSet<>(); Enumeration<URL> us; try { us = getClass().getClassLoader().getResources(ELKIServiceLoader.RESOURCE_PREFIX); } catch(IOException e) { throw new AbortException("Error enumerating service folders.", e); } while(us.hasMoreElements()) { URL u = us.nextElement(); try { if(("jar".equals(u.getProtocol()))) { JarURLConnection con = (JarURLConnection) u.openConnection(); try (JarFile jar = con.getJarFile()) { Enumeration<JarEntry> entries = jar.entries(); while(entries.hasMoreElements()) { String prop = entries.nextElement().getName(); if(prop.startsWith(ELKIServiceLoader.RESOURCE_PREFIX)) { props.add(prop.substring(ELKIServiceLoader.RESOURCE_PREFIX.length())); } else if(prop.startsWith(ELKIServiceLoader.FILENAME_PREFIX)) { props.add(prop.substring(ELKIServiceLoader.FILENAME_PREFIX.length())); } } } continue; } if("file".equals(u.getProtocol())) { props.addAll(Arrays.asList(new File(u.toURI()).list())); } } catch(IOException | URISyntaxException e) { throw new AbortException("Error enumerating service folders.", e); } } for(String prop : props) { if(LOG.isVerbose()) { LOG.verbose("Checking property: " + prop); } checkService(prop, update); } }
[ "public", "void", "checkServices", "(", "String", "update", ")", "{", "TreeSet", "<", "String", ">", "props", "=", "new", "TreeSet", "<>", "(", ")", ";", "Enumeration", "<", "URL", ">", "us", ";", "try", "{", "us", "=", "getClass", "(", ")", ".", "...
Retrieve all properties and check them. @param update Folder to update service files in
[ "Retrieve", "all", "properties", "and", "check", "them", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/application/internal/CheckELKIServices.java#L96-L139
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/application/internal/CheckELKIServices.java
CheckELKIServices.checkAliases
@SuppressWarnings("unchecked") private void checkAliases(Class<?> parent, String classname, String[] parts) { Class<?> c = ELKIServiceRegistry.findImplementation((Class<Object>) parent, classname); if(c == null) { return; } Alias ann = c.getAnnotation(Alias.class); if(ann == null) { if(parts.length > 1) { StringBuilder buf = new StringBuilder(100) // .append("Class ").append(classname) // .append(" in ").append(parent.getCanonicalName()) // .append(" has the following extraneous aliases:"); for(int i = 1; i < parts.length; i++) { buf.append(' ').append(parts[i]); } LOG.warning(buf); } return; } HashSet<String> aliases = new HashSet<String>(); for(int i = 1; i < parts.length; i++) { aliases.add(parts[i]); } StringBuilder buf = null; for(String a : ann.value()) { if(!aliases.remove(a)) { if(buf == null) { buf = new StringBuilder(100) // .append("Class ").append(classname) // .append(" in ").append(parent.getCanonicalName()) // .append(" is missing the following aliases:"); } buf.append(' ').append(a); } } if(!aliases.isEmpty()) { buf = (buf == null ? new StringBuilder() : buf.append(FormatUtil.NEWLINE)) // .append("Class ").append(classname) // .append(" in ").append(parent.getCanonicalName()) // .append(" has the following extraneous aliases:"); for(String a : aliases) { buf.append(' ').append(a); } } if(buf != null) { LOG.warning(buf); } }
java
@SuppressWarnings("unchecked") private void checkAliases(Class<?> parent, String classname, String[] parts) { Class<?> c = ELKIServiceRegistry.findImplementation((Class<Object>) parent, classname); if(c == null) { return; } Alias ann = c.getAnnotation(Alias.class); if(ann == null) { if(parts.length > 1) { StringBuilder buf = new StringBuilder(100) // .append("Class ").append(classname) // .append(" in ").append(parent.getCanonicalName()) // .append(" has the following extraneous aliases:"); for(int i = 1; i < parts.length; i++) { buf.append(' ').append(parts[i]); } LOG.warning(buf); } return; } HashSet<String> aliases = new HashSet<String>(); for(int i = 1; i < parts.length; i++) { aliases.add(parts[i]); } StringBuilder buf = null; for(String a : ann.value()) { if(!aliases.remove(a)) { if(buf == null) { buf = new StringBuilder(100) // .append("Class ").append(classname) // .append(" in ").append(parent.getCanonicalName()) // .append(" is missing the following aliases:"); } buf.append(' ').append(a); } } if(!aliases.isEmpty()) { buf = (buf == null ? new StringBuilder() : buf.append(FormatUtil.NEWLINE)) // .append("Class ").append(classname) // .append(" in ").append(parent.getCanonicalName()) // .append(" has the following extraneous aliases:"); for(String a : aliases) { buf.append(' ').append(a); } } if(buf != null) { LOG.warning(buf); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "checkAliases", "(", "Class", "<", "?", ">", "parent", ",", "String", "classname", ",", "String", "[", "]", "parts", ")", "{", "Class", "<", "?", ">", "c", "=", "ELKIServiceRegistry", ...
Check if aliases are listed completely. @param parent Parent class @param classname Class name @param parts Splitted sevice line
[ "Check", "if", "aliases", "are", "listed", "completely", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/application/internal/CheckELKIServices.java#L230-L278
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java
CorrelationAnalysisSolution.getNormalizedLinearEquationSystem
public LinearEquationSystem getNormalizedLinearEquationSystem(Normalization<?> normalization) throws NonNumericFeaturesException { if(normalization != null) { LinearEquationSystem lq = normalization.transform(linearEquationSystem); lq.solveByTotalPivotSearch(); return lq; } else { return linearEquationSystem; } }
java
public LinearEquationSystem getNormalizedLinearEquationSystem(Normalization<?> normalization) throws NonNumericFeaturesException { if(normalization != null) { LinearEquationSystem lq = normalization.transform(linearEquationSystem); lq.solveByTotalPivotSearch(); return lq; } else { return linearEquationSystem; } }
[ "public", "LinearEquationSystem", "getNormalizedLinearEquationSystem", "(", "Normalization", "<", "?", ">", "normalization", ")", "throws", "NonNumericFeaturesException", "{", "if", "(", "normalization", "!=", "null", ")", "{", "LinearEquationSystem", "lq", "=", "normal...
Returns the linear equation system for printing purposes. If normalization is null the linear equation system is returned, otherwise the linear equation system will be transformed according to the normalization. @param normalization the normalization, can be null @return the linear equation system for printing purposes @throws NonNumericFeaturesException if the linear equation system is not compatible with values initialized during normalization
[ "Returns", "the", "linear", "equation", "system", "for", "printing", "purposes", ".", "If", "normalization", "is", "null", "the", "linear", "equation", "system", "is", "returned", "otherwise", "the", "linear", "equation", "system", "will", "be", "transformed", "...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java#L163-L172
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java
CorrelationAnalysisSolution.squaredDistance
public double squaredDistance(V p) { // V_affin = V + a // dist(p, V_affin) = d(p-a, V) = ||p - a - proj_V(p-a) || double[] p_minus_a = minusEquals(p.toArray(), centroid); return squareSum(minusEquals(p_minus_a, times(strongEigenvectors, transposeTimes(strongEigenvectors, p_minus_a)))); }
java
public double squaredDistance(V p) { // V_affin = V + a // dist(p, V_affin) = d(p-a, V) = ||p - a - proj_V(p-a) || double[] p_minus_a = minusEquals(p.toArray(), centroid); return squareSum(minusEquals(p_minus_a, times(strongEigenvectors, transposeTimes(strongEigenvectors, p_minus_a)))); }
[ "public", "double", "squaredDistance", "(", "V", "p", ")", "{", "// V_affin = V + a", "// dist(p, V_affin) = d(p-a, V) = ||p - a - proj_V(p-a) ||", "double", "[", "]", "p_minus_a", "=", "minusEquals", "(", "p", ".", "toArray", "(", ")", ",", "centroid", ")", ";", ...
Returns the distance of NumberVector p from the hyperplane underlying this solution. @param p a vector in the space underlying this solution @return the distance of p from the hyperplane underlying this solution
[ "Returns", "the", "distance", "of", "NumberVector", "p", "from", "the", "hyperplane", "underlying", "this", "solution", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java#L190-L195
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java
CorrelationAnalysisSolution.errorVector
public double[] errorVector(V p) { return weakEigenvectors.length > 0 ? times(weakEigenvectors, transposeTimes(weakEigenvectors, minusEquals(p.toArray(), centroid))) : EMPTY_VECTOR; }
java
public double[] errorVector(V p) { return weakEigenvectors.length > 0 ? times(weakEigenvectors, transposeTimes(weakEigenvectors, minusEquals(p.toArray(), centroid))) : EMPTY_VECTOR; }
[ "public", "double", "[", "]", "errorVector", "(", "V", "p", ")", "{", "return", "weakEigenvectors", ".", "length", ">", "0", "?", "times", "(", "weakEigenvectors", ",", "transposeTimes", "(", "weakEigenvectors", ",", "minusEquals", "(", "p", ".", "toArray", ...
Returns the error vectors after projection. @param p a vector in the space underlying this solution @return the error vectors
[ "Returns", "the", "error", "vectors", "after", "projection", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java#L203-L205
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java
CorrelationAnalysisSolution.dataVector
public double[] dataVector(V p) { return strongEigenvectors.length > 0 ? times(strongEigenvectors, transposeTimes(strongEigenvectors, minusEquals(p.toArray(), centroid))) : EMPTY_VECTOR; }
java
public double[] dataVector(V p) { return strongEigenvectors.length > 0 ? times(strongEigenvectors, transposeTimes(strongEigenvectors, minusEquals(p.toArray(), centroid))) : EMPTY_VECTOR; }
[ "public", "double", "[", "]", "dataVector", "(", "V", "p", ")", "{", "return", "strongEigenvectors", ".", "length", ">", "0", "?", "times", "(", "strongEigenvectors", ",", "transposeTimes", "(", "strongEigenvectors", ",", "minusEquals", "(", "p", ".", "toArr...
Returns the data vectors after projection. @param p a vector in the space underlying this solution @return the error vectors
[ "Returns", "the", "data", "vectors", "after", "projection", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java#L213-L215
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java
CorrelationAnalysisSolution.writeToText
@Override public void writeToText(TextWriterStream out, String label) { if(label != null) { out.commentPrintLn(label); } out.commentPrintLn("Model class: " + this.getClass().getName()); try { if(getNormalizedLinearEquationSystem(null) != null) { // TODO: more elegant way of doing normalization here? /* * if(out instanceof TextWriterStreamNormalizing) { * TextWriterStreamNormalizing<V> nout = * (TextWriterStreamNormalizing<V>) out; LinearEquationSystem lq = * getNormalizedLinearEquationSystem(nout.getNormalization()); * out.commentPrint("Linear Equation System: "); * out.commentPrintLn(lq.equationsToString(nf)); } else { */ LinearEquationSystem lq = getNormalizedLinearEquationSystem(null); out.commentPrint("Linear Equation System: "); out.commentPrintLn(lq.equationsToString(nf)); // } } } catch(NonNumericFeaturesException e) { LoggingUtil.exception(e); } }
java
@Override public void writeToText(TextWriterStream out, String label) { if(label != null) { out.commentPrintLn(label); } out.commentPrintLn("Model class: " + this.getClass().getName()); try { if(getNormalizedLinearEquationSystem(null) != null) { // TODO: more elegant way of doing normalization here? /* * if(out instanceof TextWriterStreamNormalizing) { * TextWriterStreamNormalizing<V> nout = * (TextWriterStreamNormalizing<V>) out; LinearEquationSystem lq = * getNormalizedLinearEquationSystem(nout.getNormalization()); * out.commentPrint("Linear Equation System: "); * out.commentPrintLn(lq.equationsToString(nf)); } else { */ LinearEquationSystem lq = getNormalizedLinearEquationSystem(null); out.commentPrint("Linear Equation System: "); out.commentPrintLn(lq.equationsToString(nf)); // } } } catch(NonNumericFeaturesException e) { LoggingUtil.exception(e); } }
[ "@", "Override", "public", "void", "writeToText", "(", "TextWriterStream", "out", ",", "String", "label", ")", "{", "if", "(", "label", "!=", "null", ")", "{", "out", ".", "commentPrintLn", "(", "label", ")", ";", "}", "out", ".", "commentPrintLn", "(", ...
Text output of the equation system
[ "Text", "output", "of", "the", "equation", "system" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/data/model/CorrelationAnalysisSolution.java#L266-L292
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/AbstractStaticHistogram.java
AbstractStaticHistogram.getBinNr
protected int getBinNr(double coord) { if (Double.isInfinite(coord) || Double.isNaN(coord)) { throw new UnsupportedOperationException("Encountered non-finite value in Histogram: " + coord); } if (coord == max) { // System.err.println("Triggered special case: "+ (Math.floor((coord - // base) / binsize) + offset) + " vs. " + (size - 1)); return size - 1; } return (int) Math.floor((coord - base) / binsize) + offset; }
java
protected int getBinNr(double coord) { if (Double.isInfinite(coord) || Double.isNaN(coord)) { throw new UnsupportedOperationException("Encountered non-finite value in Histogram: " + coord); } if (coord == max) { // System.err.println("Triggered special case: "+ (Math.floor((coord - // base) / binsize) + offset) + " vs. " + (size - 1)); return size - 1; } return (int) Math.floor((coord - base) / binsize) + offset; }
[ "protected", "int", "getBinNr", "(", "double", "coord", ")", "{", "if", "(", "Double", ".", "isInfinite", "(", "coord", ")", "||", "Double", ".", "isNaN", "(", "coord", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Encountered non-f...
Compute the bin number. Has a special case for rounding max down to the last bin. @param coord Coordinate @return bin number
[ "Compute", "the", "bin", "number", ".", "Has", "a", "special", "case", "for", "rounding", "max", "down", "to", "the", "last", "bin", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/AbstractStaticHistogram.java#L79-L89
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/AbstractStaticHistogram.java
AbstractStaticHistogram.growSize
protected static int growSize(int current, int requiredSize) { // Double until 64, then increase by 50% each time. int newCapacity = ((current < 64) ? ((current + 1) << 1) : ((current >> 1) * 3)); // overflow? if (newCapacity < 0) { throw new OutOfMemoryError(); } if (requiredSize > newCapacity) { newCapacity = requiredSize; } return requiredSize; }
java
protected static int growSize(int current, int requiredSize) { // Double until 64, then increase by 50% each time. int newCapacity = ((current < 64) ? ((current + 1) << 1) : ((current >> 1) * 3)); // overflow? if (newCapacity < 0) { throw new OutOfMemoryError(); } if (requiredSize > newCapacity) { newCapacity = requiredSize; } return requiredSize; }
[ "protected", "static", "int", "growSize", "(", "int", "current", ",", "int", "requiredSize", ")", "{", "// Double until 64, then increase by 50% each time.", "int", "newCapacity", "=", "(", "(", "current", "<", "64", ")", "?", "(", "(", "current", "+", "1", ")...
Compute the size to grow to. @param current Current size @param requiredSize Required size @return Size to allocate
[ "Compute", "the", "size", "to", "grow", "to", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/AbstractStaticHistogram.java#L98-L109
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java
DeLiClu.expandNodes
private void expandNodes(DeLiCluTree index, SpatialPrimitiveDistanceFunction<V> distFunction, SpatialObjectPair nodePair, DataStore<KNNList> knns) { DeLiCluNode node1 = index.getNode(((SpatialDirectoryEntry) nodePair.entry1).getPageID()); DeLiCluNode node2 = index.getNode(((SpatialDirectoryEntry) nodePair.entry2).getPageID()); if(node1.isLeaf()) { expandLeafNodes(distFunction, node1, node2, knns); } else { expandDirNodes(distFunction, node1, node2); } index.setExpanded(nodePair.entry2, nodePair.entry1); }
java
private void expandNodes(DeLiCluTree index, SpatialPrimitiveDistanceFunction<V> distFunction, SpatialObjectPair nodePair, DataStore<KNNList> knns) { DeLiCluNode node1 = index.getNode(((SpatialDirectoryEntry) nodePair.entry1).getPageID()); DeLiCluNode node2 = index.getNode(((SpatialDirectoryEntry) nodePair.entry2).getPageID()); if(node1.isLeaf()) { expandLeafNodes(distFunction, node1, node2, knns); } else { expandDirNodes(distFunction, node1, node2); } index.setExpanded(nodePair.entry2, nodePair.entry1); }
[ "private", "void", "expandNodes", "(", "DeLiCluTree", "index", ",", "SpatialPrimitiveDistanceFunction", "<", "V", ">", "distFunction", ",", "SpatialObjectPair", "nodePair", ",", "DataStore", "<", "KNNList", ">", "knns", ")", "{", "DeLiCluNode", "node1", "=", "inde...
Expands the spatial nodes of the specified pair. @param index the index storing the objects @param distFunction the spatial distance function of this algorithm @param nodePair the pair of nodes to be expanded @param knns the knn list
[ "Expands", "the", "spatial", "nodes", "of", "the", "specified", "pair", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java#L209-L221
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java
DeLiClu.expandDirNodes
private void expandDirNodes(SpatialPrimitiveDistanceFunction<V> distFunction, DeLiCluNode node1, DeLiCluNode node2) { if(LOG.isDebuggingFinest()) { LOG.debugFinest("ExpandDirNodes: " + node1.getPageID() + " + " + node2.getPageID()); } int numEntries_1 = node1.getNumEntries(); int numEntries_2 = node2.getNumEntries(); // insert all combinations of unhandled - handled children of // node1-node2 into pq for(int i = 0; i < numEntries_1; i++) { DeLiCluEntry entry1 = node1.getEntry(i); if(!entry1.hasUnhandled()) { continue; } for(int j = 0; j < numEntries_2; j++) { DeLiCluEntry entry2 = node2.getEntry(j); if(!entry2.hasHandled()) { continue; } double distance = distFunction.minDist(entry1, entry2); heap.add(new SpatialObjectPair(distance, entry1, entry2, true)); } } }
java
private void expandDirNodes(SpatialPrimitiveDistanceFunction<V> distFunction, DeLiCluNode node1, DeLiCluNode node2) { if(LOG.isDebuggingFinest()) { LOG.debugFinest("ExpandDirNodes: " + node1.getPageID() + " + " + node2.getPageID()); } int numEntries_1 = node1.getNumEntries(); int numEntries_2 = node2.getNumEntries(); // insert all combinations of unhandled - handled children of // node1-node2 into pq for(int i = 0; i < numEntries_1; i++) { DeLiCluEntry entry1 = node1.getEntry(i); if(!entry1.hasUnhandled()) { continue; } for(int j = 0; j < numEntries_2; j++) { DeLiCluEntry entry2 = node2.getEntry(j); if(!entry2.hasHandled()) { continue; } double distance = distFunction.minDist(entry1, entry2); heap.add(new SpatialObjectPair(distance, entry1, entry2, true)); } } }
[ "private", "void", "expandDirNodes", "(", "SpatialPrimitiveDistanceFunction", "<", "V", ">", "distFunction", ",", "DeLiCluNode", "node1", ",", "DeLiCluNode", "node2", ")", "{", "if", "(", "LOG", ".", "isDebuggingFinest", "(", ")", ")", "{", "LOG", ".", "debugF...
Expands the specified directory nodes. @param distFunction the spatial distance function of this algorithm @param node1 the first node @param node2 the second node
[ "Expands", "the", "specified", "directory", "nodes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java#L230-L254
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java
DeLiClu.expandLeafNodes
private void expandLeafNodes(SpatialPrimitiveDistanceFunction<V> distFunction, DeLiCluNode node1, DeLiCluNode node2, DataStore<KNNList> knns) { if(LOG.isDebuggingFinest()) { LOG.debugFinest("ExpandLeafNodes: " + node1.getPageID() + " + " + node2.getPageID()); } int numEntries_1 = node1.getNumEntries(); int numEntries_2 = node2.getNumEntries(); // insert all combinations of unhandled - handled children of // node1-node2 into pq for(int i = 0; i < numEntries_1; i++) { DeLiCluEntry entry1 = node1.getEntry(i); if(!entry1.hasUnhandled()) { continue; } for(int j = 0; j < numEntries_2; j++) { DeLiCluEntry entry2 = node2.getEntry(j); if(!entry2.hasHandled()) { continue; } double distance = distFunction.minDist(entry1, entry2); double reach = MathUtil.max(distance, knns.get(((LeafEntry) entry2).getDBID()).getKNNDistance()); heap.add(new SpatialObjectPair(reach, entry1, entry2, false)); } } }
java
private void expandLeafNodes(SpatialPrimitiveDistanceFunction<V> distFunction, DeLiCluNode node1, DeLiCluNode node2, DataStore<KNNList> knns) { if(LOG.isDebuggingFinest()) { LOG.debugFinest("ExpandLeafNodes: " + node1.getPageID() + " + " + node2.getPageID()); } int numEntries_1 = node1.getNumEntries(); int numEntries_2 = node2.getNumEntries(); // insert all combinations of unhandled - handled children of // node1-node2 into pq for(int i = 0; i < numEntries_1; i++) { DeLiCluEntry entry1 = node1.getEntry(i); if(!entry1.hasUnhandled()) { continue; } for(int j = 0; j < numEntries_2; j++) { DeLiCluEntry entry2 = node2.getEntry(j); if(!entry2.hasHandled()) { continue; } double distance = distFunction.minDist(entry1, entry2); double reach = MathUtil.max(distance, knns.get(((LeafEntry) entry2).getDBID()).getKNNDistance()); heap.add(new SpatialObjectPair(reach, entry1, entry2, false)); } } }
[ "private", "void", "expandLeafNodes", "(", "SpatialPrimitiveDistanceFunction", "<", "V", ">", "distFunction", ",", "DeLiCluNode", "node1", ",", "DeLiCluNode", "node2", ",", "DataStore", "<", "KNNList", ">", "knns", ")", "{", "if", "(", "LOG", ".", "isDebuggingFi...
Expands the specified leaf nodes. @param distFunction the spatial distance function of this algorithm @param node1 the first node @param node2 the second node @param knns the knn list
[ "Expands", "the", "specified", "leaf", "nodes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java#L264-L289
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java
DeLiClu.reinsertExpanded
private void reinsertExpanded(SpatialPrimitiveDistanceFunction<V> distFunction, DeLiCluTree index, IndexTreePath<DeLiCluEntry> path, DataStore<KNNList> knns) { int l = 0; // Count the number of components. for(IndexTreePath<DeLiCluEntry> it = path; it != null; it = it.getParentPath()) { l++; } ArrayList<IndexTreePath<DeLiCluEntry>> p = new ArrayList<>(l - 1); // All except the last (= root). IndexTreePath<DeLiCluEntry> it = path; for(; it.getParentPath() != null; it = it.getParentPath()) { p.add(it); } assert (p.size() == l - 1); DeLiCluEntry rootEntry = it.getEntry(); reinsertExpanded(distFunction, index, p, l - 2, rootEntry, knns); }
java
private void reinsertExpanded(SpatialPrimitiveDistanceFunction<V> distFunction, DeLiCluTree index, IndexTreePath<DeLiCluEntry> path, DataStore<KNNList> knns) { int l = 0; // Count the number of components. for(IndexTreePath<DeLiCluEntry> it = path; it != null; it = it.getParentPath()) { l++; } ArrayList<IndexTreePath<DeLiCluEntry>> p = new ArrayList<>(l - 1); // All except the last (= root). IndexTreePath<DeLiCluEntry> it = path; for(; it.getParentPath() != null; it = it.getParentPath()) { p.add(it); } assert (p.size() == l - 1); DeLiCluEntry rootEntry = it.getEntry(); reinsertExpanded(distFunction, index, p, l - 2, rootEntry, knns); }
[ "private", "void", "reinsertExpanded", "(", "SpatialPrimitiveDistanceFunction", "<", "V", ">", "distFunction", ",", "DeLiCluTree", "index", ",", "IndexTreePath", "<", "DeLiCluEntry", ">", "path", ",", "DataStore", "<", "KNNList", ">", "knns", ")", "{", "int", "l...
Reinserts the objects of the already expanded nodes. @param distFunction the spatial distance function of this algorithm @param index the index storing the objects @param path the path of the object inserted last @param knns the knn list
[ "Reinserts", "the", "objects", "of", "the", "already", "expanded", "nodes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java#L299-L313
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.assertSameDimensionality
public static int assertSameDimensionality(SpatialComparable box1, SpatialComparable box2) { final int dim = box1.getDimensionality(); if(dim != box2.getDimensionality()) { throw new IllegalArgumentException("The spatial objects do not have the same dimensionality!"); } return dim; }
java
public static int assertSameDimensionality(SpatialComparable box1, SpatialComparable box2) { final int dim = box1.getDimensionality(); if(dim != box2.getDimensionality()) { throw new IllegalArgumentException("The spatial objects do not have the same dimensionality!"); } return dim; }
[ "public", "static", "int", "assertSameDimensionality", "(", "SpatialComparable", "box1", ",", "SpatialComparable", "box2", ")", "{", "final", "int", "dim", "=", "box1", ".", "getDimensionality", "(", ")", ";", "if", "(", "dim", "!=", "box2", ".", "getDimension...
Check that two spatial objects have the same dimensionality. @param box1 First object @param box2 Second object @return Dimensionality @throws IllegalArgumentException when the dimensionalities do not agree
[ "Check", "that", "two", "spatial", "objects", "have", "the", "same", "dimensionality", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L55-L61
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.getMin
public static double[] getMin(SpatialComparable box) { final int dim = box.getDimensionality(); double[] min = new double[dim]; for(int i = 0; i < dim; i++) { min[i] = box.getMin(i); } return min; }
java
public static double[] getMin(SpatialComparable box) { final int dim = box.getDimensionality(); double[] min = new double[dim]; for(int i = 0; i < dim; i++) { min[i] = box.getMin(i); } return min; }
[ "public", "static", "double", "[", "]", "getMin", "(", "SpatialComparable", "box", ")", "{", "final", "int", "dim", "=", "box", ".", "getDimensionality", "(", ")", ";", "double", "[", "]", "min", "=", "new", "double", "[", "dim", "]", ";", "for", "("...
Returns a clone of the minimum hyper point. @param box spatial object @return the minimum hyper point
[ "Returns", "a", "clone", "of", "the", "minimum", "hyper", "point", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L69-L76
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.getMax
public static double[] getMax(SpatialComparable box) { final int dim = box.getDimensionality(); double[] max = new double[dim]; for(int i = 0; i < dim; i++) { max[i] = box.getMax(i); } return max; }
java
public static double[] getMax(SpatialComparable box) { final int dim = box.getDimensionality(); double[] max = new double[dim]; for(int i = 0; i < dim; i++) { max[i] = box.getMax(i); } return max; }
[ "public", "static", "double", "[", "]", "getMax", "(", "SpatialComparable", "box", ")", "{", "final", "int", "dim", "=", "box", ".", "getDimensionality", "(", ")", ";", "double", "[", "]", "max", "=", "new", "double", "[", "dim", "]", ";", "for", "("...
Returns a clone of the maximum hyper point. @param box spatial object @return the maximum hyper point
[ "Returns", "a", "clone", "of", "the", "maximum", "hyper", "point", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L84-L91
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.intersects
public static boolean intersects(SpatialComparable box1, SpatialComparable box2) { final int dim = assertSameDimensionality(box1, box2); for(int i = 0; i < dim; i++) { if(box2.getMax(i) < box1.getMin(i) || box1.getMax(i) < box2.getMin(i)) { return false; } } return true; }
java
public static boolean intersects(SpatialComparable box1, SpatialComparable box2) { final int dim = assertSameDimensionality(box1, box2); for(int i = 0; i < dim; i++) { if(box2.getMax(i) < box1.getMin(i) || box1.getMax(i) < box2.getMin(i)) { return false; } } return true; }
[ "public", "static", "boolean", "intersects", "(", "SpatialComparable", "box1", ",", "SpatialComparable", "box2", ")", "{", "final", "int", "dim", "=", "assertSameDimensionality", "(", "box1", ",", "box2", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i...
Returns true if the two SpatialComparables intersect, false otherwise. @param box1 the first SpatialComparable @param box2 the first SpatialComparable @return true if the SpatialComparables intersect, false otherwise
[ "Returns", "true", "if", "the", "two", "SpatialComparables", "intersect", "false", "otherwise", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L100-L108
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.contains
public static boolean contains(SpatialComparable box, double[] point) { final int dim = box.getDimensionality(); if(dim != point.length) { throw new IllegalArgumentException("This HyperBoundingBox and the given point need same dimensionality"); } for(int i = 0; i < dim; i++) { if(box.getMin(i) > point[i] || box.getMax(i) < point[i]) { return false; } } return true; }
java
public static boolean contains(SpatialComparable box, double[] point) { final int dim = box.getDimensionality(); if(dim != point.length) { throw new IllegalArgumentException("This HyperBoundingBox and the given point need same dimensionality"); } for(int i = 0; i < dim; i++) { if(box.getMin(i) > point[i] || box.getMax(i) < point[i]) { return false; } } return true; }
[ "public", "static", "boolean", "contains", "(", "SpatialComparable", "box", ",", "double", "[", "]", "point", ")", "{", "final", "int", "dim", "=", "box", ".", "getDimensionality", "(", ")", ";", "if", "(", "dim", "!=", "point", ".", "length", ")", "{"...
Returns true if this SpatialComparable contains the given point, false otherwise. @param box spatial object @param point the point to be tested for containment @return true if this SpatialComparable contains the given point, false otherwise
[ "Returns", "true", "if", "this", "SpatialComparable", "contains", "the", "given", "point", "false", "otherwise", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L138-L150
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.enlargement
public static double enlargement(SpatialComparable exist, SpatialComparable addit) { final int dim = assertSameDimensionality(exist, addit); double v1 = 1.; double v2 = 1.; for(int i = 0; i < dim; i++) { final double emin = exist.getMin(i); final double emax = exist.getMax(i); final double amin = addit.getMin(i); final double amax = addit.getMax(i); final double min = Math.min(emin, amin); final double max = Math.max(emax, amax); v1 *= (max - min); v2 *= (emax - emin); } return v2 - v1; }
java
public static double enlargement(SpatialComparable exist, SpatialComparable addit) { final int dim = assertSameDimensionality(exist, addit); double v1 = 1.; double v2 = 1.; for(int i = 0; i < dim; i++) { final double emin = exist.getMin(i); final double emax = exist.getMax(i); final double amin = addit.getMin(i); final double amax = addit.getMax(i); final double min = Math.min(emin, amin); final double max = Math.max(emax, amax); v1 *= (max - min); v2 *= (emax - emin); } return v2 - v1; }
[ "public", "static", "double", "enlargement", "(", "SpatialComparable", "exist", ",", "SpatialComparable", "addit", ")", "{", "final", "int", "dim", "=", "assertSameDimensionality", "(", "exist", ",", "addit", ")", ";", "double", "v1", "=", "1.", ";", "double",...
Compute the enlargement obtained by adding an object to an existing object. @param exist Existing rectangle @param addit Additional rectangle @return Enlargement factor
[ "Compute", "the", "enlargement", "obtained", "by", "adding", "an", "object", "to", "an", "existing", "object", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L235-L251
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.perimeter
public static double perimeter(SpatialComparable box) { final int dim = box.getDimensionality(); double perimeter = 0.; for(int i = 0; i < dim; i++) { perimeter += box.getMax(i) - box.getMin(i); } return perimeter; }
java
public static double perimeter(SpatialComparable box) { final int dim = box.getDimensionality(); double perimeter = 0.; for(int i = 0; i < dim; i++) { perimeter += box.getMax(i) - box.getMin(i); } return perimeter; }
[ "public", "static", "double", "perimeter", "(", "SpatialComparable", "box", ")", "{", "final", "int", "dim", "=", "box", ".", "getDimensionality", "(", ")", ";", "double", "perimeter", "=", "0.", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", ...
Computes the perimeter of this SpatialComparable. @param box spatial object @return the perimeter of this SpatialComparable
[ "Computes", "the", "perimeter", "of", "this", "SpatialComparable", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L285-L292
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.overlap
public static double overlap(SpatialComparable box1, SpatialComparable box2) { final int dim = assertSameDimensionality(box1, box2); // the maximal and minimal value of the overlap box. double omax, omin; // the overlap volume double overlap = 1.; for(int i = 0; i < dim; i++) { // The maximal value of that overlap box in the current // dimension is the minimum of the max values. omax = Math.min(box1.getMax(i), box2.getMax(i)); // The minimal value is the maximum of the min values. omin = Math.max(box1.getMin(i), box2.getMin(i)); // if omax <= omin in any dimension, the overlap box has a volume of zero if(omax <= omin) { return 0.; } overlap *= omax - omin; } return overlap; }
java
public static double overlap(SpatialComparable box1, SpatialComparable box2) { final int dim = assertSameDimensionality(box1, box2); // the maximal and minimal value of the overlap box. double omax, omin; // the overlap volume double overlap = 1.; for(int i = 0; i < dim; i++) { // The maximal value of that overlap box in the current // dimension is the minimum of the max values. omax = Math.min(box1.getMax(i), box2.getMax(i)); // The minimal value is the maximum of the min values. omin = Math.max(box1.getMin(i), box2.getMin(i)); // if omax <= omin in any dimension, the overlap box has a volume of zero if(omax <= omin) { return 0.; } overlap *= omax - omin; } return overlap; }
[ "public", "static", "double", "overlap", "(", "SpatialComparable", "box1", ",", "SpatialComparable", "box2", ")", "{", "final", "int", "dim", "=", "assertSameDimensionality", "(", "box1", ",", "box2", ")", ";", "// the maximal and minimal value of the overlap box.", "...
Computes the volume of the overlapping box between two SpatialComparables. @param box1 the first SpatialComparable @param box2 the second SpatialComparable @return the overlap volume.
[ "Computes", "the", "volume", "of", "the", "overlapping", "box", "between", "two", "SpatialComparables", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L301-L326
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.relativeOverlap
public static double relativeOverlap(SpatialComparable box1, SpatialComparable box2) { final int dim = assertSameDimensionality(box1, box2); // the overlap volume double overlap = 1.; double vol1 = 1.; double vol2 = 1.; for(int i = 0; i < dim; i++) { final double box1min = box1.getMin(i); final double box1max = box1.getMax(i); final double box2min = box2.getMin(i); final double box2max = box2.getMax(i); final double omax = Math.min(box1max, box2max); final double omin = Math.max(box1min, box2min); // if omax <= omin in any dimension, the overlap box has a volume of zero if(omax <= omin) { return 0.; } overlap *= omax - omin; vol1 *= box1max - box1min; vol2 *= box2max - box2min; } return overlap / (vol1 + vol2); }
java
public static double relativeOverlap(SpatialComparable box1, SpatialComparable box2) { final int dim = assertSameDimensionality(box1, box2); // the overlap volume double overlap = 1.; double vol1 = 1.; double vol2 = 1.; for(int i = 0; i < dim; i++) { final double box1min = box1.getMin(i); final double box1max = box1.getMax(i); final double box2min = box2.getMin(i); final double box2max = box2.getMax(i); final double omax = Math.min(box1max, box2max); final double omin = Math.max(box1min, box2min); // if omax <= omin in any dimension, the overlap box has a volume of zero if(omax <= omin) { return 0.; } overlap *= omax - omin; vol1 *= box1max - box1min; vol2 *= box2max - box2min; } return overlap / (vol1 + vol2); }
[ "public", "static", "double", "relativeOverlap", "(", "SpatialComparable", "box1", ",", "SpatialComparable", "box2", ")", "{", "final", "int", "dim", "=", "assertSameDimensionality", "(", "box1", ",", "box2", ")", ";", "// the overlap volume", "double", "overlap", ...
Computes the volume of the overlapping box between two SpatialComparables and return the relation between the volume of the overlapping box and the volume of both SpatialComparable. @param box1 the first SpatialComparable @param box2 the second SpatialComparable @return the overlap volume in relation to the singular volumes.
[ "Computes", "the", "volume", "of", "the", "overlapping", "box", "between", "two", "SpatialComparables", "and", "return", "the", "relation", "between", "the", "volume", "of", "the", "overlapping", "box", "and", "the", "volume", "of", "both", "SpatialComparable", ...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L337-L365
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.unionTolerant
public static ModifiableHyperBoundingBox unionTolerant(SpatialComparable mbr1, SpatialComparable mbr2) { if(mbr1 == null && mbr2 == null) { return null; } if(mbr1 == null) { // Clone - intentionally return new ModifiableHyperBoundingBox(mbr2); } if(mbr2 == null) { // Clone - intentionally return new ModifiableHyperBoundingBox(mbr1); } return union(mbr1, mbr2); }
java
public static ModifiableHyperBoundingBox unionTolerant(SpatialComparable mbr1, SpatialComparable mbr2) { if(mbr1 == null && mbr2 == null) { return null; } if(mbr1 == null) { // Clone - intentionally return new ModifiableHyperBoundingBox(mbr2); } if(mbr2 == null) { // Clone - intentionally return new ModifiableHyperBoundingBox(mbr1); } return union(mbr1, mbr2); }
[ "public", "static", "ModifiableHyperBoundingBox", "unionTolerant", "(", "SpatialComparable", "mbr1", ",", "SpatialComparable", "mbr2", ")", "{", "if", "(", "mbr1", "==", "null", "&&", "mbr2", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "mb...
Returns the union of the two specified MBRs. Tolerant of "null" values. @param mbr1 the first MBR @param mbr2 the second MBR @return the union of the two specified MBRs
[ "Returns", "the", "union", "of", "the", "two", "specified", "MBRs", ".", "Tolerant", "of", "null", "values", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L395-L408
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
SpatialUtil.centroid
public static double[] centroid(SpatialComparable obj) { final int dim = obj.getDimensionality(); double[] centroid = new double[dim]; for(int d = 0; d < dim; d++) { centroid[d] = (obj.getMax(d) + obj.getMin(d)) * .5; } return centroid; }
java
public static double[] centroid(SpatialComparable obj) { final int dim = obj.getDimensionality(); double[] centroid = new double[dim]; for(int d = 0; d < dim; d++) { centroid[d] = (obj.getMax(d) + obj.getMin(d)) * .5; } return centroid; }
[ "public", "static", "double", "[", "]", "centroid", "(", "SpatialComparable", "obj", ")", "{", "final", "int", "dim", "=", "obj", ".", "getDimensionality", "(", ")", ";", "double", "[", "]", "centroid", "=", "new", "double", "[", "dim", "]", ";", "for"...
Returns the centroid of this SpatialComparable. @param obj Spatial object to process @return the centroid of this SpatialComparable
[ "Returns", "the", "centroid", "of", "this", "SpatialComparable", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L475-L482
train
elki-project/elki
elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/scaling/LinearScaling.java
LinearScaling.fromMinMax
public static LinearScaling fromMinMax(double min, double max) { double zoom = 1.0 / (max - min); return new LinearScaling(zoom, -min * zoom); }
java
public static LinearScaling fromMinMax(double min, double max) { double zoom = 1.0 / (max - min); return new LinearScaling(zoom, -min * zoom); }
[ "public", "static", "LinearScaling", "fromMinMax", "(", "double", "min", ",", "double", "max", ")", "{", "double", "zoom", "=", "1.0", "/", "(", "max", "-", "min", ")", ";", "return", "new", "LinearScaling", "(", "zoom", ",", "-", "min", "*", "zoom", ...
Make a linear scaling from a given minimum and maximum. The minimum will be mapped to zero, the maximum to one. @param min Minimum @param max Maximum @return New linear scaling.
[ "Make", "a", "linear", "scaling", "from", "a", "given", "minimum", "and", "maximum", ".", "The", "minimum", "will", "be", "mapped", "to", "zero", "the", "maximum", "to", "one", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/scaling/LinearScaling.java#L102-L105
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/PairCounting.java
PairCounting.fMeasure
public double fMeasure(double beta) { final double beta2 = beta * beta; double fmeasure = ((1 + beta2) * pairconfuse[0]) / ((1 + beta2) * pairconfuse[0] + beta2 * pairconfuse[1] + pairconfuse[2]); return fmeasure; }
java
public double fMeasure(double beta) { final double beta2 = beta * beta; double fmeasure = ((1 + beta2) * pairconfuse[0]) / ((1 + beta2) * pairconfuse[0] + beta2 * pairconfuse[1] + pairconfuse[2]); return fmeasure; }
[ "public", "double", "fMeasure", "(", "double", "beta", ")", "{", "final", "double", "beta2", "=", "beta", "*", "beta", ";", "double", "fmeasure", "=", "(", "(", "1", "+", "beta2", ")", "*", "pairconfuse", "[", "0", "]", ")", "/", "(", "(", "1", "...
Get the pair-counting F-Measure @param beta Beta value. @return F-Measure
[ "Get", "the", "pair", "-", "counting", "F", "-", "Measure" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/PairCounting.java#L118-L122
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectComment.java
TextWriterObjectComment.write
@Override public void write(TextWriterStream out, String label, Object object) { StringBuilder buf = new StringBuilder(100); if(label != null) { buf.append(label).append('='); } if(object != null) { buf.append(object.toString()); } out.commentPrintLn(buf); }
java
@Override public void write(TextWriterStream out, String label, Object object) { StringBuilder buf = new StringBuilder(100); if(label != null) { buf.append(label).append('='); } if(object != null) { buf.append(object.toString()); } out.commentPrintLn(buf); }
[ "@", "Override", "public", "void", "write", "(", "TextWriterStream", "out", ",", "String", "label", ",", "Object", "object", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "100", ")", ";", "if", "(", "label", "!=", "null", ")", "{", ...
Put an object into the comment section
[ "Put", "an", "object", "into", "the", "comment", "section" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectComment.java#L37-L47
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/transform/ClassicMultidimensionalScalingTransform.java
ClassicMultidimensionalScalingTransform.computeSquaredDistanceMatrix
protected static <I> double[][] computeSquaredDistanceMatrix(final List<I> col, PrimitiveDistanceFunction<? super I> dist) { final int size = col.size(); double[][] imat = new double[size][size]; boolean squared = dist.isSquared(); FiniteProgress dprog = LOG.isVerbose() ? new FiniteProgress("Computing distance matrix", (size * (size - 1)) >>> 1, LOG) : null; for(int x = 0; x < size; x++) { final I ox = col.get(x); for(int y = x + 1; y < size; y++) { final I oy = col.get(y); double distance = dist.distance(ox, oy); distance *= squared ? -.5 : (-.5 * distance); imat[x][y] = imat[y][x] = distance; } if(dprog != null) { dprog.setProcessed(dprog.getProcessed() + size - x - 1, LOG); } } LOG.ensureCompleted(dprog); return imat; }
java
protected static <I> double[][] computeSquaredDistanceMatrix(final List<I> col, PrimitiveDistanceFunction<? super I> dist) { final int size = col.size(); double[][] imat = new double[size][size]; boolean squared = dist.isSquared(); FiniteProgress dprog = LOG.isVerbose() ? new FiniteProgress("Computing distance matrix", (size * (size - 1)) >>> 1, LOG) : null; for(int x = 0; x < size; x++) { final I ox = col.get(x); for(int y = x + 1; y < size; y++) { final I oy = col.get(y); double distance = dist.distance(ox, oy); distance *= squared ? -.5 : (-.5 * distance); imat[x][y] = imat[y][x] = distance; } if(dprog != null) { dprog.setProcessed(dprog.getProcessed() + size - x - 1, LOG); } } LOG.ensureCompleted(dprog); return imat; }
[ "protected", "static", "<", "I", ">", "double", "[", "]", "[", "]", "computeSquaredDistanceMatrix", "(", "final", "List", "<", "I", ">", "col", ",", "PrimitiveDistanceFunction", "<", "?", "super", "I", ">", "dist", ")", "{", "final", "int", "size", "=", ...
Compute the squared distance matrix. @param col Input data @param dist Distance function @return Distance matrix.
[ "Compute", "the", "squared", "distance", "matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/transform/ClassicMultidimensionalScalingTransform.java#L158-L177
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/RescaleMetaOutlierAlgorithm.java
RescaleMetaOutlierAlgorithm.getOutlierResult
private OutlierResult getOutlierResult(ResultHierarchy hier, Result result) { List<OutlierResult> ors = ResultUtil.filterResults(hier, result, OutlierResult.class); if(!ors.isEmpty()) { return ors.get(0); } throw new IllegalStateException("Comparison algorithm expected at least one outlier result."); }
java
private OutlierResult getOutlierResult(ResultHierarchy hier, Result result) { List<OutlierResult> ors = ResultUtil.filterResults(hier, result, OutlierResult.class); if(!ors.isEmpty()) { return ors.get(0); } throw new IllegalStateException("Comparison algorithm expected at least one outlier result."); }
[ "private", "OutlierResult", "getOutlierResult", "(", "ResultHierarchy", "hier", ",", "Result", "result", ")", "{", "List", "<", "OutlierResult", ">", "ors", "=", "ResultUtil", ".", "filterResults", "(", "hier", ",", "result", ",", "OutlierResult", ".", "class", ...
Find an OutlierResult to work with. @param hier Result hierarchy @param result Result object @return Iterator to work with
[ "Find", "an", "OutlierResult", "to", "work", "with", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/meta/RescaleMetaOutlierAlgorithm.java#L126-L132
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppTreeNode.java
MkAppTreeNode.knnDistanceApproximation
protected PolynomialApproximation knnDistanceApproximation() { int p_max = 0; double[] b = null; for(int i = 0; i < getNumEntries(); i++) { MkAppEntry entry = getEntry(i); PolynomialApproximation approximation = entry.getKnnDistanceApproximation(); if(b == null) { p_max = approximation.getPolynomialOrder(); b = new double[p_max]; } for(int p = 0; p < p_max; p++) { b[p] += approximation.getB(p); } } for(int p = 0; p < p_max; p++) { b[p] /= p_max; } if(LoggingConfiguration.DEBUG) { StringBuilder msg = new StringBuilder(); msg.append("b " + FormatUtil.format(b, FormatUtil.NF4)); Logger.getLogger(this.getClass().getName()).fine(msg.toString()); } return new PolynomialApproximation(b); }
java
protected PolynomialApproximation knnDistanceApproximation() { int p_max = 0; double[] b = null; for(int i = 0; i < getNumEntries(); i++) { MkAppEntry entry = getEntry(i); PolynomialApproximation approximation = entry.getKnnDistanceApproximation(); if(b == null) { p_max = approximation.getPolynomialOrder(); b = new double[p_max]; } for(int p = 0; p < p_max; p++) { b[p] += approximation.getB(p); } } for(int p = 0; p < p_max; p++) { b[p] /= p_max; } if(LoggingConfiguration.DEBUG) { StringBuilder msg = new StringBuilder(); msg.append("b " + FormatUtil.format(b, FormatUtil.NF4)); Logger.getLogger(this.getClass().getName()).fine(msg.toString()); } return new PolynomialApproximation(b); }
[ "protected", "PolynomialApproximation", "knnDistanceApproximation", "(", ")", "{", "int", "p_max", "=", "0", ";", "double", "[", "]", "b", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getNumEntries", "(", ")", ";", "i", "++", "...
Determines and returns the polynomial approximation for the knn distances of this node as the maximum of the polynomial approximations of all entries. @return the conservative approximation for the knn distances
[ "Determines", "and", "returns", "the", "polynomial", "approximation", "for", "the", "knn", "distances", "of", "this", "node", "as", "the", "maximum", "of", "the", "polynomial", "approximations", "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/mkapp/MkAppTreeNode.java#L70-L96
train
elki-project/elki
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/ProxyDatabase.java
ProxyDatabase.setDBIDs
public void setDBIDs(DBIDs ids) { this.idrep.setDBIDs(ids); // Update relations. for (Relation<?> orel : this.relations) { if (orel instanceof ProxyView) { ((ProxyView<?>) orel).setDBIDs(this.idrep.getDBIDs()); } } }
java
public void setDBIDs(DBIDs ids) { this.idrep.setDBIDs(ids); // Update relations. for (Relation<?> orel : this.relations) { if (orel instanceof ProxyView) { ((ProxyView<?>) orel).setDBIDs(this.idrep.getDBIDs()); } } }
[ "public", "void", "setDBIDs", "(", "DBIDs", "ids", ")", "{", "this", ".", "idrep", ".", "setDBIDs", "(", "ids", ")", ";", "// Update relations.", "for", "(", "Relation", "<", "?", ">", "orel", ":", "this", ".", "relations", ")", "{", "if", "(", "orel...
Set the DBIDs to use. @param ids DBIDs to use
[ "Set", "the", "DBIDs", "to", "use", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/ProxyDatabase.java#L122-L130
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/ProgressTracker.java
ProgressTracker.getProgresses
public synchronized Collection<Progress> getProgresses() { List<Progress> list = new ArrayList<>(progresses.size()); Iterator<WeakReference<Progress>> iter = progresses.iterator(); while(iter.hasNext()) { WeakReference<Progress> ref = iter.next(); if(ref.get() == null) { iter.remove(); } else { list.add(ref.get()); } } return list; }
java
public synchronized Collection<Progress> getProgresses() { List<Progress> list = new ArrayList<>(progresses.size()); Iterator<WeakReference<Progress>> iter = progresses.iterator(); while(iter.hasNext()) { WeakReference<Progress> ref = iter.next(); if(ref.get() == null) { iter.remove(); } else { list.add(ref.get()); } } return list; }
[ "public", "synchronized", "Collection", "<", "Progress", ">", "getProgresses", "(", ")", "{", "List", "<", "Progress", ">", "list", "=", "new", "ArrayList", "<>", "(", "progresses", ".", "size", "(", ")", ")", ";", "Iterator", "<", "WeakReference", "<", ...
Get a list of progresses tracked. @return List of progresses.
[ "Get", "a", "list", "of", "progresses", "tracked", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/ProgressTracker.java#L48-L61
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/ProgressTracker.java
ProgressTracker.addProgress
public synchronized void addProgress(Progress p) { // Don't add more than once. Iterator<WeakReference<Progress>> iter = progresses.iterator(); while(iter.hasNext()) { WeakReference<Progress> ref = iter.next(); // since we are at it anyway, remove old links. if(ref.get() == null) { iter.remove(); } else { if(ref.get() == p) { return; } } } progresses.add(new WeakReference<>(p)); }
java
public synchronized void addProgress(Progress p) { // Don't add more than once. Iterator<WeakReference<Progress>> iter = progresses.iterator(); while(iter.hasNext()) { WeakReference<Progress> ref = iter.next(); // since we are at it anyway, remove old links. if(ref.get() == null) { iter.remove(); } else { if(ref.get() == p) { return; } } } progresses.add(new WeakReference<>(p)); }
[ "public", "synchronized", "void", "addProgress", "(", "Progress", "p", ")", "{", "// Don't add more than once.", "Iterator", "<", "WeakReference", "<", "Progress", ">>", "iter", "=", "progresses", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "has...
Add a new Progress to the tracker. @param p Progress
[ "Add", "a", "new", "Progress", "to", "the", "tracker", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/ProgressTracker.java#L68-L84
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java
DeLiCluTreeIndex.setHandled
public synchronized IndexTreePath<DeLiCluEntry> setHandled(DBID id, O obj) { if(LOG.isDebugging()) { LOG.debugFine("setHandled " + id + ", " + obj + "\n"); } // find the leaf node containing o IndexTreePath<DeLiCluEntry> pathToObject = findPathToObject(getRootPath(), obj, id); if(pathToObject == null) { throw new AbortException("Object not found in setHandled."); } // set o handled DeLiCluEntry entry = pathToObject.getEntry(); entry.setHasHandled(true); entry.setHasUnhandled(false); for(IndexTreePath<DeLiCluEntry> path = pathToObject; path.getParentPath() != null; path = path.getParentPath()) { DeLiCluEntry parentEntry = path.getParentPath().getEntry(); DeLiCluNode node = getNode(parentEntry); boolean hasHandled = false; boolean hasUnhandled = false; for(int i = 0; i < node.getNumEntries(); i++) { final DeLiCluEntry nodeEntry = node.getEntry(i); hasHandled = hasHandled || nodeEntry.hasHandled(); hasUnhandled = hasUnhandled || nodeEntry.hasUnhandled(); } parentEntry.setHasUnhandled(hasUnhandled); parentEntry.setHasHandled(hasHandled); } return pathToObject; }
java
public synchronized IndexTreePath<DeLiCluEntry> setHandled(DBID id, O obj) { if(LOG.isDebugging()) { LOG.debugFine("setHandled " + id + ", " + obj + "\n"); } // find the leaf node containing o IndexTreePath<DeLiCluEntry> pathToObject = findPathToObject(getRootPath(), obj, id); if(pathToObject == null) { throw new AbortException("Object not found in setHandled."); } // set o handled DeLiCluEntry entry = pathToObject.getEntry(); entry.setHasHandled(true); entry.setHasUnhandled(false); for(IndexTreePath<DeLiCluEntry> path = pathToObject; path.getParentPath() != null; path = path.getParentPath()) { DeLiCluEntry parentEntry = path.getParentPath().getEntry(); DeLiCluNode node = getNode(parentEntry); boolean hasHandled = false; boolean hasUnhandled = false; for(int i = 0; i < node.getNumEntries(); i++) { final DeLiCluEntry nodeEntry = node.getEntry(i); hasHandled = hasHandled || nodeEntry.hasHandled(); hasUnhandled = hasUnhandled || nodeEntry.hasUnhandled(); } parentEntry.setHasUnhandled(hasUnhandled); parentEntry.setHasHandled(hasHandled); } return pathToObject; }
[ "public", "synchronized", "IndexTreePath", "<", "DeLiCluEntry", ">", "setHandled", "(", "DBID", "id", ",", "O", "obj", ")", "{", "if", "(", "LOG", ".", "isDebugging", "(", ")", ")", "{", "LOG", ".", "debugFine", "(", "\"setHandled \"", "+", "id", "+", ...
Marks the specified object as handled and returns the path of node ids from the root to the objects's parent. @param id the objects id to be marked as handled @param obj the object to be marked as handled @return the path of node ids from the root to the objects's parent
[ "Marks", "the", "specified", "object", "as", "handled", "and", "returns", "the", "path", "of", "node", "ids", "from", "the", "root", "to", "the", "objects", "s", "parent", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java#L95-L127
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java
DeLiCluTreeIndex.delete
@Override public final boolean delete(DBIDRef id) { // find the leaf node containing o O obj = relation.get(id); IndexTreePath<DeLiCluEntry> deletionPath = findPathToObject(getRootPath(), obj, id); if(deletionPath == null) { return false; } deletePath(deletionPath); return true; }
java
@Override public final boolean delete(DBIDRef id) { // find the leaf node containing o O obj = relation.get(id); IndexTreePath<DeLiCluEntry> deletionPath = findPathToObject(getRootPath(), obj, id); if(deletionPath == null) { return false; } deletePath(deletionPath); return true; }
[ "@", "Override", "public", "final", "boolean", "delete", "(", "DBIDRef", "id", ")", "{", "// find the leaf node containing o", "O", "obj", "=", "relation", ".", "get", "(", "id", ")", ";", "IndexTreePath", "<", "DeLiCluEntry", ">", "deletionPath", "=", "findPa...
Deletes the specified object from this index. @return true if this index did contain the object with the specified id, false otherwise
[ "Deletes", "the", "specified", "object", "from", "this", "index", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java#L180-L190
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/application/experiments/EvaluateIntrinsicDimensionalityEstimators.java
EvaluateIntrinsicDimensionalityEstimators.makeSample
protected double[] makeSample(int maxk) { final Random rnd = this.rnd.getSingleThreadedRandom(); double[] dists = new double[maxk + 1]; final double e = 1. / dim; for(int i = 0; i <= maxk; i++) { dists[i] = FastMath.pow(rnd.nextDouble(), e); } Arrays.sort(dists); return dists; }
java
protected double[] makeSample(int maxk) { final Random rnd = this.rnd.getSingleThreadedRandom(); double[] dists = new double[maxk + 1]; final double e = 1. / dim; for(int i = 0; i <= maxk; i++) { dists[i] = FastMath.pow(rnd.nextDouble(), e); } Arrays.sort(dists); return dists; }
[ "protected", "double", "[", "]", "makeSample", "(", "int", "maxk", ")", "{", "final", "Random", "rnd", "=", "this", ".", "rnd", ".", "getSingleThreadedRandom", "(", ")", ";", "double", "[", "]", "dists", "=", "new", "double", "[", "maxk", "+", "1", "...
Generate a data sample. @param maxk Number of entries. @return Data sample
[ "Generate", "a", "data", "sample", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/application/experiments/EvaluateIntrinsicDimensionalityEstimators.java#L194-L203
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/MTreeDirectoryEntry.java
MTreeDirectoryEntry.setRoutingObjectID
@Override public final boolean setRoutingObjectID(DBID objectID) { if(objectID == routingObjectID || DBIDUtil.equal(objectID, routingObjectID)) { return false; } this.routingObjectID = objectID; return true; }
java
@Override public final boolean setRoutingObjectID(DBID objectID) { if(objectID == routingObjectID || DBIDUtil.equal(objectID, routingObjectID)) { return false; } this.routingObjectID = objectID; return true; }
[ "@", "Override", "public", "final", "boolean", "setRoutingObjectID", "(", "DBID", "objectID", ")", "{", "if", "(", "objectID", "==", "routingObjectID", "||", "DBIDUtil", ".", "equal", "(", "objectID", ",", "routingObjectID", ")", ")", "{", "return", "false", ...
Sets the id of the routing object of this entry. @param objectID the id to be set
[ "Sets", "the", "id", "of", "the", "routing", "object", "of", "this", "entry", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/MTreeDirectoryEntry.java#L136-L143
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/MTreeDirectoryEntry.java
MTreeDirectoryEntry.writeExternal
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(id); out.writeInt(DBIDUtil.asInteger(routingObjectID)); out.writeDouble(parentDistance); out.writeDouble(coveringRadius); }
java
@Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(id); out.writeInt(DBIDUtil.asInteger(routingObjectID)); out.writeDouble(parentDistance); out.writeDouble(coveringRadius); }
[ "@", "Override", "public", "void", "writeExternal", "(", "ObjectOutput", "out", ")", "throws", "IOException", "{", "out", ".", "writeInt", "(", "id", ")", ";", "out", ".", "writeInt", "(", "DBIDUtil", ".", "asInteger", "(", "routingObjectID", ")", ")", ";"...
Calls the super method and writes the routingObjectID, the parentDistance and the coveringRadius of this entry to the specified stream.
[ "Calls", "the", "super", "method", "and", "writes", "the", "routingObjectID", "the", "parentDistance", "and", "the", "coveringRadius", "of", "this", "entry", "to", "the", "specified", "stream", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/MTreeDirectoryEntry.java#L175-L181
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTextWriteable.java
TextWriterTextWriteable.write
@Override public void write(TextWriterStream out, String label, TextWriteable obj) { obj.writeToText(out, label); }
java
@Override public void write(TextWriterStream out, String label, TextWriteable obj) { obj.writeToText(out, label); }
[ "@", "Override", "public", "void", "write", "(", "TextWriterStream", "out", ",", "String", "label", ",", "TextWriteable", "obj", ")", "{", "obj", ".", "writeToText", "(", "out", ",", "label", ")", ";", "}" ]
Use the objects own text serialization.
[ "Use", "the", "objects", "own", "text", "serialization", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTextWriteable.java#L39-L42
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/EvaluateClustering.java
EvaluateClustering.evaluteResult
protected void evaluteResult(Database db, Clustering<?> c, Clustering<?> refc) { ClusterContingencyTable contmat = new ClusterContingencyTable(selfPairing, noiseSpecialHandling); contmat.process(refc, c); ScoreResult sr = new ScoreResult(contmat); sr.addHeader(c.getLongName()); db.getHierarchy().add(c, sr); }
java
protected void evaluteResult(Database db, Clustering<?> c, Clustering<?> refc) { ClusterContingencyTable contmat = new ClusterContingencyTable(selfPairing, noiseSpecialHandling); contmat.process(refc, c); ScoreResult sr = new ScoreResult(contmat); sr.addHeader(c.getLongName()); db.getHierarchy().add(c, sr); }
[ "protected", "void", "evaluteResult", "(", "Database", "db", ",", "Clustering", "<", "?", ">", "c", ",", "Clustering", "<", "?", ">", "refc", ")", "{", "ClusterContingencyTable", "contmat", "=", "new", "ClusterContingencyTable", "(", "selfPairing", ",", "noise...
Evaluate a clustering result. @param db Database @param c Clustering @param refc Reference clustering
[ "Evaluate", "a", "clustering", "result", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/EvaluateClustering.java#L174-L181
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/EvaluateClustering.java
EvaluateClustering.isReferenceResult
private boolean isReferenceResult(Clustering<?> t) { // FIXME: don't hard-code strings return "bylabel-clustering".equals(t.getShortName()) // || "bymodel-clustering".equals(t.getShortName()) // || "allinone-clustering".equals(t.getShortName()) // || "allinnoise-clustering".equals(t.getShortName()); }
java
private boolean isReferenceResult(Clustering<?> t) { // FIXME: don't hard-code strings return "bylabel-clustering".equals(t.getShortName()) // || "bymodel-clustering".equals(t.getShortName()) // || "allinone-clustering".equals(t.getShortName()) // || "allinnoise-clustering".equals(t.getShortName()); }
[ "private", "boolean", "isReferenceResult", "(", "Clustering", "<", "?", ">", "t", ")", "{", "// FIXME: don't hard-code strings", "return", "\"bylabel-clustering\"", ".", "equals", "(", "t", ".", "getShortName", "(", ")", ")", "//", "||", "\"bymodel-clustering\"", ...
Test if a clustering result is a valid reference result. @param t Clustering to test. @return {@code true} if it is considered to be a reference result.
[ "Test", "if", "a", "clustering", "result", "is", "a", "valid", "reference", "result", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/EvaluateClustering.java#L189-L195
train
elki-project/elki
elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/AbstractPageFile.java
AbstractPageFile.writePage
@Override public final synchronized int writePage(P page) { int pageid = setPageID(page); writePage(pageid, page); return pageid; }
java
@Override public final synchronized int writePage(P page) { int pageid = setPageID(page); writePage(pageid, page); return pageid; }
[ "@", "Override", "public", "final", "synchronized", "int", "writePage", "(", "P", "page", ")", "{", "int", "pageid", "=", "setPageID", "(", "page", ")", ";", "writePage", "(", "pageid", ",", "page", ")", ";", "return", "pageid", ";", "}" ]
Writes a page into this file. The method tests if the page has already an id, otherwise a new id is assigned and returned. @param page the page to be written @return the id of the page
[ "Writes", "a", "page", "into", "this", "file", ".", "The", "method", "tests", "if", "the", "page", "has", "already", "an", "id", "otherwise", "a", "new", "id", "is", "assigned", "and", "returned", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-persistent/src/main/java/de/lmu/ifi/dbs/elki/persistent/AbstractPageFile.java#L69-L74
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGHyperSphere.java
SVGHyperSphere.drawManhattan
public static Element drawManhattan(SVGPlot svgp, Projection2D proj, NumberVector mid, double radius) { final double[] v_mid = mid.toArray(); // a copy final long[] dims = proj.getVisibleDimensions2D(); SVGPath path = new SVGPath(); for(int dim = BitsUtil.nextSetBit(dims, 0); dim >= 0; dim = BitsUtil.nextSetBit(dims, dim + 1)) { v_mid[dim] += radius; double[] p1 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] -= radius * 2; double[] p2 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] += radius; for(int dim2 = BitsUtil.nextSetBit(dims, 0); dim2 >= 0; dim2 = BitsUtil.nextSetBit(dims, dim2 + 1)) { if(dim < dim2) { v_mid[dim2] += radius; double[] p3 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim2] -= radius * 2; double[] p4 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim2] += radius; path.moveTo(p1[0], p1[1]).drawTo(p3[0], p3[1]) // .moveTo(p1[0], p1[1]).drawTo(p4[0], p4[1]) // .moveTo(p2[0], p2[1]).drawTo(p3[0], p3[1]) // .moveTo(p2[0], p2[1]).drawTo(p4[0], p4[1]) // .close(); } } } return path.makeElement(svgp); }
java
public static Element drawManhattan(SVGPlot svgp, Projection2D proj, NumberVector mid, double radius) { final double[] v_mid = mid.toArray(); // a copy final long[] dims = proj.getVisibleDimensions2D(); SVGPath path = new SVGPath(); for(int dim = BitsUtil.nextSetBit(dims, 0); dim >= 0; dim = BitsUtil.nextSetBit(dims, dim + 1)) { v_mid[dim] += radius; double[] p1 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] -= radius * 2; double[] p2 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] += radius; for(int dim2 = BitsUtil.nextSetBit(dims, 0); dim2 >= 0; dim2 = BitsUtil.nextSetBit(dims, dim2 + 1)) { if(dim < dim2) { v_mid[dim2] += radius; double[] p3 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim2] -= radius * 2; double[] p4 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim2] += radius; path.moveTo(p1[0], p1[1]).drawTo(p3[0], p3[1]) // .moveTo(p1[0], p1[1]).drawTo(p4[0], p4[1]) // .moveTo(p2[0], p2[1]).drawTo(p3[0], p3[1]) // .moveTo(p2[0], p2[1]).drawTo(p4[0], p4[1]) // .close(); } } } return path.makeElement(svgp); }
[ "public", "static", "Element", "drawManhattan", "(", "SVGPlot", "svgp", ",", "Projection2D", "proj", ",", "NumberVector", "mid", ",", "double", "radius", ")", "{", "final", "double", "[", "]", "v_mid", "=", "mid", ".", "toArray", "(", ")", ";", "// a copy"...
Wireframe "manhattan" hypersphere @param svgp SVG Plot @param proj Visualization projection @param mid mean vector @param radius radius @return path element
[ "Wireframe", "manhattan", "hypersphere" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGHyperSphere.java#L63-L91
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGHyperSphere.java
SVGHyperSphere.drawCross
public static Element drawCross(SVGPlot svgp, Projection2D proj, NumberVector mid, double radius) { final double[] v_mid = mid.toArray(); final long[] dims = proj.getVisibleDimensions2D(); SVGPath path = new SVGPath(); for(int dim = BitsUtil.nextSetBit(dims, 0); dim >= 0; dim = BitsUtil.nextSetBit(dims, dim + 1)) { v_mid[dim] += radius; double[] p1 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] -= radius * 2; double[] p2 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] += radius; path.moveTo(p1[0], p1[1]).drawTo(p2[0], p2[1]).close(); } return path.makeElement(svgp); }
java
public static Element drawCross(SVGPlot svgp, Projection2D proj, NumberVector mid, double radius) { final double[] v_mid = mid.toArray(); final long[] dims = proj.getVisibleDimensions2D(); SVGPath path = new SVGPath(); for(int dim = BitsUtil.nextSetBit(dims, 0); dim >= 0; dim = BitsUtil.nextSetBit(dims, dim + 1)) { v_mid[dim] += radius; double[] p1 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] -= radius * 2; double[] p2 = proj.fastProjectDataToRenderSpace(v_mid); v_mid[dim] += radius; path.moveTo(p1[0], p1[1]).drawTo(p2[0], p2[1]).close(); } return path.makeElement(svgp); }
[ "public", "static", "Element", "drawCross", "(", "SVGPlot", "svgp", ",", "Projection2D", "proj", ",", "NumberVector", "mid", ",", "double", "radius", ")", "{", "final", "double", "[", "]", "v_mid", "=", "mid", ".", "toArray", "(", ")", ";", "final", "lon...
Wireframe "cross" hypersphere @param svgp SVG Plot @param proj Visualization projection @param mid mean vector @param radius radius @return path element
[ "Wireframe", "cross", "hypersphere" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGHyperSphere.java#L253-L267
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeUtil.java
RStarTreeUtil.getRangeQuery
@SuppressWarnings({ "cast", "unchecked" }) public static <O extends SpatialComparable> RangeQuery<O> getRangeQuery(AbstractRStarTree<?, ?, ?> tree, SpatialDistanceQuery<O> distanceQuery, Object... hints) { // Can we support this distance function - spatial distances only! SpatialPrimitiveDistanceFunction<? super O> df = distanceQuery.getDistanceFunction(); if(EuclideanDistanceFunction.STATIC.equals(df)) { return (RangeQuery<O>) new EuclideanRStarTreeRangeQuery<>(tree, (Relation<NumberVector>) distanceQuery.getRelation()); } return new RStarTreeRangeQuery<>(tree, distanceQuery.getRelation(), df); }
java
@SuppressWarnings({ "cast", "unchecked" }) public static <O extends SpatialComparable> RangeQuery<O> getRangeQuery(AbstractRStarTree<?, ?, ?> tree, SpatialDistanceQuery<O> distanceQuery, Object... hints) { // Can we support this distance function - spatial distances only! SpatialPrimitiveDistanceFunction<? super O> df = distanceQuery.getDistanceFunction(); if(EuclideanDistanceFunction.STATIC.equals(df)) { return (RangeQuery<O>) new EuclideanRStarTreeRangeQuery<>(tree, (Relation<NumberVector>) distanceQuery.getRelation()); } return new RStarTreeRangeQuery<>(tree, distanceQuery.getRelation(), df); }
[ "@", "SuppressWarnings", "(", "{", "\"cast\"", ",", "\"unchecked\"", "}", ")", "public", "static", "<", "O", "extends", "SpatialComparable", ">", "RangeQuery", "<", "O", ">", "getRangeQuery", "(", "AbstractRStarTree", "<", "?", ",", "?", ",", "?", ">", "tr...
Get an RTree range query, using an optimized double implementation when possible. @param <O> Object type @param tree Tree to query @param distanceQuery distance query @param hints Optimizer hints @return Query object
[ "Get", "an", "RTree", "range", "query", "using", "an", "optimized", "double", "implementation", "when", "possible", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeUtil.java#L67-L75
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeUtil.java
RStarTreeUtil.getKNNQuery
@SuppressWarnings({ "cast", "unchecked" }) public static <O extends SpatialComparable> KNNQuery<O> getKNNQuery(AbstractRStarTree<?, ?, ?> tree, SpatialDistanceQuery<O> distanceQuery, Object... hints) { // Can we support this distance function - spatial distances only! SpatialPrimitiveDistanceFunction<? super O> df = distanceQuery.getDistanceFunction(); if(EuclideanDistanceFunction.STATIC.equals(df)) { return (KNNQuery<O>) new EuclideanRStarTreeKNNQuery<>(tree, (Relation<NumberVector>) distanceQuery.getRelation()); } return new RStarTreeKNNQuery<>(tree, distanceQuery.getRelation(), df); }
java
@SuppressWarnings({ "cast", "unchecked" }) public static <O extends SpatialComparable> KNNQuery<O> getKNNQuery(AbstractRStarTree<?, ?, ?> tree, SpatialDistanceQuery<O> distanceQuery, Object... hints) { // Can we support this distance function - spatial distances only! SpatialPrimitiveDistanceFunction<? super O> df = distanceQuery.getDistanceFunction(); if(EuclideanDistanceFunction.STATIC.equals(df)) { return (KNNQuery<O>) new EuclideanRStarTreeKNNQuery<>(tree, (Relation<NumberVector>) distanceQuery.getRelation()); } return new RStarTreeKNNQuery<>(tree, distanceQuery.getRelation(), df); }
[ "@", "SuppressWarnings", "(", "{", "\"cast\"", ",", "\"unchecked\"", "}", ")", "public", "static", "<", "O", "extends", "SpatialComparable", ">", "KNNQuery", "<", "O", ">", "getKNNQuery", "(", "AbstractRStarTree", "<", "?", ",", "?", ",", "?", ">", "tree",...
Get an RTree knn query, using an optimized double implementation when possible. @param <O> Object type @param tree Tree to query @param distanceQuery distance query @param hints Optimizer hints @return Query object
[ "Get", "an", "RTree", "knn", "query", "using", "an", "optimized", "double", "implementation", "when", "possible", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeUtil.java#L87-L95
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java
LoggingConfiguration.privateReconfigureLogging
private void privateReconfigureLogging(String pkg, final String name) { LogManager logManager = LogManager.getLogManager(); Logger logger = Logger.getLogger(LoggingConfiguration.class.getName()); // allow null as package name. if(pkg == null) { pkg = ""; } // Load logging configuration from current directory String cfgfile = name; if(new File(name).exists()) { cfgfile = name; } else { // Fall back to full path / resources. cfgfile = pkg.replace('.', File.separatorChar) + File.separatorChar + name; } try { InputStream cfgdata = openSystemFile(cfgfile); logManager.readConfiguration(cfgdata); // also load as properties for us, to get debug flag. InputStream cfgdata2 = openSystemFile(cfgfile); Properties cfgprop = new Properties(); cfgprop.load(cfgdata2); DEBUG = Boolean.parseBoolean(cfgprop.getProperty("debug")); logger.info("Logging configuration read."); } catch(FileNotFoundException e) { logger.log(Level.SEVERE, "Could not find logging configuration file: " + cfgfile, e); } catch(Exception e) { logger.log(Level.SEVERE, "Failed to configure logging from file: " + cfgfile, e); } }
java
private void privateReconfigureLogging(String pkg, final String name) { LogManager logManager = LogManager.getLogManager(); Logger logger = Logger.getLogger(LoggingConfiguration.class.getName()); // allow null as package name. if(pkg == null) { pkg = ""; } // Load logging configuration from current directory String cfgfile = name; if(new File(name).exists()) { cfgfile = name; } else { // Fall back to full path / resources. cfgfile = pkg.replace('.', File.separatorChar) + File.separatorChar + name; } try { InputStream cfgdata = openSystemFile(cfgfile); logManager.readConfiguration(cfgdata); // also load as properties for us, to get debug flag. InputStream cfgdata2 = openSystemFile(cfgfile); Properties cfgprop = new Properties(); cfgprop.load(cfgdata2); DEBUG = Boolean.parseBoolean(cfgprop.getProperty("debug")); logger.info("Logging configuration read."); } catch(FileNotFoundException e) { logger.log(Level.SEVERE, "Could not find logging configuration file: " + cfgfile, e); } catch(Exception e) { logger.log(Level.SEVERE, "Failed to configure logging from file: " + cfgfile, e); } }
[ "private", "void", "privateReconfigureLogging", "(", "String", "pkg", ",", "final", "String", "name", ")", "{", "LogManager", "logManager", "=", "LogManager", ".", "getLogManager", "(", ")", ";", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "Loggi...
Reconfigure logging. @param pkg Package name the configuration file comes from @param name File name.
[ "Reconfigure", "logging", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java#L107-L141
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java
LoggingConfiguration.openSystemFile
private static InputStream openSystemFile(String filename) throws FileNotFoundException { try { return new FileInputStream(filename); } catch(FileNotFoundException e) { // try with classloader String resname = File.separatorChar != '/' ? filename.replace(File.separatorChar, '/') : filename; ClassLoader cl = LoggingConfiguration.class.getClassLoader(); InputStream result = cl.getResourceAsStream(resname); if(result != null) { return result; } // Sometimes, URLClassLoader does not work right. Try harder: URL u = cl.getResource(resname); if(u == null) { throw e; } try { URLConnection conn = u.openConnection(); conn.setUseCaches(false); result = conn.getInputStream(); if(result != null) { return result; } } catch(IOException x) { throw e; // Throw original error instead. } throw e; } }
java
private static InputStream openSystemFile(String filename) throws FileNotFoundException { try { return new FileInputStream(filename); } catch(FileNotFoundException e) { // try with classloader String resname = File.separatorChar != '/' ? filename.replace(File.separatorChar, '/') : filename; ClassLoader cl = LoggingConfiguration.class.getClassLoader(); InputStream result = cl.getResourceAsStream(resname); if(result != null) { return result; } // Sometimes, URLClassLoader does not work right. Try harder: URL u = cl.getResource(resname); if(u == null) { throw e; } try { URLConnection conn = u.openConnection(); conn.setUseCaches(false); result = conn.getInputStream(); if(result != null) { return result; } } catch(IOException x) { throw e; // Throw original error instead. } throw e; } }
[ "private", "static", "InputStream", "openSystemFile", "(", "String", "filename", ")", "throws", "FileNotFoundException", "{", "try", "{", "return", "new", "FileInputStream", "(", "filename", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "/...
Private copy from FileUtil, to avoid cross-dependencies. Try to open a file, first trying the file system, then falling back to the classpath. @param filename File name in system notation @return Input stream @throws FileNotFoundException When no file was found.
[ "Private", "copy", "from", "FileUtil", "to", "avoid", "cross", "-", "dependencies", ".", "Try", "to", "open", "a", "file", "first", "trying", "the", "file", "system", "then", "falling", "back", "to", "the", "classpath", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java#L151-L181
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java
LoggingConfiguration.setVerbose
public static void setVerbose(java.util.logging.Level verbose) { if(verbose.intValue() <= Level.VERBOSE.intValue()) { // decrease to VERBOSE if it was higher, otherwise further to // VERYVERBOSE if(LOGGER_GLOBAL_TOP.getLevel() == null || LOGGER_GLOBAL_TOP.getLevel().intValue() > verbose.intValue()) { LOGGER_GLOBAL_TOP.setLevel(verbose); } if(LOGGER_ELKI_TOP.getLevel() == null || LOGGER_ELKI_TOP.getLevel().intValue() > verbose.intValue()) { LOGGER_ELKI_TOP.setLevel(verbose); } } else { // re-increase to given level if it was verbose or "very verbose". if(LOGGER_GLOBAL_TOP.getLevel() != null && (// Level.VERBOSE.equals(LOGGER_GLOBAL_TOP.getLevel()) || // Level.VERYVERBOSE.equals(LOGGER_GLOBAL_TOP.getLevel()) // )) { LOGGER_GLOBAL_TOP.setLevel(verbose); } if(LOGGER_ELKI_TOP.getLevel() != null && (// Level.VERBOSE.equals(LOGGER_ELKI_TOP.getLevel()) || // Level.VERYVERBOSE.equals(LOGGER_ELKI_TOP.getLevel()) // )) { LOGGER_ELKI_TOP.setLevel(verbose); } } }
java
public static void setVerbose(java.util.logging.Level verbose) { if(verbose.intValue() <= Level.VERBOSE.intValue()) { // decrease to VERBOSE if it was higher, otherwise further to // VERYVERBOSE if(LOGGER_GLOBAL_TOP.getLevel() == null || LOGGER_GLOBAL_TOP.getLevel().intValue() > verbose.intValue()) { LOGGER_GLOBAL_TOP.setLevel(verbose); } if(LOGGER_ELKI_TOP.getLevel() == null || LOGGER_ELKI_TOP.getLevel().intValue() > verbose.intValue()) { LOGGER_ELKI_TOP.setLevel(verbose); } } else { // re-increase to given level if it was verbose or "very verbose". if(LOGGER_GLOBAL_TOP.getLevel() != null && (// Level.VERBOSE.equals(LOGGER_GLOBAL_TOP.getLevel()) || // Level.VERYVERBOSE.equals(LOGGER_GLOBAL_TOP.getLevel()) // )) { LOGGER_GLOBAL_TOP.setLevel(verbose); } if(LOGGER_ELKI_TOP.getLevel() != null && (// Level.VERBOSE.equals(LOGGER_ELKI_TOP.getLevel()) || // Level.VERYVERBOSE.equals(LOGGER_ELKI_TOP.getLevel()) // )) { LOGGER_ELKI_TOP.setLevel(verbose); } } }
[ "public", "static", "void", "setVerbose", "(", "java", ".", "util", ".", "logging", ".", "Level", "verbose", ")", "{", "if", "(", "verbose", ".", "intValue", "(", ")", "<=", "Level", ".", "VERBOSE", ".", "intValue", "(", ")", ")", "{", "// decrease to ...
Reconfigure logging to enable 'verbose' logging at the top level. @param verbose verbosity level.
[ "Reconfigure", "logging", "to", "enable", "verbose", "logging", "at", "the", "top", "level", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java#L195-L221
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java
LoggingConfiguration.setStatistics
public static void setStatistics() { // decrease to INFO if it was higher if(LOGGER_GLOBAL_TOP.getLevel() == null || LOGGER_GLOBAL_TOP.getLevel().intValue() > Level.STATISTICS.intValue()) { LOGGER_GLOBAL_TOP.setLevel(Level.STATISTICS); } if(LOGGER_ELKI_TOP.getLevel() == null || LOGGER_ELKI_TOP.getLevel().intValue() > Level.STATISTICS.intValue()) { LOGGER_ELKI_TOP.setLevel(Level.STATISTICS); } if(LOGGER_TIME_TOP.getLevel() == null || LOGGER_TIME_TOP.getLevel().intValue() > Level.STATISTICS.intValue()) { LOGGER_TIME_TOP.setLevel(Level.STATISTICS); } }
java
public static void setStatistics() { // decrease to INFO if it was higher if(LOGGER_GLOBAL_TOP.getLevel() == null || LOGGER_GLOBAL_TOP.getLevel().intValue() > Level.STATISTICS.intValue()) { LOGGER_GLOBAL_TOP.setLevel(Level.STATISTICS); } if(LOGGER_ELKI_TOP.getLevel() == null || LOGGER_ELKI_TOP.getLevel().intValue() > Level.STATISTICS.intValue()) { LOGGER_ELKI_TOP.setLevel(Level.STATISTICS); } if(LOGGER_TIME_TOP.getLevel() == null || LOGGER_TIME_TOP.getLevel().intValue() > Level.STATISTICS.intValue()) { LOGGER_TIME_TOP.setLevel(Level.STATISTICS); } }
[ "public", "static", "void", "setStatistics", "(", ")", "{", "// decrease to INFO if it was higher", "if", "(", "LOGGER_GLOBAL_TOP", ".", "getLevel", "(", ")", "==", "null", "||", "LOGGER_GLOBAL_TOP", ".", "getLevel", "(", ")", ".", "intValue", "(", ")", ">", "...
Enable runtime performance logging.
[ "Enable", "runtime", "performance", "logging", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java#L226-L237
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java
LoggingConfiguration.replaceDefaultHandler
public static void replaceDefaultHandler(Handler handler) { Logger rootlogger = LogManager.getLogManager().getLogger(""); for(Handler h : rootlogger.getHandlers()) { if(h instanceof CLISmartHandler) { rootlogger.removeHandler(h); } } addHandler(handler); }
java
public static void replaceDefaultHandler(Handler handler) { Logger rootlogger = LogManager.getLogManager().getLogger(""); for(Handler h : rootlogger.getHandlers()) { if(h instanceof CLISmartHandler) { rootlogger.removeHandler(h); } } addHandler(handler); }
[ "public", "static", "void", "replaceDefaultHandler", "(", "Handler", "handler", ")", "{", "Logger", "rootlogger", "=", "LogManager", ".", "getLogManager", "(", ")", ".", "getLogger", "(", "\"\"", ")", ";", "for", "(", "Handler", "h", ":", "rootlogger", ".", ...
Replace the default log handler with the given log handler. This will remove all {@link CLISmartHandler} found on the root logger. It will leave any other handlers in place. @param handler Logging handler.
[ "Replace", "the", "default", "log", "handler", "with", "the", "given", "log", "handler", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java#L256-L264
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java
LoggingConfiguration.setDefaultLevel
public static void setDefaultLevel(java.util.logging.Level level) { Logger.getLogger(TOPLEVEL_PACKAGE).setLevel(level); }
java
public static void setDefaultLevel(java.util.logging.Level level) { Logger.getLogger(TOPLEVEL_PACKAGE).setLevel(level); }
[ "public", "static", "void", "setDefaultLevel", "(", "java", ".", "util", ".", "logging", ".", "Level", "level", ")", "{", "Logger", ".", "getLogger", "(", "TOPLEVEL_PACKAGE", ")", ".", "setLevel", "(", "level", ")", ";", "}" ]
Set the default level. @param level level
[ "Set", "the", "default", "level", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/LoggingConfiguration.java#L288-L290
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/BatikUtil.java
BatikUtil.getRelativeCoordinates
public static double[] getRelativeCoordinates(Event evt, Element reference) { if(evt instanceof DOMMouseEvent && reference instanceof SVGLocatable && reference instanceof SVGElement) { // Get the screen (pixel!) coordinates DOMMouseEvent gnme = (DOMMouseEvent) evt; SVGMatrix mat = ((SVGLocatable) reference).getScreenCTM(); SVGMatrix imat = mat.inverse(); SVGPoint cPt = ((SVGElement) reference).getOwnerSVGElement().createSVGPoint(); cPt.setX(gnme.getClientX()); cPt.setY(gnme.getClientY()); // Have Batik transform the screen (pixel!) coordinates into SVG element // coordinates cPt = cPt.matrixTransform(imat); return new double[] { cPt.getX(), cPt.getY() }; } return null; }
java
public static double[] getRelativeCoordinates(Event evt, Element reference) { if(evt instanceof DOMMouseEvent && reference instanceof SVGLocatable && reference instanceof SVGElement) { // Get the screen (pixel!) coordinates DOMMouseEvent gnme = (DOMMouseEvent) evt; SVGMatrix mat = ((SVGLocatable) reference).getScreenCTM(); SVGMatrix imat = mat.inverse(); SVGPoint cPt = ((SVGElement) reference).getOwnerSVGElement().createSVGPoint(); cPt.setX(gnme.getClientX()); cPt.setY(gnme.getClientY()); // Have Batik transform the screen (pixel!) coordinates into SVG element // coordinates cPt = cPt.matrixTransform(imat); return new double[] { cPt.getX(), cPt.getY() }; } return null; }
[ "public", "static", "double", "[", "]", "getRelativeCoordinates", "(", "Event", "evt", ",", "Element", "reference", ")", "{", "if", "(", "evt", "instanceof", "DOMMouseEvent", "&&", "reference", "instanceof", "SVGLocatable", "&&", "reference", "instanceof", "SVGEle...
Get the relative coordinates of a point within the coordinate system of a particular SVG Element. @param evt Event, needs to be a DOMMouseEvent @param reference SVG Element the coordinate system is used of @return Array containing the X and Y values
[ "Get", "the", "relative", "coordinates", "of", "a", "point", "within", "the", "coordinate", "system", "of", "a", "particular", "SVG", "Element", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/BatikUtil.java#L53-L69
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/BIRCHLeafClustering.java
BIRCHLeafClustering.run
public Clustering<MeanModel> run(Relation<NumberVector> relation) { final int dim = RelationUtil.dimensionality(relation); CFTree tree = cffactory.newTree(relation.getDBIDs(), relation); // The CFTree does not store points. We have to reassign them (and the // quality is better than if we used the initial assignment, because centers // move in particular in the beginning, so we always had many outliers. Map<ClusteringFeature, ModifiableDBIDs> idmap = new HashMap<ClusteringFeature, ModifiableDBIDs>(tree.leaves); for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { ClusteringFeature cf = tree.findLeaf(relation.get(iter)); ModifiableDBIDs ids = idmap.get(cf); if(ids == null) { idmap.put(cf, ids = DBIDUtil.newArray(cf.n)); } ids.add(iter); } Clustering<MeanModel> result = new Clustering<>("BIRCH-leaves", "BIRCH leaves"); for(Map.Entry<ClusteringFeature, ModifiableDBIDs> ent : idmap.entrySet()) { ClusteringFeature leaf = ent.getKey(); double[] center = new double[dim]; for(int i = 0; i < dim; i++) { center[i] = leaf.centroid(i); } result.addToplevelCluster(new Cluster<>(ent.getValue(), new MeanModel(center))); } return result; }
java
public Clustering<MeanModel> run(Relation<NumberVector> relation) { final int dim = RelationUtil.dimensionality(relation); CFTree tree = cffactory.newTree(relation.getDBIDs(), relation); // The CFTree does not store points. We have to reassign them (and the // quality is better than if we used the initial assignment, because centers // move in particular in the beginning, so we always had many outliers. Map<ClusteringFeature, ModifiableDBIDs> idmap = new HashMap<ClusteringFeature, ModifiableDBIDs>(tree.leaves); for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { ClusteringFeature cf = tree.findLeaf(relation.get(iter)); ModifiableDBIDs ids = idmap.get(cf); if(ids == null) { idmap.put(cf, ids = DBIDUtil.newArray(cf.n)); } ids.add(iter); } Clustering<MeanModel> result = new Clustering<>("BIRCH-leaves", "BIRCH leaves"); for(Map.Entry<ClusteringFeature, ModifiableDBIDs> ent : idmap.entrySet()) { ClusteringFeature leaf = ent.getKey(); double[] center = new double[dim]; for(int i = 0; i < dim; i++) { center[i] = leaf.centroid(i); } result.addToplevelCluster(new Cluster<>(ent.getValue(), new MeanModel(center))); } return result; }
[ "public", "Clustering", "<", "MeanModel", ">", "run", "(", "Relation", "<", "NumberVector", ">", "relation", ")", "{", "final", "int", "dim", "=", "RelationUtil", ".", "dimensionality", "(", "relation", ")", ";", "CFTree", "tree", "=", "cffactory", ".", "n...
Run the clustering algorithm. @param relation Input data @return Clustering
[ "Run", "the", "clustering", "algorithm", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/BIRCHLeafClustering.java#L100-L125
train
elki-project/elki
addons/tutorial/src/main/java/tutorial/outlier/DistanceStddevOutlier.java
DistanceStddevOutlier.run
public OutlierResult run(Database database, Relation<O> relation) { // Get a nearest neighbor query on the relation. KNNQuery<O> knnq = QueryUtil.getKNNQuery(relation, getDistanceFunction(), k); // Output data storage WritableDoubleDataStore scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_DB); // Track minimum and maximum scores DoubleMinMax minmax = new DoubleMinMax(); // Iterate over all objects for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { KNNList neighbors = knnq.getKNNForDBID(iter, k); // Aggregate distances MeanVariance mv = new MeanVariance(); for(DoubleDBIDListIter neighbor = neighbors.iter(); neighbor.valid(); neighbor.advance()) { // Skip the object itself. The 0 is not very informative. if(DBIDUtil.equal(iter, neighbor)) { continue; } mv.put(neighbor.doubleValue()); } // Store score scores.putDouble(iter, mv.getSampleStddev()); } // Wrap the result in the standard containers // Actual min-max, theoretical min-max! OutlierScoreMeta meta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0, Double.POSITIVE_INFINITY); DoubleRelation rel = new MaterializedDoubleRelation(relation.getDBIDs(), "stddev-outlier", scores); return new OutlierResult(meta, rel); }
java
public OutlierResult run(Database database, Relation<O> relation) { // Get a nearest neighbor query on the relation. KNNQuery<O> knnq = QueryUtil.getKNNQuery(relation, getDistanceFunction(), k); // Output data storage WritableDoubleDataStore scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_DB); // Track minimum and maximum scores DoubleMinMax minmax = new DoubleMinMax(); // Iterate over all objects for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { KNNList neighbors = knnq.getKNNForDBID(iter, k); // Aggregate distances MeanVariance mv = new MeanVariance(); for(DoubleDBIDListIter neighbor = neighbors.iter(); neighbor.valid(); neighbor.advance()) { // Skip the object itself. The 0 is not very informative. if(DBIDUtil.equal(iter, neighbor)) { continue; } mv.put(neighbor.doubleValue()); } // Store score scores.putDouble(iter, mv.getSampleStddev()); } // Wrap the result in the standard containers // Actual min-max, theoretical min-max! OutlierScoreMeta meta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0, Double.POSITIVE_INFINITY); DoubleRelation rel = new MaterializedDoubleRelation(relation.getDBIDs(), "stddev-outlier", scores); return new OutlierResult(meta, rel); }
[ "public", "OutlierResult", "run", "(", "Database", "database", ",", "Relation", "<", "O", ">", "relation", ")", "{", "// Get a nearest neighbor query on the relation.", "KNNQuery", "<", "O", ">", "knnq", "=", "QueryUtil", ".", "getKNNQuery", "(", "relation", ",", ...
Run the outlier detection algorithm @param database Database to use @param relation Relation to analyze @return Outlier score result
[ "Run", "the", "outlier", "detection", "algorithm" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/tutorial/src/main/java/tutorial/outlier/DistanceStddevOutlier.java#L90-L119
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/application/ELKILauncher.java
ELKILauncher.main
public static void main(String[] args) { if(args.length > 0 && args[0].charAt(0) != '-') { Class<?> cls = ELKIServiceRegistry.findImplementation(AbstractApplication.class, args[0]); if(cls != null) { try { Method m = cls.getMethod("main", String[].class); Object a = Arrays.copyOfRange(args, 1, args.length); m.invoke(null, a); } catch(InvocationTargetException e) { LoggingUtil.exception(e.getCause()); } catch(Exception e) { LoggingUtil.exception(e); } return; } } try { Method m = DEFAULT_APPLICATION.getMethod("main", String[].class); m.invoke(null, (Object) args); } catch(Exception e) { LoggingUtil.exception(e); } }
java
public static void main(String[] args) { if(args.length > 0 && args[0].charAt(0) != '-') { Class<?> cls = ELKIServiceRegistry.findImplementation(AbstractApplication.class, args[0]); if(cls != null) { try { Method m = cls.getMethod("main", String[].class); Object a = Arrays.copyOfRange(args, 1, args.length); m.invoke(null, a); } catch(InvocationTargetException e) { LoggingUtil.exception(e.getCause()); } catch(Exception e) { LoggingUtil.exception(e); } return; } } try { Method m = DEFAULT_APPLICATION.getMethod("main", String[].class); m.invoke(null, (Object) args); } catch(Exception e) { LoggingUtil.exception(e); } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", ">", "0", "&&", "args", "[", "0", "]", ".", "charAt", "(", "0", ")", "!=", "'", "'", ")", "{", "Class", "<", "?", ">", "cls", "...
Launch ELKI. @param args Command line arguments.
[ "Launch", "ELKI", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/application/ELKILauncher.java#L70-L95
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ClassGenericsUtil.java
ClassGenericsUtil.getParameterizer
public static Parameterizer getParameterizer(Class<?> c) { for(Class<?> inner : c.getDeclaredClasses()) { if(Parameterizer.class.isAssignableFrom(inner)) { try { return inner.asSubclass(Parameterizer.class).newInstance(); } catch(Exception e) { LOG.warning("Non-usable Parameterizer in class: " + c.getName()); } } } return null; }
java
public static Parameterizer getParameterizer(Class<?> c) { for(Class<?> inner : c.getDeclaredClasses()) { if(Parameterizer.class.isAssignableFrom(inner)) { try { return inner.asSubclass(Parameterizer.class).newInstance(); } catch(Exception e) { LOG.warning("Non-usable Parameterizer in class: " + c.getName()); } } } return null; }
[ "public", "static", "Parameterizer", "getParameterizer", "(", "Class", "<", "?", ">", "c", ")", "{", "for", "(", "Class", "<", "?", ">", "inner", ":", "c", ".", "getDeclaredClasses", "(", ")", ")", "{", "if", "(", "Parameterizer", ".", "class", ".", ...
Get a parameterizer for the given class. @param c Class @return Parameterizer or null.
[ "Get", "a", "parameterizer", "for", "the", "given", "class", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ClassGenericsUtil.java#L145-L157
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/hierarchy/HashMapHierarchy.java
HashMapHierarchy.putRec
private void putRec(O obj, Rec<O> rec) { graph.put(obj, rec); for(int i = 0; i < numelems; ++i) { if(obj == elems[i]) { return; } } if(elems.length == numelems) { elems = Arrays.copyOf(elems, (elems.length << 1) + 1); } elems[numelems++] = obj; }
java
private void putRec(O obj, Rec<O> rec) { graph.put(obj, rec); for(int i = 0; i < numelems; ++i) { if(obj == elems[i]) { return; } } if(elems.length == numelems) { elems = Arrays.copyOf(elems, (elems.length << 1) + 1); } elems[numelems++] = obj; }
[ "private", "void", "putRec", "(", "O", "obj", ",", "Rec", "<", "O", ">", "rec", ")", "{", "graph", ".", "put", "(", "obj", ",", "rec", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numelems", ";", "++", "i", ")", "{", "if", ...
Put a record. @param obj Key @param rec Record
[ "Put", "a", "record", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/hierarchy/HashMapHierarchy.java#L246-L257
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/hierarchy/HashMapHierarchy.java
HashMapHierarchy.removeRec
private void removeRec(O obj) { graph.remove(obj); for(int i = 0; i < numelems; ++i) { if(obj == elems[i]) { System.arraycopy(elems, i + 1, elems, i, --numelems - i); elems[numelems] = null; return; } } }
java
private void removeRec(O obj) { graph.remove(obj); for(int i = 0; i < numelems; ++i) { if(obj == elems[i]) { System.arraycopy(elems, i + 1, elems, i, --numelems - i); elems[numelems] = null; return; } } }
[ "private", "void", "removeRec", "(", "O", "obj", ")", "{", "graph", ".", "remove", "(", "obj", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numelems", ";", "++", "i", ")", "{", "if", "(", "obj", "==", "elems", "[", "i", "]", ...
Remove a record. @param obj Key
[ "Remove", "a", "record", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/hierarchy/HashMapHierarchy.java#L264-L273
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java
TreePopup.createTree
protected JTree createTree() { JTree tree = new JTree(model); tree.setName("TreePopup.tree"); tree.setFont(getFont()); tree.setForeground(getForeground()); tree.setBackground(getBackground()); tree.setBorder(null); tree.setFocusable(true); tree.addMouseListener(handler); tree.addKeyListener(handler); tree.setCellRenderer(new Renderer()); return tree; }
java
protected JTree createTree() { JTree tree = new JTree(model); tree.setName("TreePopup.tree"); tree.setFont(getFont()); tree.setForeground(getForeground()); tree.setBackground(getBackground()); tree.setBorder(null); tree.setFocusable(true); tree.addMouseListener(handler); tree.addKeyListener(handler); tree.setCellRenderer(new Renderer()); return tree; }
[ "protected", "JTree", "createTree", "(", ")", "{", "JTree", "tree", "=", "new", "JTree", "(", "model", ")", ";", "tree", ".", "setName", "(", "\"TreePopup.tree\"", ")", ";", "tree", ".", "setFont", "(", "getFont", "(", ")", ")", ";", "tree", ".", "se...
Creates the JList used in the popup to display the items in the combo box model. This method is called when the UI class is created. @return a <code>JList</code> used to display the combo box items
[ "Creates", "the", "JList", "used", "in", "the", "popup", "to", "display", "the", "items", "in", "the", "combo", "box", "model", ".", "This", "method", "is", "called", "when", "the", "UI", "class", "is", "created", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java#L141-L153
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java
TreePopup.createScroller
protected JScrollPane createScroller() { JScrollPane sp = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); sp.setHorizontalScrollBar(null); sp.setName("TreePopup.scrollPane"); sp.setFocusable(false); sp.getVerticalScrollBar().setFocusable(false); sp.setBorder(null); return sp; }
java
protected JScrollPane createScroller() { JScrollPane sp = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); sp.setHorizontalScrollBar(null); sp.setName("TreePopup.scrollPane"); sp.setFocusable(false); sp.getVerticalScrollBar().setFocusable(false); sp.setBorder(null); return sp; }
[ "protected", "JScrollPane", "createScroller", "(", ")", "{", "JScrollPane", "sp", "=", "new", "JScrollPane", "(", "tree", ",", "ScrollPaneConstants", ".", "VERTICAL_SCROLLBAR_AS_NEEDED", ",", "ScrollPaneConstants", ".", "HORIZONTAL_SCROLLBAR_NEVER", ")", ";", "sp", "....
Creates the scroll pane which houses the scrollable tree.
[ "Creates", "the", "scroll", "pane", "which", "houses", "the", "scrollable", "tree", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java#L171-L179
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java
TreePopup.show
public void show(Component parent) { Dimension parentSize = parent.getSize(); Insets insets = getInsets(); // reduce the width of the scrollpane by the insets so that the popup // is the same width as the combo box. parentSize.setSize(parentSize.width - (insets.right + insets.left), 10 * parentSize.height); Dimension scrollSize = computePopupBounds(parent, 0, getBounds().height, parentSize.width, parentSize.height).getSize(); scroller.setMaximumSize(scrollSize); scroller.setPreferredSize(scrollSize); scroller.setMinimumSize(scrollSize); super.show(parent, 0, parent.getHeight()); tree.requestFocusInWindow(); }
java
public void show(Component parent) { Dimension parentSize = parent.getSize(); Insets insets = getInsets(); // reduce the width of the scrollpane by the insets so that the popup // is the same width as the combo box. parentSize.setSize(parentSize.width - (insets.right + insets.left), 10 * parentSize.height); Dimension scrollSize = computePopupBounds(parent, 0, getBounds().height, parentSize.width, parentSize.height).getSize(); scroller.setMaximumSize(scrollSize); scroller.setPreferredSize(scrollSize); scroller.setMinimumSize(scrollSize); super.show(parent, 0, parent.getHeight()); tree.requestFocusInWindow(); }
[ "public", "void", "show", "(", "Component", "parent", ")", "{", "Dimension", "parentSize", "=", "parent", ".", "getSize", "(", ")", ";", "Insets", "insets", "=", "getInsets", "(", ")", ";", "// reduce the width of the scrollpane by the insets so that the popup", "//...
Display the popup, attached to the given component. @param parent Parent component
[ "Display", "the", "popup", "attached", "to", "the", "given", "component", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java#L195-L210
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java
TreePopup.fireActionPerformed
protected void fireActionPerformed(ActionEvent event) { Object[] listeners = listenerList.getListenerList(); for(int i = listeners.length - 2; i >= 0; i -= 2) { if(listeners[i] == ActionListener.class) { ((ActionListener) listeners[i + 1]).actionPerformed(event); } } }
java
protected void fireActionPerformed(ActionEvent event) { Object[] listeners = listenerList.getListenerList(); for(int i = listeners.length - 2; i >= 0; i -= 2) { if(listeners[i] == ActionListener.class) { ((ActionListener) listeners[i + 1]).actionPerformed(event); } } }
[ "protected", "void", "fireActionPerformed", "(", "ActionEvent", "event", ")", "{", "Object", "[", "]", "listeners", "=", "listenerList", ".", "getListenerList", "(", ")", ";", "for", "(", "int", "i", "=", "listeners", ".", "length", "-", "2", ";", "i", "...
Notify action listeners. @param event the <code>ActionEvent</code> object
[ "Notify", "action", "listeners", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/TreePopup.java#L262-L269
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/style/PropertiesBasedStyleLibrary.java
PropertiesBasedStyleLibrary.setCached
private <T> void setCached(String prefix, String postfix, T data) { cache.put(prefix + '.' + postfix, data); }
java
private <T> void setCached(String prefix, String postfix, T data) { cache.put(prefix + '.' + postfix, data); }
[ "private", "<", "T", ">", "void", "setCached", "(", "String", "prefix", ",", "String", "postfix", ",", "T", "data", ")", "{", "cache", ".", "put", "(", "prefix", "+", "'", "'", "+", "postfix", ",", "data", ")", ";", "}" ]
Set a cache value @param <T> Type @param prefix Tree name @param postfix Property name @param data Data
[ "Set", "a", "cache", "value" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/style/PropertiesBasedStyleLibrary.java#L181-L183
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/style/PropertiesBasedStyleLibrary.java
PropertiesBasedStyleLibrary.getPropertyValue
protected String getPropertyValue(String prefix, String postfix) { String ret = properties.getProperty(prefix + "." + postfix); if (ret != null) { // logger.debugFine("Found property: "+prefix + "." + // postfix+" for "+prefix); return ret; } int pos = prefix.length(); while (pos > 0) { pos = prefix.lastIndexOf('.', pos - 1); if (pos <= 0) { break; } ret = properties.getProperty(prefix.substring(0, pos) + '.' + postfix); if (ret != null) { // logger.debugFine("Found property: "+prefix.substring(0, pos) + "." + // postfix+" for "+prefix); return ret; } } ret = properties.getProperty(postfix); if (ret != null) { // logger.debugFine("Found property: "+postfix+" for "+prefix); return ret; } return null; }
java
protected String getPropertyValue(String prefix, String postfix) { String ret = properties.getProperty(prefix + "." + postfix); if (ret != null) { // logger.debugFine("Found property: "+prefix + "." + // postfix+" for "+prefix); return ret; } int pos = prefix.length(); while (pos > 0) { pos = prefix.lastIndexOf('.', pos - 1); if (pos <= 0) { break; } ret = properties.getProperty(prefix.substring(0, pos) + '.' + postfix); if (ret != null) { // logger.debugFine("Found property: "+prefix.substring(0, pos) + "." + // postfix+" for "+prefix); return ret; } } ret = properties.getProperty(postfix); if (ret != null) { // logger.debugFine("Found property: "+postfix+" for "+prefix); return ret; } return null; }
[ "protected", "String", "getPropertyValue", "(", "String", "prefix", ",", "String", "postfix", ")", "{", "String", "ret", "=", "properties", ".", "getProperty", "(", "prefix", "+", "\".\"", "+", "postfix", ")", ";", "if", "(", "ret", "!=", "null", ")", "{...
Retrieve the property value for a particular path + type pair. @param prefix Path @param postfix Type @return Value
[ "Retrieve", "the", "property", "value", "for", "a", "particular", "path", "+", "type", "pair", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/style/PropertiesBasedStyleLibrary.java#L192-L218
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/FilterUtil.java
FilterUtil.guessFactory
@SuppressWarnings("unchecked") public static <V extends NumberVector> NumberVector.Factory<V> guessFactory(SimpleTypeInformation<V> in) { NumberVector.Factory<V> factory = null; if(in instanceof VectorTypeInformation) { factory = (NumberVector.Factory<V>) ((VectorTypeInformation<V>) in).getFactory(); } if(factory == null) { // FIXME: hack. Add factories to simple type information, too? try { Field f = in.getRestrictionClass().getField("FACTORY"); factory = (NumberVector.Factory<V>) f.get(null); } catch(Exception e) { LoggingUtil.warning("Cannot determine factory for type " + in.getRestrictionClass(), e); } } return factory; }
java
@SuppressWarnings("unchecked") public static <V extends NumberVector> NumberVector.Factory<V> guessFactory(SimpleTypeInformation<V> in) { NumberVector.Factory<V> factory = null; if(in instanceof VectorTypeInformation) { factory = (NumberVector.Factory<V>) ((VectorTypeInformation<V>) in).getFactory(); } if(factory == null) { // FIXME: hack. Add factories to simple type information, too? try { Field f = in.getRestrictionClass().getField("FACTORY"); factory = (NumberVector.Factory<V>) f.get(null); } catch(Exception e) { LoggingUtil.warning("Cannot determine factory for type " + in.getRestrictionClass(), e); } } return factory; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "V", "extends", "NumberVector", ">", "NumberVector", ".", "Factory", "<", "V", ">", "guessFactory", "(", "SimpleTypeInformation", "<", "V", ">", "in", ")", "{", "NumberVector", ".", ...
Try to guess the appropriate factory. @param in Input type @param <V> Vector type @return Factory
[ "Try", "to", "guess", "the", "appropriate", "factory", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/FilterUtil.java#L54-L71
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/MultipleObjectsBundle.java
MultipleObjectsBundle.appendSimple
public void appendSimple(Object... data) { if(data.length != meta.size()) { throw new AbortException("Invalid number of attributes in 'append'."); } for(int i = 0; i < data.length; i++) { @SuppressWarnings("unchecked") final List<Object> col = (List<Object>) columns.get(i); col.add(data[i]); } }
java
public void appendSimple(Object... data) { if(data.length != meta.size()) { throw new AbortException("Invalid number of attributes in 'append'."); } for(int i = 0; i < data.length; i++) { @SuppressWarnings("unchecked") final List<Object> col = (List<Object>) columns.get(i); col.add(data[i]); } }
[ "public", "void", "appendSimple", "(", "Object", "...", "data", ")", "{", "if", "(", "data", ".", "length", "!=", "meta", ".", "size", "(", ")", ")", "{", "throw", "new", "AbortException", "(", "\"Invalid number of attributes in 'append'.\"", ")", ";", "}", ...
Append a new record to the data set. Pay attention to having the right number of values! @param data Data to append
[ "Append", "a", "new", "record", "to", "the", "data", "set", ".", "Pay", "attention", "to", "having", "the", "right", "number", "of", "values!" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/MultipleObjectsBundle.java#L115-L124
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/MultipleObjectsBundle.java
MultipleObjectsBundle.fromStream
public static MultipleObjectsBundle fromStream(BundleStreamSource source) { MultipleObjectsBundle bundle = new MultipleObjectsBundle(); boolean stop = false; DBIDVar var = null; ArrayModifiableDBIDs ids = null; int size = 0; while(!stop) { BundleStreamSource.Event ev = source.nextEvent(); switch(ev){ case END_OF_STREAM: stop = true; break; case META_CHANGED: BundleMeta smeta = source.getMeta(); // rebuild bundle meta bundle.meta = new BundleMeta(); for(int i = 0; i < bundle.columns.size(); i++) { bundle.meta.add(smeta.get(i)); } for(int i = bundle.metaLength(); i < smeta.size(); i++) { List<Object> data = new ArrayList<>(bundle.dataLength() + 1); bundle.appendColumn(smeta.get(i), data); } if(var == null && source.hasDBIDs()) { var = DBIDUtil.newVar(); ids = DBIDUtil.newArray(); } continue; case NEXT_OBJECT: if(var != null && source.assignDBID(var)) { ids.add(var); } for(int i = 0; i < bundle.metaLength(); i++) { @SuppressWarnings("unchecked") final List<Object> col = (List<Object>) bundle.columns.get(i); col.add(source.data(i)); } ++size; continue; default: LoggingUtil.warning("Unknown event: " + ev); continue; } } if(ids != null) { if(size != ids.size()) { LOG.warning("Not every object had an DBID - discarding DBIDs: " + size + " != " + ids.size()); } else { bundle.setDBIDs(ids); } } return bundle; }
java
public static MultipleObjectsBundle fromStream(BundleStreamSource source) { MultipleObjectsBundle bundle = new MultipleObjectsBundle(); boolean stop = false; DBIDVar var = null; ArrayModifiableDBIDs ids = null; int size = 0; while(!stop) { BundleStreamSource.Event ev = source.nextEvent(); switch(ev){ case END_OF_STREAM: stop = true; break; case META_CHANGED: BundleMeta smeta = source.getMeta(); // rebuild bundle meta bundle.meta = new BundleMeta(); for(int i = 0; i < bundle.columns.size(); i++) { bundle.meta.add(smeta.get(i)); } for(int i = bundle.metaLength(); i < smeta.size(); i++) { List<Object> data = new ArrayList<>(bundle.dataLength() + 1); bundle.appendColumn(smeta.get(i), data); } if(var == null && source.hasDBIDs()) { var = DBIDUtil.newVar(); ids = DBIDUtil.newArray(); } continue; case NEXT_OBJECT: if(var != null && source.assignDBID(var)) { ids.add(var); } for(int i = 0; i < bundle.metaLength(); i++) { @SuppressWarnings("unchecked") final List<Object> col = (List<Object>) bundle.columns.get(i); col.add(source.data(i)); } ++size; continue; default: LoggingUtil.warning("Unknown event: " + ev); continue; } } if(ids != null) { if(size != ids.size()) { LOG.warning("Not every object had an DBID - discarding DBIDs: " + size + " != " + ids.size()); } else { bundle.setDBIDs(ids); } } return bundle; }
[ "public", "static", "MultipleObjectsBundle", "fromStream", "(", "BundleStreamSource", "source", ")", "{", "MultipleObjectsBundle", "bundle", "=", "new", "MultipleObjectsBundle", "(", ")", ";", "boolean", "stop", "=", "false", ";", "DBIDVar", "var", "=", "null", ";...
Convert an object stream to a bundle @param source Object stream @return Static bundle
[ "Convert", "an", "object", "stream", "to", "a", "bundle" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/MultipleObjectsBundle.java#L233-L286
train