text classification - Multinomial Naive Bayes Classifier sliding window (MOA implementation, weka) -


i facing following problem: trying implement mnb classifier in sliding window. implemented linkedlist of size of window , store instances of stream have considered in it. when new instance arrives doesn't fit in window anymore first instance removed. remove corresponding word counts implemented following method same trainoninstanceimpl() moa backwards:

private void removeinstance(instance insttoremove) {      int classindex = insttoremove.classindex();     int classvalue = (int) insttoremove.value(classindex);      double w = insttoremove.weight();     m_probofclass[classvalue] -= w;      m_classtotals[classvalue] -= w * totalsize(insttoremove);     double total = m_classtotals[classvalue];      (int = 0; < insttoremove.numvalues(); i++) {         int index = insttoremove.index(i);           if (index != classindex && !insttoremove.ismissing(i)) {              double laplacecorrection = 0.0;             if (m_wordtotalforclass[classvalue].getvalue(index) == w*insttoremove.valuesparse(i) + this.laplacecorrectionoption.getvalue()) {                 laplacecorrection = this.laplacecorrectionoption.getvalue(); //1.0              }              m_wordtotalforclass[classvalue].addtovalue(index,                     (-1)*(w * insttoremove.valuesparse(i) + laplacecorrection));         }     } 

now if output m_wordtotalforclass[classvalue] different results classical mnb on stream 3000 instances instance 2000-3000 sliding window mnb (see above) window size of 1000. , differences outputs 1 instead of 0 @ points not always. guess has laplace correction. maybe there problem rounding in if-statement: if (m_wordtotalforclass[classvalue].getvalue(index) == w*insttoremove.valuesparse(i) + this.laplacecorrectionoption.getvalue()) not enter part laplace value set.

does have idea? kind of going crazy have been thinking problem may last 3 days. appreciated!


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -