Skip to content

Commit

Permalink
0.0.12; algofix
Browse files Browse the repository at this point in the history
  • Loading branch information
reality committed Oct 5, 2021
1 parent 8cd1164 commit c7bbd4d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion klarigi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ jacocoTestReport {
}
}

version = '0.0.12-SNAPSHOT'
version = '0.0.12'
7 changes: 4 additions & 3 deletions klarigi/src/main/groovy/klarigi/App.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class App {
_ longOpt: 'min-exclusion', 'Min exclusion to use in stepdown algorithm. Default: 0.3', args: 1
_ longOpt: 'max-total-inclusion', 'Max total inclusion to use in stepdown algorithm. Default: 0.95 (probably don\'t want to edit this one)', args: 1
_ longOpt: 'step', 'Step by which to reduce coefficients in stepdown algorithm. Default: 0.05', args: 1
_ longOpt: 'debug', 'Print some debug output', type: Boolean

_ longOpt: 'power', 'Use modification of algorithm which uses normalised power instead of inc/exc', type: Boolean

Expand Down Expand Up @@ -91,11 +92,11 @@ class App {
System.exit(1)
}

allExplanations = k.explainClusters(groups, o['output-scores'], o['power'], threads)
allExplanations = k.explainClusters(groups, o['output-scores'], o['power'], threads, o['debug'])
} else if(o['group'] && o['group'] != '*') {
allExplanations = k.explainClusters([o['group']], o['output-scores'], o['power'], threads)
allExplanations = k.explainClusters([o['group']], o['output-scores'], o['power'], threads, o['debug'])
} else {
allExplanations = k.explainAllClusters(o['output-scores'], o['power'], threads)
allExplanations = k.explainAllClusters(o['output-scores'], o['power'], threads, o['debug'])
}

allExplanations.each {
Expand Down
14 changes: 7 additions & 7 deletions klarigi/src/main/groovy/klarigi/Klarigi.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public class Klarigi {
}
}

def explainCluster(cid, powerMode, outputScores, threads) {
def explainCluster(cid, powerMode, outputScores, threads, debug) {
def scorer = new Scorer(ontoHelper, data)
def candidates = scorer.scoreClasses(cid, threads)

Expand All @@ -173,21 +173,21 @@ public class Klarigi {

// TODO: now we have to, ah, add the multiprocessing
if(powerMode) {
StepDown.RunNewAlgorithm(coefficients, cid, candidates, data)
StepDown.RunNewAlgorithm(coefficients, cid, candidates, data, debug)
} else {
StepDown.Run(coefficients, cid, candidates, data)
StepDown.Run(coefficients, cid, candidates, data, debug)
}
}

def explainClusters(groups, outputScores, powerMode, threads) {
def explainClusters(groups, outputScores, powerMode, threads, debug) {
data.groupings.findAll { g, v -> groups.contains(g) }.collect { g, v ->
[ cluster: g, results: explainCluster(g, powerMode, outputScores, threads) ]
[ cluster: g, results: explainCluster(g, powerMode, outputScores, threads, debug) ]
}
}

def explainAllClusters(outputScores, powerMode, threads) {
def explainAllClusters(outputScores, powerMode, threads, debug) {
data.groupings.collect { g, v ->
[ cluster: g, results: explainCluster(g, powerMode, outputScores, threads) ]
[ cluster: g, results: explainCluster(g, powerMode, outputScores, threads, debug) ]
}
}

Expand Down
22 changes: 14 additions & 8 deletions klarigi/src/main/groovy/klarigi/StepDown.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package klarigi

public class StepDown {
static def Run(c, cid, candidates, data) {
static def Run(c, cid, candidates, data, debug) {
def totalCoverage = 0
def stepDown = { e, icCutoff, exclusionCutoff, inclusionCutoff, totalInclusionCutoff ->
while(totalCoverage <= (totalInclusionCutoff*100)) {
Expand All @@ -15,10 +15,13 @@ public class StepDown {
if(data.groupings.size() > 1) {
totalExclusion = (1-(((ef.collect { it.internalExcluded }.flatten().unique(false).size()) / (data.groupings.collect {k,v->v.size()}.sum() - data.groupings[cid].size()))))*100
}
//println "DEBUG: running with ic cutoff: $icCutoff exclusion cutoff: $exclusionCutoff inclusion cutoff: $inclusionCutoff total: coverage: $totalCoverage/$totalInclusionCutoff"
if(totalCoverage <= (totalInclusionCutoff*100)) {
if(debug) {
println "DEBUG: running with ic cutoff: $icCutoff exclusion cutoff: $exclusionCutoff inclusion cutoff: $inclusionCutoff total: coverage: $totalCoverage/$totalInclusionCutoff"
}
if(totalCoverage < (totalInclusionCutoff*100)) {
totalCoverage = 0 // OMG
if(inclusionCutoff <= c.MIN_INCLUSION) {
if(icCutoff >= c.MIN_IC) {
if(icCutoff > c.MIN_IC) {
icCutoff -= c.STEP
exclusionCutoff = c.MAX_EXCLUSION
inclusionCutoff = c.MAX_INCLUSION
Expand Down Expand Up @@ -46,7 +49,7 @@ public class StepDown {
return stepDown(candidates, c.MAX_IC, c.MAX_EXCLUSION, c.MAX_INCLUSION, c.MAX_TOTAL_INCLUSION)
}

static def RunNewAlgorithm(c, cid, candidates, data) {
static def RunNewAlgorithm(c, cid, candidates, data, debug) {
def totalCoverage = 0
def stepDown = { e, icCutoff, powerCutoff, totalInclusionCutoff ->
while(totalCoverage <= (totalInclusionCutoff*100)) {
Expand All @@ -60,10 +63,13 @@ public class StepDown {
if(data.groupings.size() > 1) {
totalExclusion = (1-(((ef.collect { it.internalExcluded }.flatten().unique(false).size()) / (data.groupings.collect {k,v->v.size()}.sum() - data.groupings[cid].size()))))*100
}
//println "DEBUG: running with ic cutoff: $icCutoff exclusion cutoff: $exclusionCutoff inclusion cutoff: $inclusionCutoff total: coverage: $totalCoverage/$totalInclusionCutoff"
if(totalCoverage <= (totalInclusionCutoff*100)) {
if(debug) {
println "DEBUG: running with ic cutoff: $icCutoff exclusion cutoff: $exclusionCutoff inclusion cutoff: $inclusionCutoff total: coverage: $totalCoverage/$totalInclusionCutoff"
}
if(totalCoverage < (totalInclusionCutoff*100)) {
totalCoverage = 0
if(powerCutoff <= c.MIN_POWER) {
if(icCutoff >= c.MIN_IC) {
if(icCutoff > c.MIN_IC) {
icCutoff -= c.STEP
powerCutoff = c.MAX_POWER
continue;
Expand Down

0 comments on commit c7bbd4d

Please sign in to comment.