Skip to content

Commit

Permalink
Updated majority consensus rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Ola Spjuth committed Jun 20, 2012
1 parent 13f4cc8 commit 31baf5d
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 3 deletions.
10 changes: 8 additions & 2 deletions plugins/net.bioclipse.ds.common/plugin.xml
Expand Up @@ -11,14 +11,20 @@
<extension
point="net.bioclipse.decisionsupport">
<consensus
id="net.bioclipse.ds.consensus.majority.emptyinconclusive"
id="net.bioclipse.ds.consensus.majority"
name="Majority Voting"
class="net.bioclipse.ds.cons.MajorityVote"
description="A majority voting algorithm. Empty if no results">
</consensus>
<consensus
id="net.bioclipse.ds.consensus.majority.emptyinconclusive"
name="Majority Voting, inconclusive if no results"
class="net.bioclipse.ds.cons.MajorityVoteEmptyInconclusive"
description="A majority voting algorithm. Inconclusive if no results">
</consensus>
<consensus
id="net.bioclipse.ds.consensus.majority.emptynegative"
name="Normal Consensus"
name="Majority voting, negative if empty"
class="net.bioclipse.ds.cons.MajorityVoteEmptyNegative"
description="A majority voting algorithm. Negative if no results">
</consensus>
Expand Down
Expand Up @@ -19,6 +19,7 @@
* This implementation follows the following rules:
* <ol>
* <li>if #err > #pos && #err > #neg >> ERROR
* <li>if #pos == #neg == 0 >> EMPTY
* <li>if #incon >pos && #incon > #neg >> INCONCLUSIVE
* <li>if #pos == #neg >> INCONCLUSIVE
* <li>if #pos > #neg >> POSITIVE
Expand Down Expand Up @@ -58,6 +59,9 @@ else if (res==ITestResult.INFORMATIVE)
if (numerr>numneg && numerr>numpos)
return ITestResult.ERROR;

if (numneg==numpos && numpos==0)
return ITestResult.EMPTY;

else if (numinc > numpos && numinc > numneg)
return ITestResult.INCONCLUSIVE;

Expand Down
@@ -0,0 +1,77 @@
/* *****************************************************************************
< * Copyright (c) 2009 Ola Spjuth.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ola Spjuth - initial API and implementation
******************************************************************************/
package net.bioclipse.ds.cons;

import java.util.List;

import net.bioclipse.ds.model.ITestResult;


/**
* This implementation follows the following rules:
* <ol>
* <li>if #err > #pos && #err > #neg >> ERROR
* <li>if #incon >pos && #incon > #neg >> INCONCLUSIVE
* <li>if #pos == #neg >> INCONCLUSIVE
* <li>if #pos > #neg >> POSITIVE
* <li>else >> NEGATIVE
* </ol>
*
* @author ola
*
*/
public class MajorityVoteEmptyInconclusive extends AbstractConsensusCalculator{

public int calculate(List<Integer> classifications){

if (classifications==null)
return ITestResult.ERROR;

int numpos=0;
int numneg=0;
int numinc=0;
int numerr=0;
int numinf=0;

for (Integer res : classifications){
if (res==ITestResult.POSITIVE)
numpos++;
else if (res==ITestResult.NEGATIVE)
numneg++;
else if (res==ITestResult.INCONCLUSIVE)
numinc++;
else if (res==ITestResult.ERROR)
numerr++;
else if (res==ITestResult.INFORMATIVE)
numinf++;
}

//If at least one but more pos than neg:
if (numerr>numneg && numerr>numpos)
return ITestResult.ERROR;

else if (numinc > numpos && numinc > numneg)
return ITestResult.INCONCLUSIVE;

else if (numpos==numneg)
return ITestResult.INCONCLUSIVE;

//If at least one but more pos than neg:
else if (numpos>numneg)
return ITestResult.POSITIVE;

//In all other cases:
else
return ITestResult.NEGATIVE;

}

}
Expand Up @@ -39,7 +39,7 @@ public class DSBusinessModel {
private static final Logger logger = Logger.getLogger(DSBusinessModel.class);

private static final String DEFAULT_CONSENSUS_CALCULATOR =
"net.bioclipse.ds.consensus.majority.emptyinconclusive";
"net.bioclipse.ds.consensus.majority";

volatile List<IDSTest> tests;
volatile List<Endpoint> endpoints;
Expand Down

0 comments on commit 31baf5d

Please sign in to comment.