Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions template/steps/dataset_loader/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,23 @@ def data_loader(

# Load dataset based on the dataset value
{%- if dataset == 'financial_news' %}
dataset = load_dataset("zeroshot/twitter-financial-news-sentiment")
dataset = load_dataset(
"zeroshot/twitter-financial-news-sentiment",
trust_remote_code=True,
)
{%- endif %}
{%- if dataset == 'imdb_reviews' %}
dataset = load_dataset("imdb")["train"]
dataset = load_dataset(
"imdb",
trust_remote_code=True,
)["train"]
dataset = dataset.train_test_split(test_size=0.25, shuffle=True)
{%- endif %}
{%- if dataset == 'airline_reviews' %}
dataset = load_dataset("Shayanvsf/US_Airline_Sentiment")
dataset = load_dataset(
"Shayanvsf/US_Airline_Sentiment",
trust_remote_code=True,
)
dataset = dataset.rename_column("airline_sentiment", "label")
dataset = dataset.remove_columns(["airline_sentiment_confidence","negativereason_confidence"])
{%- endif %}
Expand Down
6 changes: 3 additions & 3 deletions template/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def compute_metrics(eval_pred: Tuple[np.ndarray, np.ndarray]) -> Dict[str, float
logits, labels = eval_pred
predictions = np.argmax(logits, axis=-1)
# calculate the mertic using the predicted and true value
accuracy = load_metric("accuracy").compute(
accuracy = load_metric("accuracy", trust_remote_code=True).compute(
predictions=predictions, references=labels
)
f1 = load_metric("f1").compute(
f1 = load_metric("f1", trust_remote_code=True).compute(
predictions=predictions, references=labels, average="weighted"
)
precision = load_metric("precision").compute(
precision = load_metric("precision", trust_remote_code=True).compute(
predictions=predictions, references=labels, average="weighted"
)
return {
Expand Down