snowflake.snowpark.DataFrameAIFunctions.classify¶
- DataFrameAIFunctions.classify(input_column: Union[snowflake.snowpark.column.Column, str], categories: Union[List[str], Column], *, output_column: Optional[str] = None, **kwargs) snowflake.snowpark.DataFrame[source]¶
Classify text or images into specified categories using AI.
This method applies AI-based classification to each row, assigning one or more categories from the provided list based on the input content.
- Parameters:
input_column – The column (Column object or column name as string) containing the text or image data to classify.
categories – List of category strings or a Column containing an array of categories. Must contain at least 2 and no more than 100 categories.
output_column – The name of the output column to be appended. If not provided, a column named
AI_CLASSIFY_OUTPUTis appended.**kwargs –
Configuration settings specified as key/value pairs. Supported keys:
task_description: A explanation of the classification task that is 50 words or fewer. This can help the model understand the context of the classification task and improve accuracy.
output_mode: Set to
multifor multi-label classification. Defaults tosinglefor single-label classification.examples: A list of example objects for few-shot learning. Each example must include:
input: Example text to classify.
labels: List of correct categories for the input.
explanation: Explanation of why the input maps to those categories.
- Returns:
A new DataFrame with an appended output column containing classification results. The output is a JSON object with a
labelsfield containing the assigned categories.
Examples:
This function or method is experimental since 1.39.0.