Files
wehub-resource-sync 0d3cb498a3
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Waiting to run
Test and Publish Multi-arch Docker Image / test (push) Waiting to run
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Blocked by required conditions
Validate Renovate Config / Validate Renovate Configuration (push) Waiting to run
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:24:08 +08:00

50 lines
1.5 KiB
Python

from typing import Dict, List
import pandas as pd
from datasets import Dataset, load_dataset
def prepare_imdb_data() -> None:
"""
Prepare and sample IMDB dataset for sentiment analysis evaluation.
Loads data from HuggingFace, converts to DataFrame, and saves a sample to CSV.
"""
# Load the IMDB dataset
print("Loading IMDB dataset...")
imdb: Dataset = load_dataset("imdb") # type: ignore
# Convert labels to more readable format
label_map: Dict[int, str] = {0: "negative", 1: "positive"}
# Create dataframe from test set (we'll use this for zero-shot evaluation)
texts: List[str] = imdb["test"]["text"] # type: ignore
labels: List[int] = imdb["test"]["label"] # type: ignore
eval_df: pd.DataFrame = pd.DataFrame(
{
"text": texts,
"sentiment": [label_map[label] for label in labels],
}
)
# Take a small sample for evaluation
eval_sample: pd.DataFrame = eval_df.sample(n=100, random_state=0)
# Save to CSV file
print("Saving sample to CSV...")
eval_sample.to_csv("imdb_eval_sample.csv", index=False)
print(f"Saved {len(eval_sample)} examples for evaluation")
# Print some statistics
print("\nLabel distribution in evaluation set:")
print(eval_sample["sentiment"].value_counts())
print("\nSample review:")
print("Text:", eval_sample["text"].iloc[0][:200], "...")
print("Sentiment:", eval_sample["sentiment"].iloc[0])
if __name__ == "__main__":
prepare_imdb_data()