docs: @Override
      public void trainOnInstanceImpl(Instance inst) {
          if (this.reset == true) {
              this.m_numClasses = inst.numClasses();
              double laplace = this.laplaceCorrectionOption.getValue();
              int numAttributes = inst.numAttributes();
  
              m_probOfClass = new double[m_numClasses];
              Arrays.fill(m_probOfClass, laplace);
  
              m_classTotals = new double[m_numClasses];
              Arrays.fill(m_classTotals, laplace * numAttributes);
  
              m_wordTotalForClass = new DoubleVector[m_numClasses];
              for (int i = 0; i< m_numClasses; i++) {
                  //Arrays.fill(wordTotal, laplace);
                  m_wordTotalForClass[i] = new DoubleVector();
              }
              this.reset = false;
          }
          // Update classifier
          int classIndex = inst.classIndex();
          int classValue = (int) inst.classValue();//value(classIndex);
  
          double w = inst.weight();
          m_probOfClass[classValue] += w;
  
          m_classTotals[classValue] += w * totalSize(inst);
          double total = m_classTotals[classValue];
  
          for (int i = 0; i < inst.numValues(); i++) {
              int index = inst.index(i);
              if (index != classIndex && !inst.isMissing(i)) {
                  //m_wordTotalForClass[index][classValue] += w * inst.valueSparse(i);
                  double laplaceCorrection = 0.0;
                  if (m_wordTotalForClass[classValue].getValue(index)== 0) {
                      laplaceCorrection = this.laplaceCorrectionOption.getValue();
                  }
                  m_wordTotalForClass[classValue].addToValue(index, w * inst.valueSparse(i) + laplaceCorrection);
              }
          }
      }