Complete the code to import the model used for text classification.
from sklearn.[1] import LogisticRegression
The LogisticRegression model is part of the linear_model module in scikit-learn, commonly used for classification tasks.
Complete the code to create a model for sentiment analysis using a pretrained transformer.
from transformers import [1] model = [1].from_pretrained('distilbert-base-uncased-finetuned-sst-2-english')
The DistilBertForSequenceClassification model is designed for sequence classification tasks like sentiment analysis.
Fix the error in the code to select the right model for named entity recognition (NER).
from transformers import AutoModelFor[1] model = AutoModelFor[1].from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english')
Named entity recognition is a token-level task, so the correct model class is AutoModelForTokenClassification.
Fill both blanks to create a pipeline for text summarization using Hugging Face.
from transformers import pipeline summarizer = pipeline(task=[1], model=[2])
The task for summarization is 'summarization' and the model 'facebook/bart-large-cnn' is a popular pretrained summarization model.
Fill all three blanks to build and evaluate a simple text classification model using scikit-learn.
from sklearn.feature_extraction.text import [1] from sklearn.linear_model import [2] from sklearn.metrics import [3] vectorizer = [1]() X_train_vec = vectorizer.fit_transform(X_train) model = [2]() model.fit(X_train_vec, y_train) y_pred = model.predict(vectorizer.transform(X_test)) score = [3](y_test, y_pred)
CountVectorizer converts text to numbers, LogisticRegression is a simple classifier, and accuracy_score measures how well the model predicts.