# joelreji/blogcommentsprediction architecture

> Architecture diagram of the GitHub repository joelreji/blogcommentsprediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joelreji/blogcommentsprediction
- Repository: https://github.com/joelreji/blogcommentsprediction

## Overview

##### Main Components
- Data Collection & Ingestion:
- BlogScraping.ipynb: Uses the PRAW API for scraping Reddit data.
- refreshtoken.py: A utility module to manage authentication (refresh token) so that the Reddit API interaction can be maintained reliably.
- Data Preparation & Feature Engineering:
- bagofWords_Reddit.ipynb: Responsible for generating 200 bag-of-words features using the data from RedditData.csv (and possibly the supplemented reddit_data_with_bow.xlsx).
- Modeling and Evaluation:
- blog_test_data.ipynb: Used to build initial models using original blog test data.
- RedditModeling.ipynb: Performs base and final modeling using the features; reddit-final.csv is mainly consumed here.
- Data Sources:
- CSV and Excel files (RedditData.csv, reddit-final.csv, reddit_data_with_bow.xlsx) provide the raw and processed datasets.
- Data set reference: The UCI BlogFeedback dataset mentioned in the README is the external source of the original data utilized in this project.

##### Relationships and Interactions
- Data flow starts with the external data source (UCI BlogFeedback) and live data extracted via the Reddit API.
- The authentication utility (refreshtoken.py) facilitates secure data scraping.
- BlogScraping.ipynb collects data from Reddit and outputs scraped features that might later be enriched or combined.
- The output data from the scraping process (e.g., RedditData.csv) is then processed for feature engineering in bagofWords_Reddit.ipynb.
- The newly engineered features (bag-of-words) along with the raw features support the downstream modeling work in blog_test_data.ipynb and RedditModeling.ipynb.
- The final refined dataset (reddit-final.csv) is used to train, validate, and compare models.

##### Architectural Patterns and Technologies
- Pipeline Pattern: The project follows a sequential data science pipeline from data ingestion to feature engineering and finally to modeling.
- Modularity: Different notebooks clearly separate concerns (e.g., data scraping vs. feature extraction vs. modeling).
- Technologies: Python (Jupyter Notebooks) for interactive computing, the PRAW API for Reddit data scraping, and common machine learning libraries likely utilized in these notebooks (even though not explicitly listed, expect libraries such as pandas, scikit-learn, etc.).
- Reusability: The refreshtoken.py module is an example of modular code designed to be reusable for API authentication.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Sources
    subgraph "External Sources"
        A("UCI BlogFeedback Dataset"):::external
        B("Reddit API"):::external
    end

    %% Data Collection
    subgraph "Data Collection"
        C("refreshtoken.py"):::utility
        D("BlogScraping.ipynb"):::notebook
    end

    %% Data Storage / Artifacts
    subgraph "Data Storage"
        E("RedditData.csv"):::file
    end

    %% Feature Engineering
    subgraph "Feature Engineering"
        F("reddit_data_with_bow.xlsx"):::file
        G("bagofWords_Reddit.ipynb"):::notebook
    end

    %% Modeling and Evaluation
    subgraph "Modeling"
        H("blog_test_data.ipynb"):::notebook
        I("reddit-final.csv"):::file
        J("RedditModeling.ipynb"):::notebook
    end

    %% Connections
    B -->|"Scrape_via_PRAW"| D
    C -->|"Token_Refresh"| D
    D -->|"Produce_RawData"| E
    E -->|"Input_RawData"| G
    F -->|"Supplement_Data"| G
    G -->|"Output_Features"| I
    A -->|"BlogFeedback_Input"| H
    I -->|"Training_Data"| J
    G -->|"Processed_Features"| J
    H -->|"Model_Comparison"| J

    %% Click Events
    click D "https://github.com/joelreji/blogcommentsprediction/blob/main/BlogScraping.ipynb"
    click C "https://github.com/joelreji/blogcommentsprediction/blob/main/refreshtoken.py"
    click G "https://github.com/joelreji/blogcommentsprediction/blob/main/bagofWords_Reddit.ipynb"
    click H "https://github.com/joelreji/blogcommentsprediction/blob/main/blog_test_data.ipynb"
    click J "https://github.com/joelreji/blogcommentsprediction/blob/main/RedditModeling.ipynb"
    click E "https://github.com/joelreji/blogcommentsprediction/blob/main/RedditData.csv"
    click I "https://github.com/joelreji/blogcommentsprediction/blob/main/reddit-final.csv"
    click F "https://github.com/joelreji/blogcommentsprediction/blob/main/reddit_data_with_bow.xlsx"

    %% Styles
    classDef external fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px;
    classDef utility fill:#fce4ec,stroke:#ad1457,stroke-width:2px;
    classDef notebook fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef file fill:#fff3e0,stroke:#e65100,stroke-width:2px;
```
