public static <E> CRFCliqueTree<E> getCalibratedCliqueTree(double[][] weights, int[][][] data, Index[] labelIndices,
      int numClasses, Index<E> classIndex, E backgroundSymbol) {

    FactorTable[] factorTables = new FactorTable[data.length];
    FactorTable[] messages = new FactorTable[data.length - 1];

    for (int i = 0; i < data.length; i++) {
      factorTables[i] = getFactorTable(weights, data[i], labelIndices, numClasses);

      if (i > 0) {
        messages[i - 1] = factorTables[i - 1].sumOutFront();
        factorTables[i].multiplyInFront(messages[i - 1]);
      }
    }

    for (int i = factorTables.length - 2; i >= 0; i--) {
      FactorTable summedOut = factorTables[i + 1].sumOutEnd();
      summedOut.divideBy(messages[i]);
      factorTables[i].multiplyInEnd(summedOut);
    }

    return new CRFCliqueTree<E>(factorTables, classIndex, backgroundSymbol);
  }
public static < E > CRFCliqueTree < E > getCalibratedCliqueTree ( double [ ] [ ] weights , int [ ] [ ] [ ] data , Index [ ] labelIndices , int numClasses , Index < E > classIndex , E backgroundSymbol ) { FactorTable [ ] factorTables = new FactorTable [ data . length ] ; FactorTable [ ] messages = new FactorTable [ data . length - 1 ] ; for ( int i = 0 ; i < data . length ; i ++ ) { factorTables [ i ] = getFactorTable ( weights , data [ i ] , labelIndices , numClasses ) ; if ( i > 0 ) { messages [ i - 1 ] = factorTables [ i - 1 ] . sumOutFront ( ) ; factorTables [ i ] . multiplyInFront ( messages [ i - 1 ] ) ; } } for ( int i = factorTables . length - 2 ; i >= 0 ; i -- ) { FactorTable summedOut = factorTables [ i + 1 ] . sumOutEnd ( ) ; summedOut . divideBy ( messages [ i ] ) ; factorTables [ i ] . multiplyInEnd ( summedOut ) ; } return new CRFCliqueTree < E > ( factorTables , classIndex , backgroundSymbol ) ; }
@return a new CRFCliqueTree for the weights on the data