summaryrefslogtreecommitdiff
path: root/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter')
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDRefIter.java39
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDsTest.java59
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DecreasingVectorIter.java116
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DistanceResultAdapter.java92
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/FilteredDistanceResultAdapter.java76
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/IncreasingVectorIter.java116
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/OutlierScoreAdapter.java103
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/SimpleAdapter.java89
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorNonZero.java44
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorOverThreshold.java79
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorZero.java71
-rw-r--r--src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/package-info.java26
12 files changed, 910 insertions, 0 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDRefIter.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDRefIter.java
new file mode 100644
index 00000000..2fdb5978
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDRefIter.java
@@ -0,0 +1,39 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import de.lmu.ifi.dbs.elki.database.ids.DBIDRef;
+
+/**
+ * A score iterator wrapping a DBIDRef object.
+ *
+ * @author Erich Schubert
+ */
+public interface DBIDRefIter {
+ /**
+ * Get the current DBIDRef.
+ *
+ * @return DBID reference
+ */
+ DBIDRef getRef();
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDsTest.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDsTest.java
new file mode 100644
index 00000000..d41c7af4
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DBIDsTest.java
@@ -0,0 +1,59 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import de.lmu.ifi.dbs.elki.database.ids.DBIDs;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.Predicate;
+
+/**
+ * Test predicate using a DBID set as positive elements.
+ *
+ * @apiviz.composedOf DBIDs
+ *
+ * @author Erich Schubert
+ */
+public class DBIDsTest implements Predicate<DBIDRefIter> {
+ /**
+ * DBID set.
+ */
+ private DBIDs set;
+
+ /**
+ * Constructor.
+ *
+ * @param set Set of positive objects
+ */
+ public DBIDsTest(DBIDs set) {
+ this.set = set;
+ }
+
+ @Override
+ public boolean test(DBIDRefIter o) {
+ return set.contains(o.getRef());
+ }
+
+ @Override
+ public int numPositive() {
+ return set.size();
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DecreasingVectorIter.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DecreasingVectorIter.java
new file mode 100644
index 00000000..d0a55b19
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DecreasingVectorIter.java
@@ -0,0 +1,116 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import de.lmu.ifi.dbs.elki.data.NumberVector;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.ScoreIter;
+import de.lmu.ifi.dbs.elki.utilities.datastructures.arrays.IntegerArrayQuickSort;
+import de.lmu.ifi.dbs.elki.utilities.datastructures.arrays.IntegerComparator;
+import de.lmu.ifi.dbs.elki.utilities.datastructures.iterator.ArrayIter;
+
+/**
+ * Class to iterate over a number vector in decreasing order.
+ *
+ * @author Erich Schubert
+ *
+ * @apiviz.composedOf NumberVector
+ */
+public class DecreasingVectorIter implements ScoreIter, IntegerComparator, ArrayIter {
+ /**
+ * Order of dimensions.
+ */
+ private int[] sort;
+
+ /**
+ * Data vector.
+ */
+ private NumberVector vec;
+
+ /**
+ * Current position.
+ */
+ int pos = 0;
+
+ /**
+ * Constructor.
+ *
+ * @param vec Vector to iterate over.
+ */
+ public DecreasingVectorIter(NumberVector vec) {
+ this.vec = vec;
+ final int dim = vec.getDimensionality();
+ this.sort = new int[dim];
+ for(int d = 0; d < dim; d++) {
+ sort[d] = d;
+ }
+ IntegerArrayQuickSort.sort(sort, this);
+ }
+
+ @Override
+ public int compare(int x, int y) {
+ return Double.compare(vec.doubleValue(y), vec.doubleValue(x));
+ }
+
+ public int dim() {
+ return sort[pos];
+ }
+
+ @Override
+ public boolean valid() {
+ return pos < vec.getDimensionality() && pos >= 0;
+ }
+
+ @Override
+ public DecreasingVectorIter advance() {
+ ++pos;
+ return this;
+ }
+
+ @Override
+ public boolean tiedToPrevious() {
+ return pos > 0 && Double.compare(vec.doubleValue(sort[pos]), vec.doubleValue(sort[pos - 1])) == 0;
+ }
+
+ @Override
+ public int getOffset() {
+ return pos;
+ }
+
+ @Override
+ public DecreasingVectorIter advance(int count) {
+ pos += count;
+ return this;
+ }
+
+ @Override
+ public DecreasingVectorIter retract() {
+ pos--;
+ return this;
+ }
+
+ @Override
+ public DecreasingVectorIter seek(int off) {
+ pos = off;
+ return this;
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DistanceResultAdapter.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DistanceResultAdapter.java
new file mode 100644
index 00000000..704c38bc
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/DistanceResultAdapter.java
@@ -0,0 +1,92 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import de.lmu.ifi.dbs.elki.database.ids.DBIDRef;
+import de.lmu.ifi.dbs.elki.database.ids.DoubleDBIDListIter;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.ScoreIter;
+
+/**
+ * This adapter is used to process a list of (double, DBID) objects. The list
+ * <em>must</em> be sorted appropriately, the score is only used to detect
+ * ties.
+ *
+ * @author Erich Schubert
+ *
+ * @apiviz.composedOf DoubleDBIDListIter
+ */
+public class DistanceResultAdapter implements ScoreIter, DBIDRefIter {
+ /**
+ * Original Iterator
+ */
+ protected DoubleDBIDListIter iter;
+
+ /**
+ * Distance of previous.
+ */
+ protected double prevDist = Double.NaN;
+
+ /**
+ * Constructor
+ *
+ * @param iter Iterator for distance results
+ */
+ public DistanceResultAdapter(DoubleDBIDListIter iter) {
+ super();
+ this.iter = iter;
+ }
+
+ @Override
+ public boolean valid() {
+ return iter.valid();
+ }
+
+ @Override
+ public DistanceResultAdapter advance() {
+ prevDist = iter.doubleValue();
+ iter.advance();
+ return this;
+ }
+
+ @Override
+ public DBIDRef getRef() {
+ return iter;
+ }
+
+ @Override
+ public boolean tiedToPrevious() {
+ return iter.doubleValue() == prevDist;
+ }
+
+ @Deprecated
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Deprecated
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/FilteredDistanceResultAdapter.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/FilteredDistanceResultAdapter.java
new file mode 100644
index 00000000..9a8a2ddc
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/FilteredDistanceResultAdapter.java
@@ -0,0 +1,76 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import de.lmu.ifi.dbs.elki.database.ids.DBIDRef;
+import de.lmu.ifi.dbs.elki.database.ids.DBIDUtil;
+import de.lmu.ifi.dbs.elki.database.ids.DoubleDBIDListIter;
+
+/**
+ * This adapter is used to process a list of (double, DBID) objects, but allows
+ * skipping one object in the ranking. The list <em>must</em> be sorted
+ * appropriately, the score is only used to detect ties.
+ *
+ * @author Erich Schubert
+ */
+public class FilteredDistanceResultAdapter extends DistanceResultAdapter {
+ /**
+ * DBID to skip (usually: query object).
+ */
+ DBIDRef skip;
+
+ /**
+ * Constructor
+ *
+ * @param iter Iterator for distance results
+ * @param skip DBID to skip (reference must remain stable!)
+ */
+ public FilteredDistanceResultAdapter(DoubleDBIDListIter iter, DBIDRef skip) {
+ super(iter);
+ this.skip = skip;
+ if(iter.valid() && DBIDUtil.equal(iter, skip)) {
+ iter.advance();
+ }
+ }
+
+ @Override
+ public DistanceResultAdapter advance() {
+ super.advance();
+ if(iter.valid() && DBIDUtil.equal(iter, skip)) {
+ iter.advance();
+ }
+ return this;
+ }
+
+ @Deprecated
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Deprecated
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/IncreasingVectorIter.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/IncreasingVectorIter.java
new file mode 100644
index 00000000..979dc166
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/IncreasingVectorIter.java
@@ -0,0 +1,116 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import de.lmu.ifi.dbs.elki.data.NumberVector;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.ScoreIter;
+import de.lmu.ifi.dbs.elki.utilities.datastructures.arrays.IntegerArrayQuickSort;
+import de.lmu.ifi.dbs.elki.utilities.datastructures.arrays.IntegerComparator;
+import de.lmu.ifi.dbs.elki.utilities.datastructures.iterator.ArrayIter;
+
+/**
+ * Class to iterate over a number vector in decreasing order.
+ *
+ * @author Erich Schubert
+ *
+ * @apiviz.composedOf NumberVector
+ */
+public class IncreasingVectorIter implements ScoreIter, IntegerComparator, ArrayIter {
+ /**
+ * Order of dimensions.
+ */
+ private int[] sort;
+
+ /**
+ * Data vector.
+ */
+ private NumberVector vec;
+
+ /**
+ * Current position.
+ */
+ int pos = 0;
+
+ /**
+ * Constructor.
+ *
+ * @param vec Vector to iterate over.
+ */
+ public IncreasingVectorIter(NumberVector vec) {
+ this.vec = vec;
+ final int dim = vec.getDimensionality();
+ this.sort = new int[dim];
+ for(int d = 0; d < dim; d++) {
+ sort[d] = d;
+ }
+ IntegerArrayQuickSort.sort(sort, this);
+ }
+
+ @Override
+ public int compare(int x, int y) {
+ return Double.compare(vec.doubleValue(x), vec.doubleValue(y));
+ }
+
+ public int dim() {
+ return sort[pos];
+ }
+
+ @Override
+ public boolean valid() {
+ return pos < vec.getDimensionality();
+ }
+
+ @Override
+ public IncreasingVectorIter advance() {
+ ++pos;
+ return this;
+ }
+
+ @Override
+ public boolean tiedToPrevious() {
+ return pos > 0 && Double.compare(vec.doubleValue(sort[pos]), vec.doubleValue(sort[pos - 1])) == 0;
+ }
+
+ @Override
+ public int getOffset() {
+ return pos;
+ }
+
+ @Override
+ public IncreasingVectorIter advance(int count) {
+ pos += count;
+ return this;
+ }
+
+ @Override
+ public IncreasingVectorIter retract() {
+ pos--;
+ return this;
+ }
+
+ @Override
+ public IncreasingVectorIter seek(int off) {
+ pos = off;
+ return this;
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/OutlierScoreAdapter.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/OutlierScoreAdapter.java
new file mode 100644
index 00000000..a36a57d6
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/OutlierScoreAdapter.java
@@ -0,0 +1,103 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import de.lmu.ifi.dbs.elki.database.ids.DBIDIter;
+import de.lmu.ifi.dbs.elki.database.ids.DBIDRef;
+import de.lmu.ifi.dbs.elki.database.relation.DoubleRelation;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.ScoreIter;
+import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult;
+
+/**
+ * This adapter can be used for an arbitrary collection of Integers, and uses
+ * that id1.compareTo(id2) != 0 for id1 != id2 to satisfy the comparability.
+ *
+ * Note that of course, no id should occur more than once.
+ *
+ * The ROC values would be incorrect then anyway!
+ *
+ * @author Erich Schubert
+ *
+ * @apiviz.composedOf OutlierResult
+ */
+public class OutlierScoreAdapter implements ScoreIter, DBIDRefIter {
+ /**
+ * Original iterator.
+ */
+ private DBIDIter iter;
+
+ /**
+ * Outlier score.
+ */
+ private DoubleRelation scores;
+
+ /**
+ * Previous value.
+ */
+ double prev = Double.NaN;
+
+ /**
+ * Constructor.
+ *
+ * @param o Result
+ */
+ public OutlierScoreAdapter(OutlierResult o) {
+ super();
+ this.iter = o.getOrdering().iter(o.getScores().getDBIDs()).iter();
+ this.scores = o.getScores();
+ }
+
+ @Override
+ public boolean valid() {
+ return iter.valid();
+ }
+
+ @Override
+ public OutlierScoreAdapter advance() {
+ prev = scores.doubleValue(iter);
+ iter.advance();
+ return this;
+ }
+
+ @Override
+ public boolean tiedToPrevious() {
+ return scores.doubleValue(iter) == prev;
+ }
+
+ @Override
+ public DBIDRef getRef() {
+ return iter;
+ }
+
+ @Deprecated
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Deprecated
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/SimpleAdapter.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/SimpleAdapter.java
new file mode 100644
index 00000000..beb301a8
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/SimpleAdapter.java
@@ -0,0 +1,89 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import de.lmu.ifi.dbs.elki.database.ids.DBIDIter;
+import de.lmu.ifi.dbs.elki.database.ids.DBIDRef;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.ScoreIter;
+
+/**
+ * This adapter can be used for an arbitrary collection of Integers, and uses
+ * that id1.compareTo(id2) != 0 for id1 != id2 to satisfy the comparability.
+ *
+ * Note that of course, no id should occur more than once.
+ *
+ * The ROC values would be incorrect then anyway!
+ *
+ * @author Erich Schubert
+ *
+ * @apiviz.composedOf DBIDIter
+ */
+public class SimpleAdapter implements ScoreIter, DBIDRefIter {
+ /**
+ * Original Iterator
+ */
+ private DBIDIter iter;
+
+ /**
+ * Constructor
+ *
+ * @param iter Iterator for object IDs
+ */
+ public SimpleAdapter(DBIDIter iter) {
+ super();
+ this.iter = iter;
+ }
+
+ @Override
+ public boolean valid() {
+ return iter.valid();
+ }
+
+ @Override
+ public SimpleAdapter advance() {
+ iter.advance();
+ return this;
+ }
+
+ @Override
+ public boolean tiedToPrevious() {
+ return false; // No information.
+ }
+
+ @Deprecated
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Deprecated
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+
+ @Override
+ public DBIDRef getRef() {
+ return iter;
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorNonZero.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorNonZero.java
new file mode 100644
index 00000000..cc97006f
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorNonZero.java
@@ -0,0 +1,44 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import de.lmu.ifi.dbs.elki.data.NumberVector;
+
+/**
+ * Class that uses a NumberVector as reference, and considers all non-zero
+ * values as positive entries.
+ *
+ * @apiviz.composedOf NumberVector
+ *
+ * @author Erich Schubert
+ */
+public class VectorNonZero extends VectorOverThreshold {
+ /**
+ * Constructor.
+ *
+ * @param vec Reference vector.
+ */
+ public VectorNonZero(NumberVector vec) {
+ super(vec, 0.);
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorOverThreshold.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorOverThreshold.java
new file mode 100644
index 00000000..99c24332
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorOverThreshold.java
@@ -0,0 +1,79 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import de.lmu.ifi.dbs.elki.data.NumberVector;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.Predicate;
+
+/**
+ * Class that uses a NumberVector as reference, and considers all non-zero
+ * values as positive entries.
+ *
+ * @apiviz.composedOf NumberVector
+ *
+ * @author Erich Schubert
+ */
+public class VectorOverThreshold implements Predicate<DecreasingVectorIter> {
+ /**
+ * Vector to use as reference
+ */
+ NumberVector vec;
+
+ /**
+ * Threshold
+ */
+ double threshold;
+
+ /**
+ * Number of positive values.
+ */
+ int numpos;
+
+ /**
+ * Constructor.
+ *
+ * @param vec Reference vector.
+ * @param threshold Threshold value.
+ */
+ public VectorOverThreshold(NumberVector vec, double threshold) {
+ super();
+ this.vec = vec;
+ this.threshold = threshold;
+ this.numpos = 0;
+ for(int i = 0, l = vec.getDimensionality(); i < l; i++) {
+ if(vec.doubleValue(i) > threshold) {
+ ++numpos;
+ }
+ }
+ }
+
+ @Override
+ public boolean test(DecreasingVectorIter o) {
+ return Math.abs(vec.doubleValue(o.dim())) > threshold;
+ }
+
+ @Override
+ public int numPositive() {
+ return numpos;
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorZero.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorZero.java
new file mode 100644
index 00000000..e7b728fc
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/VectorZero.java
@@ -0,0 +1,71 @@
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter;
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import de.lmu.ifi.dbs.elki.data.NumberVector;
+import de.lmu.ifi.dbs.elki.evaluation.scores.ScoreEvaluation.Predicate;
+
+/**
+ * Class that uses a NumberVector as reference, and considers all zero values as
+ * positive entries.
+ *
+ * @apiviz.composedOf NumberVector
+ *
+ * @author Erich Schubert
+ */
+public class VectorZero implements Predicate<IncreasingVectorIter> {
+ /**
+ * Vector to use as reference
+ */
+ NumberVector vec;
+
+ /**
+ * Number of positive values.
+ */
+ int numpos;
+
+ /**
+ * Constructor.
+ *
+ * @param vec Reference vector.
+ */
+ public VectorZero(NumberVector vec) {
+ this.vec = vec;
+ this.numpos = 0;
+ for(int i = 0, l = vec.getDimensionality(); i < l; i++) {
+ if(Math.abs(vec.doubleValue(i)) < Double.MIN_NORMAL) {
+ ++numpos;
+ }
+ }
+ }
+
+ @Override
+ public boolean test(IncreasingVectorIter o) {
+ return Math.abs(vec.doubleValue(o.dim())) < Double.MIN_NORMAL;
+ }
+
+ @Override
+ public int numPositive() {
+ return numpos;
+ }
+} \ No newline at end of file
diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/package-info.java b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/package-info.java
new file mode 100644
index 00000000..746d9a1c
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/evaluation/scores/adapter/package-info.java
@@ -0,0 +1,26 @@
+/**
+ * Adapter classes for ranking and scoring measures.
+ */
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2014
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package de.lmu.ifi.dbs.elki.evaluation.scores.adapter; \ No newline at end of file