public static MaxEntModel create(ByteArray byteArray)
    {
        MaxEntModel m = new MaxEntModel();
        m.correctionConstant = byteArray.nextInt();  // correctionConstant
        m.correctionParam = byteArray.nextDouble();  // getCorrectionParameter
        // label
        int numOutcomes = byteArray.nextInt();
        String[] outcomeLabels = new String[numOutcomes];
        m.outcomeNames = outcomeLabels;
        for (int i = 0; i < numOutcomes; i++) outcomeLabels[i] = byteArray.nextString();
        // pattern
        int numOCTypes = byteArray.nextInt();
        int[][] outcomePatterns = new int[numOCTypes][];
        for (int i = 0; i < numOCTypes; i++)
        {
            int length = byteArray.nextInt();
            int[] infoInts = new int[length];
            for (int j = 0; j < length; j++)
            {
                infoInts[j] = byteArray.nextInt();
            }
            outcomePatterns[i] = infoInts;
        }
        // feature
        int NUM_PREDS = byteArray.nextInt();
        String[] predLabels = new String[NUM_PREDS];
        m.pmap = new DoubleArrayTrie<Integer>();
        for (int i = 0; i < NUM_PREDS; i++)
        {
            predLabels[i] = byteArray.nextString();
        }
        Integer[] v = new Integer[NUM_PREDS];
        for (int i = 0; i < v.length; i++)
        {
            v[i] = byteArray.nextInt();
        }
        m.pmap.load(byteArray, v);
        // params
        Context[] params = new Context[NUM_PREDS];
        int pid = 0;
        for (int i = 0; i < outcomePatterns.length; i++)
        {
            int[] outcomePattern = new int[outcomePatterns[i].length - 1];
            for (int k = 1; k < outcomePatterns[i].length; k++)
            {
                outcomePattern[k - 1] = outcomePatterns[i][k];
            }
            for (int j = 0; j < outcomePatterns[i][0]; j++)
            {
                double[] contextParameters = new double[outcomePatterns[i].length - 1];
                for (int k = 1; k < outcomePatterns[i].length; k++)
                {
                    contextParameters[k - 1] = byteArray.nextDouble();
                }
                params[pid] = new Context(outcomePattern, contextParameters);
                pid++;
            }
        }
        // prior
        m.prior = new UniformPrior();
        m.prior.setLabels(outcomeLabels);
        // eval
        m.evalParams = new EvalParameters(params, m.correctionParam, m.correctionConstant, outcomeLabels.length);
        return m;
    }
public static MaxEntModel create ( ByteArray byteArray ) { MaxEntModel m = new MaxEntModel ( ) ; m . correctionConstant = byteArray . nextInt ( ) ; m . correctionParam = byteArray . nextDouble ( ) ; int numOutcomes = byteArray . nextInt ( ) ; String [ ] outcomeLabels = new String [ numOutcomes ] ; m . outcomeNames = outcomeLabels ; for ( int i = 0 ; i < numOutcomes ; i ++ ) outcomeLabels [ i ] = byteArray . nextString ( ) ; int numOCTypes = byteArray . nextInt ( ) ; int [ ] [ ] outcomePatterns = new int [ numOCTypes ] [ ] ; for ( int i = 0 ; i < numOCTypes ; i ++ ) { int length = byteArray . nextInt ( ) ; int [ ] infoInts = new int [ length ] ; for ( int j = 0 ; j < length ; j ++ ) { infoInts [ j ] = byteArray . nextInt ( ) ; } outcomePatterns [ i ] = infoInts ; } int NUM_PREDS = byteArray . nextInt ( ) ; String [ ] predLabels = new String [ NUM_PREDS ] ; m . pmap = new DoubleArrayTrie < Integer > ( ) ; for ( int i = 0 ; i < NUM_PREDS ; i ++ ) { predLabels [ i ] = byteArray . nextString ( ) ; } Integer [ ] v = new Integer [ NUM_PREDS ] ; for ( int i = 0 ; i < v . length ; i ++ ) { v [ i ] = byteArray . nextInt ( ) ; } m . pmap . load ( byteArray , v ) ; Context [ ] params = new Context [ NUM_PREDS ] ; int pid = 0 ; for ( int i = 0 ; i < outcomePatterns . length ; i ++ ) { int [ ] outcomePattern = new int [ outcomePatterns [ i ] . length - 1 ] ; for ( int k = 1 ; k < outcomePatterns [ i ] . length ; k ++ ) { outcomePattern [ k - 1 ] = outcomePatterns [ i ] [ k ] ; } for ( int j = 0 ; j < outcomePatterns [ i ] [ 0 ] ; j ++ ) { double [ ] contextParameters = new double [ outcomePatterns [ i ] . length - 1 ] ; for ( int k = 1 ; k < outcomePatterns [ i ] . length ; k ++ ) { contextParameters [ k - 1 ] = byteArray . nextDouble ( ) ; } params [ pid ] = new Context ( outcomePattern , contextParameters ) ; pid ++ ; } } m . prior = new UniformPrior ( ) ; m . prior . setLabels ( outcomeLabels ) ; m . evalParams = new EvalParameters ( params , m . correctionParam , m . correctionConstant , outcomeLabels . length ) ; return m ; }
从字节流快速加载
@param byteArray
@return