Sklearn TF-IDF Vectorizer icon

Sklearn TF-IDF Vectorizer

Convert text to TF-IDF feature vectors using scikit-learn

Transform

AI-generated

Summary

Transform text columns into TF-IDF feature vectors using a fitted scikit-learn vectorizer.

Inputs

  • vectorizerData (required) — JSON string containing the fitted vectorizer
  • transformTextColumn (required) — Name of the column containing text
  • pythonPath — Path to Python executable with scikit-learn installed

Output shape

a list of records, each containing tfidf_features (dictionary of term weights) and tfidf_vector (list of weights); the first record also includes metadata such as vocabulary_size and feature_names

Subsequent records omit the metadata fields; the shape is always an array.

Examples

Example 1: Fit and transform a text column

operation=fitTransform, vectorizerData='', transformTextColumn='body', maxFeatures=500, ngramMin=1, ngramMax=2, stopWords='english', lowercase=true

Example 2: Transform using an existing vectorizer

operation=transform, vectorizerData='{"max_features":500,"ngram_range":[1,2],"stop_words":"english","lowercase":true}', transformTextColumn='subject'

Example 3: Use a custom Python interpreter

operation=fitTransform, pythonPath='/usr/local/bin/python3.11', textColumn='description', maxFeatures=300

Discussion