[
https://issues.apache.org/jira/browse/MAHOUT-900?focusedWorklogId=1002864&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1002864
]
ASF GitHub Bot logged work on MAHOUT-900:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 01/Feb/26 06:22
Start Date: 01/Feb/26 06:22
Worklog Time Spent: 10m
Work Description: guan404ming commented on PR #938:
URL: https://github.com/apache/mahout/pull/938#issuecomment-3830460648
Hahaha, take your time. I'm chilling at Cafe shop.
Issue Time Tracking
-------------------
Worklog Id: (was: 1002864)
Time Spent: 1.5h (was: 1h 20m)
> RandomSeedGenerator samples / output k texts incorrectly
> --------------------------------------------------------
>
> Key: MAHOUT-900
> URL: https://issues.apache.org/jira/browse/MAHOUT-900
> Project: Mahout
> Issue Type: Bug
> Components: classic
> Affects Versions: 0.5
> Reporter: Sean R. Owen
> Assignee: Sean R. Owen
> Priority: Minor
> Fix For: 0.6
>
> Attachments: MAHOUT-900.patch
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> {code}
> int currentSize = chosenTexts.size();
> if (currentSize < k) {
> chosenTexts.add(newText);
> chosenClusters.add(newCluster);
> } else if (random.nextInt(currentSize + 1) == 0) { // with chance
> 1/(currentSize+1) pick new element
> int indexToRemove = random.nextInt(currentSize); // evict one
> chosen randomly
> chosenTexts.remove(indexToRemove);
> chosenClusters.remove(indexToRemove);
> chosenTexts.add(newText);
> chosenClusters.add(newCluster);
> }
> {code}
> The second "if" condition ought to be "!= 0", right? Only if it is 0 do we
> skip the body, which removes an existing element, since the new element
> itself is evicted.
> Second, this code:
> {code}
> for (int i = 0; i < k; i++) {
> writer.append(chosenTexts.get(i), chosenClusters.get(i));
> }
> {code}
> ... assumes that at least k elements existed in the input, and fails
> otherwise. Probably need to cap this.
> Patch attached.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)