Changeset 3680:fa965bf5caa8 in orange


Ignore:
Timestamp:
05/21/07 19:01:11 (7 years ago)
Author:
martinm <martinm@…>
Branch:
default
Convert:
f4d846772cd303e87bcb0899239e38ca1ad8207f
Message:

Removed bug with brent optimization (wrong interval)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/rulelearner.cpp

    r3678 r3680  
    735735    return (rule->classDistribution->atint(targetClass)+m*aprioriProb)/(rule->classDistribution->abs+m); 
    736736 
     737 
    737738  float median = evc->median(); 
    738739  float chiCorrected = nonOptimistic_Chi; 
     
    754755  { 
    755756    LRInv *diffFunc = new LRInv(rule->classDistribution->abs,apriori->atint(targetClass),apriori->abs,chiCorrected); 
    756     ePositives = brent(0.0, rule->classDistribution->atint(targetClass), 100, diffFunc); 
     757    ePositives = brent(rule->classDistribution->abs*aprioriProb, rule->classDistribution->atint(targetClass), 100, diffFunc); 
    757758    delete diffFunc; 
    758759  } 
     760 
    759761  float quality = (ePositives + m*aprioriProb)/(rule->classDistribution->abs+m); 
    760762  if (quality > aprioriProb) 
     
    10141016          newRule->parentRule = wrule; 
    10151017 
    1016           newRule->filter.AS(TFilter_values)->conditions->push_back(mlnew TValueFilter_continuous(pos,  TValueFilter_continuous::LessEqual, cutoffs.front(), 0, 0)); 
     1018          newRule->filter.AS(TFilter_values)->conditions->push_back(mlnew TValueFilter_continuous(pos,  TValueFilter_continuous::LessEqual,     cutoffs.front(), 0, 0)); 
    10171019          newRule->filterAndStore(rule.examples, rule.weightID,targetClass); 
    10181020          if (wrule->classDistribution->cases > wnewRule->classDistribution->cases) 
     
    17401742      if ((wavgProb->at(i) > rules->at(i)->quality) && (betas[i]-step)>=minBeta) { 
    17411743        newEval = compPotEval(i, getClassIndex(rules->at(i)), betas[i]-step,tempF,tempP,wavgProb,wpriorProb); 
    1742                 betas[i] = betas[i]-step; 
     1744        if (betas[i]-step<minBeta) 
     1745          betas[i] = 0.0; 
     1746        else 
     1747                  betas[i] = betas[i]-step; 
    17431748        changedOptimistic = true; 
    17441749      } 
     
    17781783      if (newEval>eval && wavgProb->at(i) <= rules->at(i)->quality) { //   
    17791784            memcpy(oldBetasU,betas,sizeof(float)*rules->size()); 
    1780                 betas[i] = betas[i]+step; 
     1785        if ((betas[i]+step) < minBeta) 
     1786          betas[i] = minBeta; 
     1787        else 
     1788                  betas[i] = betas[i]+step; 
    17811789        newEval = cutOptimisticBetas(step, newEval); 
    17821790        if (newEval>eval) { 
     
    19161924{ 
    19171925  float dif = 0.0; 
    1918   if (betas[ruleIndex] > minBeta && newBeta > minBeta) 
     1926  if (betas[ruleIndex] >= minBeta && newBeta >= minBeta) 
    19191927    dif = newBeta - betas[ruleIndex]; 
    1920   else if (betas[ruleIndex] > minBeta) { 
     1928  else if (betas[ruleIndex] >= minBeta) { 
    19211929    dif = -betas[ruleIndex]; 
    19221930  } 
    1923   else if (newBeta > minBeta) 
     1931  else if (newBeta >= minBeta) 
    19241932    dif = newBeta; 
     1933  else  
     1934      dif = minBeta - betas[ruleIndex]; 
    19251935/*  if (ruleIndex == 0) 
    19261936    raiseWarning("dif = %f, %d, %d", dif, useBestRuleOnly, classIndex);*/ 
Note: See TracChangeset for help on using the changeset viewer.