You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "Robin Anil (JIRA)" <ji...@apache.org> on 2009/10/07 14:33:31 UTC
[jira] Created: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Classifier PriorityQueue returns erroneous results
--------------------------------------------------
Key: MAHOUT-186
URL: https://issues.apache.org/jira/browse/MAHOUT-186
Project: Mahout
Issue Type: Bug
Affects Versions: 0.1, 0.2
Reporter: Robin Anil
Assignee: Robin Anil
Fix For: 0.2
A simple test fails
import org.apache.hadoop.util.PriorityQueue;
PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
queue.insert(new ClassifierResult("label1", 5));
queue.insert(new ClassifierResult("label2", 4));
queue.insert(new ClassifierResult("label3", 3));
queue.insert(new ClassifierResult("label4", 2));
queue.insert(new ClassifierResult("label5", 1));
assertEquals("Incorrect Size", 3, queue.size());
log.info(queue.pop().toString());
log.info(queue.pop().toString());
log.info(queue.pop().toString());
09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robin Anil updated MAHOUT-186:
------------------------------
Status: Patch Available (was: In Progress)
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Sean Owen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763035#action_12763035 ]
Sean Owen commented on MAHOUT-186:
----------------------------------
Not sure what's up with the hadoop class, but sure makes sense to use the standard PriorityQueue class. why do we need a custom subclass at all? seems like this can be done with a regular PriorityQueue, a Comparator, and use of the standard PriorityQueue methods. That is, do we need getTopResults(), for example.
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Ted Dunning (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763172#action_12763172 ]
Ted Dunning commented on MAHOUT-186:
------------------------------------
You are right that I should code up an example before speaking. But it does seem that, against all odds, that what I was suggesting works.
Here is a test case that illustrates what I meant. I am still not sure what everybody is saying:
{noformat}
package com.infovell.logging.test;
import junit.framework.TestCase;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class FooTest extends TestCase {
public void testQueue() {
PriorityQueue<Double> pq = new PriorityQueue<Double>(10);
Random gen = new Random(123L);
for (int i = 0; i < 1000; i++) {
double x = gen.nextDouble();
if (pq.size() < 10 || x > pq.peek()) {
pq.add(x);
while (pq.size() > 10) {
pq.remove();
}
}
}
List<Double> r = new ArrayList<Double>(pq);
Collections.reverse(r);
System.out.printf("%s\n", r);
assertEquals(0.994991252160446, r.get(0), 1e-7);
assertEquals(0.9881699208527764, r.get(9), 1e-7);
}
}
{noformat}
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Sean Owen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763387#action_12763387 ]
Sean Owen commented on MAHOUT-186:
----------------------------------
I think I agree, if you're suggesting this is probably simplifiable. Attached is an alternate patch which I believe does the same thing (tests pass at least). I think it's not necessary to use intermediate collections in several places here.
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch, MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Sean Owen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763162#action_12763162 ]
Sean Owen commented on MAHOUT-186:
----------------------------------
I will make up an alternate patch that either shows what I mean or shows me I'm wrong. My central question is, what requires a custom subclass of PriorityQueue? I understand that the "new List()" thing doesn't give the items in order but that doesn't imply a subclass is needed.
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robin Anil updated MAHOUT-186:
------------------------------
Resolution: Fixed
Status: Resolved (was: Patch Available)
Committed sean's patch.
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch, MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Ted Dunning (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763124#action_12763124 ]
Ted Dunning commented on MAHOUT-186:
------------------------------------
I don't quite understand the last comment, but generally if you want the top n items in descending order, you keep a descending queue as you say in order to make insertion efficient. It is generally good to cache the score of the least element to speed comparisons even a little bit more.
Then when you want the results, you can just fill a list in reverse order
or just do this:
List r = new ArrayList(priorityQueue);
Collections.reverse(r);
Since this is pretty simple, I think I misunderstood the question.
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robin Anil updated MAHOUT-186:
------------------------------
Attachment: MAHOUT-186.patch
Fix:
Added PriorityQueue Test.
Used java.util.PriorityQueue instead of the org.apache.hadoop.util.PriorityQueue
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763491#action_12763491 ]
Robin Anil commented on MAHOUT-186:
-----------------------------------
Reply to Ted
I ran the code, and this is the result
[0.994991252160446, 0.9945536151314497, 0.999376415169616, 0.9968475047260047, 0.9984130174646184, 0.9912339517865715, 0.9941739318651063, 0.9916439528089621, 0.9908988967772393, 0.9881699208527764]
The data shows this, which is clearly not sorted
dec, inc, dec, inc, dec, inc, dec, dec, dec.
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch, MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763145#action_12763145 ]
Robin Anil commented on MAHOUT-186:
-----------------------------------
new List(priorityQueue) i believe doesnt keep the order of the priorityQueue as the toArray and Iterator both returns data in random order. So you need to keep polling the top of the heap isn't it?
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Sean Owen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Owen updated MAHOUT-186:
-----------------------------
Attachment: MAHOUT-186.patch
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch, MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robin Anil closed MAHOUT-186.
-----------------------------
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch, MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763036#action_12763036 ]
Robin Anil commented on MAHOUT-186:
-----------------------------------
well i want to get the data in the descending order.
if i keep a descending priorityQueue i cant get the least element without polling the entire queue
if i keep an ascending priorityqueue, I wont be able to get the reverse iterator without doing the getTopResults()
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
> Attachments: MAHOUT-186.patch
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Work started: (MAHOUT-186) Classifier PriorityQueue returns
erroneous results
Posted by "Robin Anil (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MAHOUT-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Work on MAHOUT-186 started by Robin Anil.
> Classifier PriorityQueue returns erroneous results
> --------------------------------------------------
>
> Key: MAHOUT-186
> URL: https://issues.apache.org/jira/browse/MAHOUT-186
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.1, 0.2
> Reporter: Robin Anil
> Assignee: Robin Anil
> Fix For: 0.2
>
>
> A simple test fails
> import org.apache.hadoop.util.PriorityQueue;
> PriorityQueue<ClassifierResult> queue = new ClassifierResultPriorityQueue(3);
> queue.insert(new ClassifierResult("label1", 5));
> queue.insert(new ClassifierResult("label2", 4));
> queue.insert(new ClassifierResult("label3", 3));
> queue.insert(new ClassifierResult("label4", 2));
> queue.insert(new ClassifierResult("label5", 1));
>
> assertEquals("Incorrect Size", 3, queue.size());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> log.info(queue.pop().toString());
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label3', score=3.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label4', score=2.0}
> 09/10/07 16:58:39 INFO common.ClassifierResultPriorityQueueTest: ClassifierResult{category='label5', score=1.0}
> Expected label1 and label2 at the top
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.