A comprehensive e-commerce product validation system that uses AI to assess products for market opportunities.
STEP 0: Trend Filtering (step0_trend_filter.py)
β’ Removes one-word keywords (too non-specific)
β’ Removes growing search trends (slope > 0)
β’ Keeps: Multi-word keywords with declining/flat trends
STEP 1: Brand Identification (step1_brand_identifier.py)
β’ Removes branded products (can't compete without massive budgets)
β’ Keeps: Generic product terms only
STEP 2: Product Assessment (step2_product_validator.py)
β’ No filtering - assesses all products across 7 criteria
β’ Output: Final validated list with AI scores
- Brand Identification: Automatically identifies branded vs. generic products using AI
- Product Assessment: AI-powered evaluation of products across 7 key criteria
- Batch Processing: Efficient processing of large datasets with rate limiting
- Resume Functionality: Robust crash recovery and progress tracking
- Pipeline Automation: Complete workflow from raw data to validated products
- Seasonal Demand (0-5): 0=flat year, 5=strongly seasonal
- Specificity (0-5): 0=very broad, 5=very precise
- Commodity Level (0-5): 0=brand-owned, 5=commodity
- Subscribe & Save (0-5): 0=not suitable, 5=perfect consumable
- Gated (0/1): 1 if restricted Amazon category, else 0
- Electronics/Batteries (0/1): 1 if electronic/battery-powered, else 0
- Insurance/Gov (0/1): 1 if reimbursed by insurance or supplied free by gov programs
product-validator_analytics/
βββ step0_trend_filter.py # Trend filtering and keyword specificity
βββ step1_brand_identifier.py # Brand identification with resume functionality
βββ step2_product_validator.py # AI product assessment
βββ pipeline.py # Automated workflow runner
βββ search_terms_sample.csv # Input data (Search Term + monthly data)
βββ csv_outputs/ # Output directory
β βββ step0-brand-filtered.csv # All products with brand data
β βββ step0-no-brand-products.csv # Filtered no-brand products
β βββ step1-products-assessed.csv # Final output with AI assessments
β βββ progress.json # Progress tracking (auto-created)
β βββ step0-brand-filtered-PARTIAL.csv # Partial results (auto-created)
βββ README.md # This file
OPENAI_API_KEY: Your OpenAI API key (required)
BATCH_SIZE: Number of terms processed concurrently (default: 5)DELAY_BETWEEN_BATCHES: Delay between batches in seconds (default: 1)INPUT_CSV: Input file path (default: "search_terms_sample.csv")CSV_FOLDER: Output directory (default: "csv_outputs")
-
Set your OpenAI API key:
export OPENAI_API_KEY='your-api-key-here'
-
Run the complete pipeline:
python3 pipeline.py
python3 step0_trend_filter.py- Filters products by declining trends and keyword specificity
- Removes one-word keywords (too non-specific)
- Calculates linear regression slopes (ignoring zeros)
- Keeps only declining or flat trends
python3 step1_brand_identifier.py- Processes input CSV to identify branded vs. generic products
- Resume functionality: Automatically detects and offers to resume from previous runs
- Progress tracking: Saves progress after each batch
- Crash recovery: Gracefully handles rate limits and errors
python3 step2_product_validator.py- Assesses products using AI across 7 criteria
- Processes in batches of 10 with 2-second delays
- Preserves all monthly data while adding AI assessments
The brand identifier automatically detects when you're resuming a previous run and offers you options:
- Resume from where you left off - Continues processing from the last completed batch
- Start fresh - Overwrites existing results and starts over
- View partial results - Shows what was already processed
progress.json: Tracks current batch, total processed, timestampsstep0-brand-filtered-PARTIAL.csv: Partial results saved after each batch- Auto-cleanup: Progress files are removed when processing completes successfully
- Rate limit hit: Progress saved, graceful exit with clear instructions
- Mac sleep/crash: Progress saved, resume from exact failure point
- API errors: Individual batch errors logged, processing continues
- Manual interruption: Progress saved, can resume later
π EXISTING PROGRESS DETECTED!
Input file: search_terms_sample.csv
Last processed: Batch 45/2600
Keywords processed: 225
Timestamp: 2024-01-15 14:30:25
Do you want to:
1. Resume from where you left off
2. Start fresh (overwrite existing results)
3. View partial results
Enter choice (1/2/3): 1
π Resuming from batch 46/2600
Already processed: 225 keywords
- 36 keywords: ~8 minutes (8 batches Γ 1 second delay)
- 13,000 keywords: ~50 minutes (2,600 batches Γ 1 second delay)
- 100,000 keywords: ~6 hours (20,000 batches Γ 1 second delay)
- Increase batch size: Change
BATCH_SIZEfrom 5 to 10 - Reduce delays: Change
DELAY_BETWEEN_BATCHESfrom 1 to 0.5 seconds - Combined optimization: 10 batches + 0.5s delay = ~2.5x faster
- Current approach: All data stored in RAM (efficient for <100k keywords)
- Streaming approach: Row-by-row processing (better for >100k keywords)
- Typical usage: 13k keywords β 50-100 MB RAM
- Automatic detection of OpenAI rate limit errors
- Progress preservation before graceful exit
- Clear instructions for resuming later
- Individual batch errors don't crash the entire process
- Error logging for debugging
- Graceful degradation with error placeholders
- Partial results saved after each batch
- Progress tracking with timestamps
- Input file validation to prevent corruption
- Rate limit hit: Script saves progress and exits gracefully
- API key issues: Check environment variable and API key validity
- File not found: Ensure input CSV exists and has correct format
- Memory issues: For very large datasets, consider streaming approach
- Check progress files in
csv_outputs/directory - Verify API key and rate limit status
- Run script again and choose resume option
- Monitor progress with detailed logging
- Streaming processing for datasets >100k keywords
- Advanced rate limit handling with exponential backoff
- Progress visualization with real-time charts
- Cloud deployment for enterprise-scale processing
- Configurable assessment criteria via JSON files
- Multiple AI model support (GPT-4, Claude, etc.)
- Custom filtering rules for specific business needs
- Export formats (Excel, JSON, API endpoints)
This system is designed for e-commerce product research and validation. Feel free to adapt it for your specific needs and contribute improvements.
Use this system responsibly and in accordance with OpenAI's terms of service.