Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5198

Show
Ignore:
Timestamp:
08/08/08 09:27:27 (5 months ago)
Author:
jegg
Message:

in patientmatching module, updated EM analysis to set the score threshold of a match along with m and u values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/patientmatching/src/org/regenstrief/linkage/analysis/EMAnalyzer.java

    r4152 r5198  
    44import java.util.Hashtable; 
    55import java.util.Iterator; 
     6import java.util.List; 
    67 
    78import org.apache.log4j.Logger; 
     
    268269                //*************************************** 
    269270                 
     271                log.info("previous score threshold:\t" + mc.getScoreThreshold()); 
     272                // change the score threshold to one calculated from estimated true matches 
     273                VectorTable vt = new VectorTable(mc); 
     274                 
     275                // get sorted list of results 
     276                List<MatchResult> results = vt.getPossibleMatchResults(); 
     277                Iterator<MatchResult> it = results.iterator(); 
     278                double total = 0; 
     279                MatchResult total_mr = null; 
     280                double prev_total = 0; 
     281                MatchResult prev_mr = null; 
     282                while(it.hasNext() && total < true_matches){ 
     283                        MatchResult mr = it.next(); 
     284                        double d = mr.getTrueProbability() * total_pairs; 
     285                        prev_total = total; 
     286                        prev_mr = total_mr; 
     287                        total += d; 
     288                        total_mr = mr; 
     289                } 
     290                // choose total or prev_total, depending on which one is closer to estimated matches 
     291                if(Math.abs(total - true_matches) > Math.abs(prev_total - true_matches)){ 
     292                        // use previous score as threshold 
     293                        mc.setScoreThreshold(prev_mr.getScore()); 
     294                } else { 
     295                        mc.setScoreThreshold(total_mr.getScore()); 
     296                } 
     297                log.info("new score threshold:\t" + mc.getScoreThreshold()); 
     298                 
    270299                for(int i = 0; i < demographics.length; i++){ 
    271300                        String demographic = demographics[i];