Skip to content

Zer0-Bug/Perceptron-Binary-Classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perceptron Algorithm: Binary Classification

Python NumPy Matplotlib License

A clean implementation of the Perceptron Learning Algorithm for binary classification tasks. This project demonstrates the iterative weight adjustment process to separate data points into distinct classes (2 and 4) using a threshold-based decision function and structured Excel datasets.

° ° ° °



Technical Architecture

The implementation follows a modular linear classification pipeline designed for binary prediction. It manages both training and inference with custom logic:

  1. Data Ingestion: Utilizes pandas to read structured multi-sheet Excel files, separating Training (TRAINData) and Test (TESTData) environments.
  2. Perceptron Training: Implements the stochastic weight update rule. It iterates through the dataset for 1000 epochs, adjusting the hyperplane at each misclassification.
  3. Threshold Activation: Employs a zero-threshold activation function to categorize inputs into binary labels (Class 2 / Class 4).
  4. Result Serialization: Includes a feature to save predicted test results back into an formatted Excel output for further analysis.


Project Structure

Perceptron-Binary-Classifier/
├── LICENSE                                   # MIT License
├── README.md                                 # Project documentation
├── .gitattributes                            # Git configuration
├── DataForPerceptron.xlsx                    # Raw dataset (TRAIN/TEST sheets)
├── Project Report.pdf                        # Research and project report
│
└── Implementation/
    └── PerceptronAlgorithm.py                # Core algorithm and execution script


Mathematical Foundations

1. Linear Combination (Summation)

The input features are multiplied by their respective weights and added to the bias term.

z = Σ (wᵢ * xᵢ) + b

2. Step Activation Function

The decision rule that classifies the output based on the value of z.

f(z) = { 2  if z < 0
       { 4  if z ≥ 0

3. Weight Update Rule

The perceptron learning rule used to adjust weights when a misclassification occurs.

w := w + α * (y_actual - y_pred) * x
b := b + α * (y_actual - y_pred)


Technical Specifications

Component Specification Details
Algorithm Perceptron Learning Rule
Classification Type Binary Category (2 vs 4)
Learning Rate (α) 0.1 (Constant)
Max Epochs 1000 Iterations
Input Format Excel (.xlsx) with Feature Matrix
Weight Initialization Zero Initialized Weights & Bias


Deployment & Installation

Repository Acquisition

To setup the environment locally, execute:

git clone https://github.com/Zer0-Bug/Perceptron-Binary-Classifier.git
cd Perceptron-Binary-Classifier

Environment Preparation

The project requires the following numerical and data manipulation libraries:

# Optional: Setup virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install essential dependencies
pip install numpy pandas openpyxl

Running the Classifier

Execute the primary script to train the model and generate predictions:

python PerceptronAlgorithm.py


Contribution

Contributions are always appreciated. Open-source projects grow through collaboration, and any improvement—whether a bug fix, new feature, documentation update, or suggestion—is valuable.

To contribute, please follow the steps below:

  1. Fork the repository.
  2. Create a new branch for your change:
    git checkout -b feature/your-feature-name
  3. Commit your changes with a clear and descriptive message:
    git commit -m "Add: brief description of the change"
  4. Push your branch to your fork:
    git push origin feature/your-feature-name
  5. Open a Pull Request describing the changes made.

All contributions are reviewed before being merged. Please ensure that your changes follow the existing code style and include relevant documentation or tests where applicable.

References

  1. Frank Rosenblatt (1958) - The Perceptron: A Probabilistic Model for Information Storage and Organization. Psychological Review.
  2. Hastie et al. (2009) - The Elements of Statistical Learning. Springer New York.
  3. Goodfellow, I., Bengio, Y., & Courville, A. (2016) - Deep Learning, MIT Press.


Email × LinkedIn


About

From-scratch Perceptron Learning Algorithm for binary classification, showcasing iterative weight optimization and linear decision boundary formation on labeled datasets.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages