Vectorizar texto
Ahora transformarás la columna title del conjunto de datos volunteer en un vector de texto, que utilizarás en una tarea de predicción en el siguiente ejercicio.
Este ejercicio forma parte del curso
Preprocesamiento para machine learning en Python
Instrucciones del ejercicio
- Guarda la columna
volunteer["title"]en una variable llamadatitle_text. - Instanciar un
TfidfVectorizercomotfidf_vec. - Transforma el texto de
title_texten un vector tf-idf utilizandotfidf_vec.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Take the title text
title_text = ____
# Create the vectorizer method
tfidf_vec = ____
# Transform the text into tf-idf vectors
text_tfidf = tfidf_vec.____(____)