@Override
    protected void _transform(Dataframe newData) {
        ModelParameters modelParameters = knowledgeBase.getModelParameters();
        Map<Object, Double> minColumnValues = modelParameters.getMinColumnValues();
        Map<Object, Double> maxColumnValues = modelParameters.getMaxColumnValues();
        boolean scaleResponse = knowledgeBase.getTrainingParameters().getScaleResponse() && minColumnValues.containsKey(Dataframe.COLUMN_NAME_Y);

        streamExecutor.forEach(StreamMethods.stream(newData.entries(), isParallelized()), e -> {
            Record r = e.getValue();
            AssociativeArray xData = r.getX().copy();
            Object yData = r.getY();

            boolean modified = false;
            for(Object column : r.getX().keySet()) {
                Double min = minColumnValues.get(column);
                if(min == null) {
                    continue;
                }
                Object value = xData.remove(column);
                if(value != null) {
                    Double max = maxColumnValues.get(column);
                    xData.put(column, scale(TypeInference.toDouble(value), min, max));
                }
                modified = true;
            }

            if(scaleResponse && yData != null) {
                Double value = TypeInference.toDouble(yData);
                Double min = minColumnValues.get(Dataframe.COLUMN_NAME_Y);
                Double max = maxColumnValues.get(Dataframe.COLUMN_NAME_Y);

                yData = scale(value, min, max);
                modified = true;
            }

            if(modified) {
                Integer rId = e.getKey();
                Record newR = new Record(xData, yData, r.getYPredicted(), r.getYPredictedProbabilities());

                //no modification on the actual columns takes place, safe to do.
                newData._unsafe_set(rId, newR);
            }
        });
    }
@ Override protected void _transform ( Dataframe newData ) { ModelParameters modelParameters = knowledgeBase . getModelParameters ( ) ; Map < Object , Double > minColumnValues = modelParameters . getMinColumnValues ( ) ; Map < Object , Double > maxColumnValues = modelParameters . getMaxColumnValues ( ) ; boolean scaleResponse = knowledgeBase . getTrainingParameters ( ) . getScaleResponse ( ) && minColumnValues . containsKey ( Dataframe . COLUMN_NAME_Y ) ; streamExecutor . forEach ( StreamMethods . stream ( newData . entries ( ) , isParallelized ( ) ) , e -> { Record r = e . getValue ( ) ; AssociativeArray xData = r . getX ( ) . copy ( ) ; Object yData = r . getY ( ) ; boolean modified = false ; for ( Object column : r . getX ( ) . keySet ( ) ) { Double min = minColumnValues . get ( column ) ; if ( min == null ) { continue ; } Object value = xData . remove ( column ) ; if ( value != null ) { Double max = maxColumnValues . get ( column ) ; xData . put ( column , scale ( TypeInference . toDouble ( value ) , min , max ) ) ; } modified = true ; } if ( scaleResponse && yData != null ) { Double value = TypeInference . toDouble ( yData ) ; Double min = minColumnValues . get ( Dataframe . COLUMN_NAME_Y ) ; Double max = maxColumnValues . get ( Dataframe . COLUMN_NAME_Y ) ; yData = scale ( value , min , max ) ; modified = true ; } if ( modified ) { Integer rId = e . getKey ( ) ; Record newR = new Record ( xData , yData , r . getYPredicted ( ) , r . getYPredictedProbabilities ( ) ) ; newData . _unsafe_set ( rId , newR ) ; } } ) ; }
{@inheritDoc}