Skip to content

Commit

Permalink
Merge pull request #6 from bioclipse/FixedRegressionCOloring
Browse files Browse the repository at this point in the history
Fixed regression coloring
  • Loading branch information
olas committed Apr 2, 2013
2 parents 0d317ec + 9091663 commit 822bc10
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 deletions.
Expand Up @@ -256,6 +256,9 @@ public void completeReturn( SDFIndexEditorModel object ) {
throw new DSException("Initialization of DB exact match FP cancelled");
}

if (SDFmodel==null){
throw new DSException("Could not read SDFModel");
}
if (SDFmodel.getNumberOfMolecules()<=0){
throw new DSException("No molecules could be read in database");
}
Expand Down
Expand Up @@ -124,6 +124,10 @@ public void initialize(IProgressMonitor monitor) throws DSException {
String signaturesPath = getFileFromParameter(SIGNATURES_FILE_PARAMETER );
startHeight=Integer.parseInt(getParameters().get( SIGNATURES_MIN_HEIGHT ));
endHeight=Integer.parseInt(getParameters().get( SIGNATURES_MAX_HEIGHT ));
String infoma = getParameters().get( "isInformative" );
if (infoma!=null)
setInformative(Boolean.parseBoolean(getParameters().get( "isInformative" )));


//These are for regression
if ("false".equalsIgnoreCase(getParameters().get( "isClassification" ))){
Expand Down Expand Up @@ -288,30 +292,52 @@ public List<? extends ITestResult> predictLibSVM(ICDKMolecule cdkmol,
results.add(match);

//Logic for multi-class results here
int intPrediction=(int)prediction;
if (classLabels==null){
return returnError("No classlabels found in model", "Classlabels are null for model");
}
String predictedClassLabel = classLabels.get(intPrediction);
if (getParameters().get("isClassification").equalsIgnoreCase("true")){

logger.debug("Prediction result: " + prediction + ", predictedClassLabel=" + predictedClassLabel);
int intPrediction=(int)prediction;
if (classLabels==null){
return returnError("No classlabels found in model", "Classlabels are null for model");
}
String predictedClassLabel = classLabels.get(intPrediction);

//If this is higher than posVal in list, set POSITIVE color
int posIX = classLabels.indexOf(positiveValue);
int negIX = classLabels.indexOf(negativeValue);
int predIX = classLabels.indexOf(predictedClassLabel);
logger.debug("Prediction result: " + prediction + ", predictedClassLabel=" + predictedClassLabel);

if (predIX==posIX){
match.setClassification( ITestResult.POSITIVE );
match.setName("Result: Positive");
}
else if (predIX==negIX){
match.setClassification( ITestResult.NEGATIVE );
match.setName("Result: Negative");
}
else{
match.setClassification( ITestResult.INCONCLUSIVE );
match.setName("Result: Inconclusive");
//If this is higher than posVal in list, set POSITIVE color
int posIX = classLabels.indexOf(positiveValue);
int negIX = classLabels.indexOf(negativeValue);
int predIX = classLabels.indexOf(predictedClassLabel);

if (predIX==posIX){
match.setClassification( ITestResult.POSITIVE );
match.setName("Result: Positive");
}
else if (predIX==negIX){
match.setClassification( ITestResult.NEGATIVE );
match.setName("Result: Negative");
}
else{
match.setClassification( ITestResult.INCONCLUSIVE );
match.setName("Result: Inconclusive");
}

}else{
//Regression
if (isInformative())
match.setClassification( ITestResult.INFORMATIVE );
else{
if (prediction>regrUpperThreshold && lowIsNegative)
match.setClassification( ITestResult.POSITIVE );
else if (prediction>regrUpperThreshold && !lowIsNegative)
match.setClassification( ITestResult.NEGATIVE );
else if (prediction<regrLowerThreshold && lowIsNegative)
match.setClassification( ITestResult.NEGATIVE );
else if (prediction<regrLowerThreshold && !lowIsNegative)
match.setClassification( ITestResult.POSITIVE);
}

//Else, between the two, keep inconclusive
match.setName("Result: " + formatter.format(prediction));
// return results;
}


Expand Down Expand Up @@ -511,6 +537,8 @@ else if (predIX==negIX){
match = new ScaledResultMatch("Result: "
+ formatter.format( prediction ),
ITestResult.INFORMATIVE);
results.clear();
results.add(match);

int result=ITestResult.INCONCLUSIVE;
if (regrLowerThreshold!=null && regrUpperThreshold!=null){
Expand Down
Expand Up @@ -1205,6 +1205,7 @@ public void setFocus() {

private void updateView() {

if (viewer.getControl().isDisposed()) return;
viewer.refresh();
// viewer.expandToLevel( 1 );
viewer.expandAll();
Expand Down

0 comments on commit 822bc10

Please sign in to comment.