Complete the code to load the domain-specific sentiment dataset.
import pandas as pd data = pd.read_csv('[1]')
The domain-specific sentiment dataset is stored in 'domain_sentiment.csv'. Loading this file ensures the model learns from relevant data.
Complete the code to split the dataset into features and labels.
X = data['[1]'] y = data['sentiment']
The feature column containing the text data is named 'text'. This is used as input for the model.
Fix the error in the code to vectorize the text data using TF-IDF.
from sklearn.feature_extraction.text import TfidfVectorizer vectorizer = TfidfVectorizer() X_vectorized = vectorizer.[1](X)
To convert raw text into TF-IDF features, use 'fit_transform' which fits the vectorizer and transforms the data in one step.
Fill both blanks to train a logistic regression model and predict sentiments.
from sklearn.linear_model import LogisticRegression model = LogisticRegression() model.[1](X_vectorized, y) predictions = model.[2](X_vectorized)
First, train the model using 'fit'. Then, use 'predict' to get sentiment predictions on the data.
Fill all three blanks to compute accuracy, precision, and recall for the model.
from sklearn.metrics import [1], [2], [3] accuracy = accuracy_score(y, predictions) precision = precision_score(y, predictions, average='macro') recall = recall_score(y, predictions, average='macro')
To evaluate the model, import 'accuracy_score', 'precision_score', and 'recall_score' from sklearn.metrics.