protected Frame scoreImpl ( Frame adaptFrm ) { if ( isSupervised ( ) ) { int ridx = adaptFrm . find ( responseName ( ) ) ; assert ridx == - 1 : "Adapted frame should not contain response in scoring method!" ; assert nfeatures ( ) == adaptFrm . numCols ( ) : "Number of model features " + nfeatures ( ) + " != number of test set columns: " + adaptFrm . numCols ( ) ; assert adaptFrm . vecs ( ) . length == nfeatures ( ) : "Scoring data set contains wrong number of columns: " + adaptFrm . vecs ( ) . length + " instead of " + nfeatures ( ) ; } // Create a new vector for response // If the model produces a classification/enum, copy the domain into the // result vector. int nc = nclasses ( ) ; Vec [ ] newVecs = new Vec [ ] { adaptFrm . anyVec ( ) . makeZero ( classNames ( ) ) } ; if ( nc > 1 ) newVecs = Utils . join ( newVecs , adaptFrm . anyVec ( ) . makeZeros ( nc ) ) ; String [ ] names = new String [ newVecs . length ] ; names [ 0 ] = "predict" ; for ( int i = 1 ; i < names . length ; ++ i ) names [ i ] = classNames ( ) [ i - 1 ] ; final int num_features = nfeatures ( ) ; new MRTask2 ( ) { @ Override public void map ( Chunk chks [ ] ) { double tmp [ ] = new double [ num_features ] ; // We do not need the last field representing response float preds [ ] = new float [ nclasses ( ) == 1 ? 1 : nclasses ( ) + 1 ] ; int len = chks [ 0 ] . _len ; for ( int row = 0 ; row < len ; row ++ ) { float p [ ] = score0 ( chks , row , tmp , preds ) ; for ( int c = 0 ; c < preds . length ; c ++ ) chks [ num_features + ] . set0 ( row , p [ ] ) ; } } } . doAll ( Utils . join ( adaptFrm . vecs ( ) , newVecs ) ) ; // Return just the output columns return new Frame ( names , newVecs ) ; }
Score already adapted frame .