# constancedongg/horse-racing architecture

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

- Interactive diagram: https://gitdiagram.com/constancedongg/horse-racing
- Repository: https://github.com/constancedongg/horse-racing

## Overview

##### Main Components
- Data Sources:
- The raw input files: training.csv, testing.csv, race-result-horse.csv, and race-result-race.csv (these represent the data foundation from Kaggle and the Hong Kong Jockey Club).
- Data Processing & Preprocessing:
- Preprocessing steps that the Notebook carries out (including cleaning, feature engineering, and merging of race and horse data).
- Machine Learning Models:
- Classification algorithms: Logistic Regression, Naïve Bayes, SVM Classifier, Random Forest.
- Regression methods: SVR and Gradient Boosting Regression Tree (GBRT model).
- Prediction Outputs:
- The prediction CSV files, e.g., lr_predictions.csv, nb_predictions.csv, svm_predictions.csv, rf_predictions.csv, reg_prediction.csv, and nb_predictions.csv.
- Analysis & Betting Strategy:
- The Notebook also contains evaluation, model performance comparisons, and concluding recommendations about betting strategies.

##### Relationships and Interactions
- Data Flow:
- From Data Processing, output flows into each ML Model component.
- Evaluation & Strategy:
- A feedback loop from Prediction Outputs (and optionally the processed data) to an Analysis/Strategy component where results are compared and insights are drawn.
- Notebook as an Orchestrator:
- Jupyter Notebook (Horse_Racing.ipynb) as the central orchestration hub that ties data ingestion, preprocessing, model building, prediction generation, and strategy development together.

##### Architectural Patterns
- Data Pipeline Pattern: Separate inputs (raw data) from processing steps (preprocessing, feature engineering, model training/evaluation).
- Modular ML Pipeline: Each algorithm (classification and regression) can be depicted as a modular “component” with specific inputs and outputs.

##### Relevant Technologies and Tools
- Jupyter Notebook (Python environment) as the main development and narrative tool.
- Machine Learning libraries (implied: scikit-learn or similar, based on the algorithms mentioned).
- CSV files denote direct file-based persistence for both input data and predictions.

##### Additional Detail
- Although the project is not a full-stack application, it benefits from a clear separation into sub-systems (data ingestion, processing, modeling, predictions, analysis) which helps in both understanding and potentially extending the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources Subgraph
    subgraph "Data Sources"
        D1["training.csv"]:::datasource
        D2["testing.csv"]:::datasource
        D3["race-result-horse.csv"]:::datasource
        D4["race-result-race.csv"]:::datasource
    end

    %% Data Processing & Preprocessing (Jupyter Notebook)
    NP["Jupyter Notebook: Horse_Racing.ipynb"]:::notebook

    %% ML Models Subgraph
    subgraph "Machine Learning Models"
        subgraph "Classification Models"
            LR["Logistic Regression"]:::model
            NB["Naïve Bayes"]:::model
            SVM["SVM Classifier"]:::model
            RF["Random Forest"]:::model
        end
        subgraph "Regression Models"
            SVR["SVR Model"]:::model
            GB["Gradient Boosting Regression"]:::model
        end
    end

    %% Prediction Outputs Subgraph
    subgraph "Prediction Outputs"
        lrPred["lr_predictions.csv"]:::output
        nbPred["nb_predictions.csv"]:::output
        svmPred["svm_predictions.csv"]:::output
        rfPred["rf_predictions.csv"]:::output
        regPred["reg_prediction.csv"]:::output
    end

    %% Analysis & Betting Strategy
    ABS["Analysis & Betting Strategy"]:::analysis

    %% Data Flow Connections
    D1 -->|"input"| NP
    D2 -->|"input"| NP
    D3 -->|"input"| NP
    D4 -->|"input"| NP

    NP -->|"process"| LR
    NP -->|"process"| NB
    NP -->|"process"| SVM
    NP -->|"process"| RF
    NP -->|"process"| SVR
    NP -->|"process"| GB

    LR -->|"predict"| lrPred
    NB -->|"predict"| nbPred
    SVM -->|"predict"| svmPred
    RF -->|"predict"| rfPred
    SVR -->|"predict"| regPred
    GB -->|"predict"| regPred

    lrPred -->|"analyze"| ABS
    nbPred -->|"analyze"| ABS
    svmPred -->|"analyze"| ABS
    rfPred -->|"analyze"| ABS
    regPred -->|"analyze"| ABS

    %% Click Events
    click D1 "https://github.com/constancedongg/horse-racing/blob/master/training.csv"
    click D2 "https://github.com/constancedongg/horse-racing/blob/master/testing.csv"
    click D3 "https://github.com/constancedongg/horse-racing/blob/master/race-result-horse.csv"
    click D4 "https://github.com/constancedongg/horse-racing/blob/master/race-result-race.csv"
    click NP "https://github.com/constancedongg/horse-racing/blob/master/Horse_Racing.ipynb"
    click lrPred "https://github.com/constancedongg/horse-racing/blob/master/lr_predictions.csv"
    click nbPred "https://github.com/constancedongg/horse-racing/blob/master/nb_predictions.csv"
    click svmPred "https://github.com/constancedongg/horse-racing/blob/master/svm_predictions.csv"
    click rfPred "https://github.com/constancedongg/horse-racing/blob/master/rf_predictions.csv"
    click regPred "https://github.com/constancedongg/horse-racing/blob/master/reg_prediction.csv"
    click ABS "https://github.com/constancedongg/horse-racing/blob/master/Horse_Racing.ipynb"

    %% Styles
    classDef datasource fill:#FED,stroke:#A55,stroke-width:2px;
    classDef notebook fill:#BBF,stroke:#446,stroke-width:2px;
    classDef model fill:#DFD,stroke:#4A4,stroke-width:2px;
    classDef output fill:#FCF,stroke:#C6C,stroke-width:2px;
    classDef analysis fill:#FFB,stroke:#B55,stroke-width:2px;
```
