# arturoviti/votedaverageperceptron-mnist architecture

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

- Interactive diagram: https://gitdiagram.com/arturoviti/votedaverageperceptron-mnist
- Repository: https://github.com/arturoviti/votedaverageperceptron-mnist

## Overview

##### Main Components
- Entry Point (main.py): This is the orchestrator that reads command-line arguments (using Argparse), sets up configurations, and triggers the training or prediction processes.
- Data Handling Module (dataSetFunctions.py): Contains functions to load, manipulate, split, and read the dataset. It interacts with the dataset stored in the “dataset/” directory.
- Configuration Module (parameters.py): Provides global parameters and settings (such as dataset splits) which can be used across modules.
- Perceptron Model (perceptronModel.py): Implements the core learning algorithms (Voted and Average Perceptron) with methods for training and prediction.
- Documentation & Supplementary Material (docs/ and README.md): While not part of runtime execution, this section provides project documentation and additional insights into the design and theoretical background.

##### Relationships and Interactions
- main.py acts as the controller. It calls functions from dataSetFunctions.py to load and pre-process the MNIST data and retrieves configuration from parameters.py.
- main.py then instantiates the Perceptron model from perceptronModel.py to either train on the dataset or make predictions, guided by command-line parameters.
- The “dataset/” folder is a data repository from which input is drawn, and output such as prediction results or error plots (via Matplotlib) is produced.

##### Important Architectural Patterns
- Modular Design: The project is separated into distinct Python modules that handle separate concerns (data manipulation, parameter handling, algorithm implementation, and main control).
- Command-line Interface (CLI): The use of Argparse indicates the design is intended for execution from the terminal while using well-defined parameters to alter behavior (e.g., selecting Voted vs. Average variations).
- Separation of Concerns: Data processing, configuration, and core algorithm logic are clearly separated into different files which promotes reusability and clarity.

##### Additional Detailed Elements
- Every node/component is clear and include brief annotations where needed (e.g., “handles image datasets”, “implements training loop”).
- That the design is modular and emphasizes separation of concerns, which is a key architectural principle in the project.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Application Layer
    subgraph "Application Layer"
        main("main.py (Controller)"):::exec
        dataHandler("dataSetFunctions.py (Data Loader & Pre-Processor)"):::util
        config("parameters.py (Configuration)"):::util
        perceptron("perceptronModel.py (Algorithm)"):::exec
    end

    %% Data Repository
    subgraph "Data Repository"
        dataset("dataset/"):::data
    end

    %% Documentation
    subgraph "Documentation"
        docs("docs/ (Documentation)"):::doc
        readme("README.md (Supplementary Material)"):::doc
    end

    %% External Libraries
    subgraph "External Libraries"
        argparse("Argparse"):::ext
        numpy("Numpy"):::ext
        matplotlib("Matplotlib"):::ext
        tqdm("Tqdm"):::ext
    end

    %% Connections between Application Components
    main -->|"loadsData"| dataHandler
    main -->|"readsParams"| config
    main -->|"triggersTrainOrPredict"| perceptron
    dataHandler -->|"readsDataset"| dataset

    %% External Libraries used by main.py and perceptronModel.py
    main -->|"uses"| argparse
    main -->|"uses"| numpy
    main -->|"uses"| matplotlib
    main -->|"uses"| tqdm
    perceptron -->|"uses"| numpy
    perceptron -->|"visualizes"| matplotlib

    %% Click Events for Components
    click main "https://github.com/arturoviti/votedaverageperceptron-mnist/blob/main/main.py"
    click dataHandler "https://github.com/arturoviti/votedaverageperceptron-mnist/blob/main/dataSetFunctions.py"
    click config "https://github.com/arturoviti/votedaverageperceptron-mnist/blob/main/parameters.py"
    click perceptron "https://github.com/arturoviti/votedaverageperceptron-mnist/blob/main/perceptronModel.py"
    click dataset "https://github.com/arturoviti/votedaverageperceptron-mnist/tree/main/dataset/"
    click docs "https://github.com/arturoviti/votedaverageperceptron-mnist/tree/main/docs/"
    click readme "https://github.com/arturoviti/votedaverageperceptron-mnist/blob/main/README.md"

    %% Styles
    classDef exec fill:#F9E79F,stroke:#d35400,stroke-width:2px;
    classDef util fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
    classDef data fill:#D5F5E3,stroke:#17A589,stroke-width:2px;
    classDef doc fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef ext fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px,stroke-dasharray: 5 5;
```
