# ahmadrezaomidvar/news_classification architecture

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

- Interactive diagram: https://gitdiagram.com/ahmadrezaomidvar/news_classification
- Repository: https://github.com/ahmadrezaomidvar/news_classification

## Overview

##### Main Components

a. Data Pipeline Layer:
- Input Data Source (data/data.csv)
- Data Cleaning Process (data/clean_data.csv)
- Data Preprocessing Module (news/dataset.py)

b. Model Architecture Layer:
- Traditional ML Models (news/benchmark.py)
- Logistic Regression
- Random Forest
- Support Vector Machine
- Deep Learning Model (news/lstm.py)
- LSTM Architecture

c. Training Pipeline Components:
- Cross Validation Module (news/cross_validation.py)
- Data Balancing Techniques
- SMOTE (Oversampling)
- Undersampling
- Class Weighting

d. Evaluation System:
- Metrics Collection
- F1 Score
- Accuracy
- Precision
- Recall
- Results Storage (results/ directory)

##### Flow and Relationships

1. Raw Data → Data Cleaning → Preprocessed Data
2. Preprocessed Data splits into three parallel paths:
- Traditional ML Pipeline
- LSTM Pipeline
- Cross-Validation Pipeline
3. Each path should show the various techniques (SMOTE, undersampling, weighted loss)
4. All paths converge at the Evaluation System

##### Important Design Elements

- Rectangles: Data storage/files
- Rounded rectangles: Processing modules
- Diamonds: Decision points/model selection

- Blue: Data-related components
- Green: ML/DL models
- Orange: Evaluation components
- Gray: Utility functions and configurations

##### Technical Details

- Configuration Management (news/configs/config.yaml)
- Environment Management (conda/environment.yml)
- Testing Framework (tests/ directory structure)
- Utility Functions (news/utils.py)

##### Implementation Details

- Maintain a hierarchical layout from top (data ingestion) to bottom (evaluation)
- Version control and environment management components

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Data_Pipeline
        RawData["Raw Data"]:::data
        CleanData["Clean Data"]:::data
        Preprocess["Data Preprocessing"]:::process
    end

    subgraph Model_Architecture
        subgraph Traditional
            LogReg["Logistic Regression"]:::model
            RF["Random Forest"]:::model
            SVM["Support Vector Machine"]:::model
        end
        
        subgraph Deep_Learning
            LSTM["LSTM Model"]:::model
        end
    end

    subgraph Training_Pipeline
        CV["Cross Validation"]:::process
        subgraph Balancing_Techniques
            SMOTE["SMOTE Oversampling"]:::process
            Under["Undersampling"]:::process
            Weight["Class Weighting"]:::process
        end
    end

    subgraph Evaluation
        Metrics["Metrics Collection"]:::eval
        Results["Results Storage"]:::data
    end

    subgraph Config_And_Utils
        Config["Configuration"]:::config
        Utils["Utilities"]:::util
        Env["Environment"]:::config
        Tests["Testing Framework"]:::test
    end

    RawData --> CleanData
    CleanData --> Preprocess
    Preprocess --> Traditional
    Preprocess --> Deep_Learning
    Preprocess --> CV

    LogReg & RF & SVM --> SMOTE
    LogReg & RF & SVM --> Under
    LogReg & RF & SVM --> Weight
    LSTM --> Metrics
    SMOTE & Under & Weight --> Metrics
    CV --> Metrics
    Metrics --> Results

    Config -.-> Model_Architecture
    Utils -.-> Training_Pipeline
    Env -.-> Model_Architecture
    Tests -.-> Evaluation

    %% Component Mappings
    click RawData "https://github.com/ahmadrezaomidvar/news_classification/blob/main/data/data.csv"
    click CleanData "https://github.com/ahmadrezaomidvar/news_classification/blob/main/data/clean_data.csv"
    click Preprocess "https://github.com/ahmadrezaomidvar/news_classification/blob/main/news/dataset.py"
    click Traditional "https://github.com/ahmadrezaomidvar/news_classification/blob/main/news/benchmark.py"
    click LSTM "https://github.com/ahmadrezaomidvar/news_classification/blob/main/news/lstm.py"
    click CV "https://github.com/ahmadrezaomidvar/news_classification/blob/main/news/cross_validation.py"
    click Config "https://github.com/ahmadrezaomidvar/news_classification/blob/main/news/configs/config.yaml"
    click Utils "https://github.com/ahmadrezaomidvar/news_classification/blob/main/news/utils.py"
    click Env "https://github.com/ahmadrezaomidvar/news_classification/blob/main/conda/environment.yml"
    click Tests "https://github.com/ahmadrezaomidvar/news_classification/tree/main/tests/"
    click Results "https://github.com/ahmadrezaomidvar/news_classification/tree/main/results/"
    click SMOTE "https://github.com/ahmadrezaomidvar/news_classification/tree/main/results/base_line/smote/"
    click Under "https://github.com/ahmadrezaomidvar/news_classification/tree/main/results/base_line/undersample/"
    click Weight "https://github.com/ahmadrezaomidvar/news_classification/tree/main/results/base_line/benchmark/weighted_loss/"

    %% Styling
    classDef data fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef process fill:#d9f2d9,stroke:#333,stroke-width:2px
    classDef model fill:#ffcccc,stroke:#333,stroke-width:2px
    classDef eval fill:#ffe6cc,stroke:#333,stroke-width:2px
    classDef config fill:#e6e6e6,stroke:#333,stroke-width:2px
    classDef util fill:#f2f2f2,stroke:#333,stroke-width:2px
    classDef test fill:#ffccff,stroke:#333,stroke-width:2px
```
