Class AbstractPredictor

    • Constructor Detail

      • AbstractPredictor

        public AbstractPredictor()
    • Method Detail

      • getInput

        public final RecordPort getInput()
        The input data. Any fields specified in the PMML model must be present in the input data. Additional fields will be ignored.
        Returns:
        the input data
      • getModel

        public final PMMLPort getModel()
        The input for supplying the PMML model
        Returns:
        the input for the pmml model
      • getOutput

        public RecordPort getOutput()
        The original data with prediction appended
        Returns:
        the original data with the prediction appended
      • computeMetadata

        protected void computeMetadata​(StreamingMetadataContext ctx)
        Default implementation of computeMetadata.
        1. Output type is set to input type plus predictedType
        2. Input data ordering ( if ordered ) is preserved
        3. Input data partitioning ( if partitioned ) is preserved
        Specified by:
        computeMetadata in class StreamingOperator
        Parameters:
        ctx - the context
      • stepNext

        protected final boolean stepNext()
        Steps to the next input row, returning false at end of data
        Returns:
        true if there is still more data
      • pushPrediction

        protected final void pushPrediction()
        Pushes a prediction row consisting of input fields plus predicted fields
      • predictedType

        protected abstract RecordTokenType predictedType​(PMMLModelSpec modelSpec)
        Given the model spec, returns the predicted type. This should not include the input type ( the input is automatically prepended to the type that is returned )
        Parameters:
        modelSpec - the model metadata
        Returns:
        the predicted type
      • execute

        protected abstract void execute​(PMMLModel model,
                                        RecordValued input,
                                        ScalarSettable[] predictedFields)
        Called to perform prediction. Subclasses are expected to loop over the input by calling stepNext(). For each row of input, subclasses should first set the predicted values in the predictedFields array and then invoke pushPrediction(). Subclasses should not invoke pushEndOfData since that is automatically handled by the base class.
        Parameters:
        model - The input PMML model
        input - The input data
        predictedFields - An array of fields that reference the predicted field locations. The array positionally corresponds to the type returned by predictedType(PMMLModelSpec).