Interface Model
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:
predict(Table, ColumnList)- Applies the model to make predictions on input data
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
Modifier and TypeMethodDescriptionasArgument(String name) Converts this model object into a named argument.Returns the resolved input schema of this model.Returns the resolved output schema of this model.predict(Table table, ColumnList inputColumns) Performs prediction on the given table using specified input columns.Performs prediction on the given table using specified input columns with runtime options.
-
Method Details
-
getResolvedInputSchema
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
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
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 predictioninputColumns- the columns from the input table to use as model input- Returns:
- a table containing the input data along with prediction results
-
predict
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 predictioninputColumns- the columns from the input table to use as model inputoptions- runtime options for configuring the prediction operation- Returns:
- a table containing the input data along with prediction results
-
asArgument
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
-