Code icon

The App is Under a Quick Maintenance

We apologize for the inconvenience. Please come back later

Menu iconMenu iconNLP with Transformers: Fundamentals and Core Applications
NLP with Transformers: Fundamentals and Core Applications

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'}")