Project 1: Sentiment Analysis with BERT
5. Step 2: Loading and Exploring the Dataset
For this project, we’ll use the IMDb dataset, which contains movie reviews labeled as positive or negative. Optionally, you can include a neutral label for a three-class classification.
Code Example: Load Dataset
# Load IMDb dataset
dataset = load_dataset("imdb")
# Split dataset into train and test sets
train_data = dataset["train"]
test_data = dataset["test"]
# Display an example review
example = train_data[0]
print(f"Review: {example['text']}")
print(f"Label: {'Positive' if example['label'] == 1 else 'Negative'}")
5. Step 2: Loading and Exploring the Dataset
For this project, we’ll use the IMDb dataset, which contains movie reviews labeled as positive or negative. Optionally, you can include a neutral label for a three-class classification.
Code Example: Load Dataset
# Load IMDb dataset
dataset = load_dataset("imdb")
# Split dataset into train and test sets
train_data = dataset["train"]
test_data = dataset["test"]
# Display an example review
example = train_data[0]
print(f"Review: {example['text']}")
print(f"Label: {'Positive' if example['label'] == 1 else 'Negative'}")
5. Step 2: Loading and Exploring the Dataset
For this project, we’ll use the IMDb dataset, which contains movie reviews labeled as positive or negative. Optionally, you can include a neutral label for a three-class classification.
Code Example: Load Dataset
# Load IMDb dataset
dataset = load_dataset("imdb")
# Split dataset into train and test sets
train_data = dataset["train"]
test_data = dataset["test"]
# Display an example review
example = train_data[0]
print(f"Review: {example['text']}")
print(f"Label: {'Positive' if example['label'] == 1 else 'Negative'}")
5. Step 2: Loading and Exploring the Dataset
For this project, we’ll use the IMDb dataset, which contains movie reviews labeled as positive or negative. Optionally, you can include a neutral label for a three-class classification.
Code Example: Load Dataset
# Load IMDb dataset
dataset = load_dataset("imdb")
# Split dataset into train and test sets
train_data = dataset["train"]
test_data = dataset["test"]
# Display an example review
example = train_data[0]
print(f"Review: {example['text']}")
print(f"Label: {'Positive' if example['label'] == 1 else 'Negative'}")