Interface Model

  • All Known Implementing Classes:
    ModelImpl

    @PublicEvolving
    public interface Model
    The Model object is the core abstraction for ML model resources in the Table API.

    A Model object describes a machine learning model resource that can be used for inference operations. It provides methods to perform prediction on data tables.

    The Model interface offers main operations:

    ml_predict operation supports runtime options for configuring execution parameters such as asynchronous execution mode.

    Every Model object has input and output schemas that describe the expected data structure for model operations, available through getResolvedInputSchema() and getResolvedOutputSchema().

    Example usage:

    
     Model model = tableEnv.fromModel("my_model");
    
     // Simple prediction
     Table predictions = model.predict(inputTable, ColumnList.of("feature1", "feature2"));
    
     // Prediction with options
     Map<String, String> options = Map.of("max-concurrent-operations", "100", "timeout", "30s", "async", "true");
     Table predictions = model.predict(inputTable, ColumnList.of("feature1", "feature2"), options);
     
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      ApiExpression asArgument​(String name)
      Converts this model object into a named argument.
      org.apache.flink.table.catalog.ResolvedSchema getResolvedInputSchema()
      Returns the resolved input schema of this model.
      org.apache.flink.table.catalog.ResolvedSchema getResolvedOutputSchema()
      Returns the resolved output schema of this model.
      Table predict​(Table table, org.apache.flink.types.ColumnList inputColumns)
      Performs prediction on the given table using specified input columns.
      Table predict​(Table table, org.apache.flink.types.ColumnList inputColumns, Map<String,​String> options)
      Performs prediction on the given table using specified input columns with runtime options.
    • Method Detail

      • getResolvedInputSchema

        org.apache.flink.table.catalog.ResolvedSchema getResolvedInputSchema()
        Returns the resolved input schema of this model.

        The input schema describes the structure and data types of the input columns that the model expects for inference operations.

        Returns:
        the resolved input schema.
      • getResolvedOutputSchema

        org.apache.flink.table.catalog.ResolvedSchema getResolvedOutputSchema()
        Returns the resolved output schema of this model.

        The output schema describes the structure and data types of the output columns that the model produces during inference operations.

        Returns:
        the resolved output schema.
      • predict

        Table predict​(Table table,
                      org.apache.flink.types.ColumnList inputColumns)
        Performs prediction on the given table using specified input columns.

        This method applies the model to the input data to generate predictions. The input columns must match the model's expected input schema.

        Example:

        
         Table predictions = model.predict(inputTable, ColumnList.of("feature1", "feature2"));
         
        Parameters:
        table - the input table containing data for prediction
        inputColumns - the columns from the input table to use as model input
        Returns:
        a table containing the input data along with prediction results
      • predict

        Table predict​(Table table,
                      org.apache.flink.types.ColumnList inputColumns,
                      Map<String,​String> options)
        Performs prediction on the given table using specified input columns with runtime options.

        This method applies the model to the input data to generate predictions with additional runtime configuration options such as max-concurrent-operations, timeout, and execution mode settings.

        For Common runtime options, see MLPredictRuntimeConfigOptions.

        Example:

        
         Map<String, String> options = Map.of("max-concurrent-operations", "100", "timeout", "30s", "async", "true");
         Table predictions = model.predict(inputTable,
             ColumnList.of("feature1", "feature2"), options);
         
        Parameters:
        table - the input table containing data for prediction
        inputColumns - the columns from the input table to use as model input
        options - runtime options for configuring the prediction operation
        Returns:
        a table containing the input data along with prediction results
      • asArgument

        ApiExpression asArgument​(String name)
        Converts this model object into a named argument.

        This method is intended for use in function calls that accept model arguments, particularly in process table functions (PTFs) or other operations that work with models.

        Example:

        
         env.fromCall(
           "ML_PREDICT",
           inputTable.asArgument("INPUT"),
           model.asArgument("MODEL"),
           Expressions.descriptor(ColumnList.of("feature1", "feature2")).asArgument("ARGS")
         )
         
        Parameters:
        name - the name to assign to this model argument
        Returns:
        an expression that can be passed to functions expecting model arguments