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.
The implementation follows a modular linear classification pipeline designed for binary prediction. It manages both training and inference with custom logic:
- Data Ingestion: Utilizes
pandasto read structured multi-sheet Excel files, separating Training (TRAINData) and Test (TESTData) environments. - Perceptron Training: Implements the stochastic weight update rule. It iterates through the dataset for 1000 epochs, adjusting the hyperplane at each misclassification.
- Threshold Activation: Employs a zero-threshold activation function to categorize inputs into binary labels (Class 2 / Class 4).
- Result Serialization: Includes a feature to save predicted test results back into an formatted Excel output for further analysis.
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
The input features are multiplied by their respective weights and added to the bias term.
z = Σ (wᵢ * xᵢ) + b
The decision rule that classifies the output based on the value of z.
f(z) = { 2 if z < 0
{ 4 if z ≥ 0
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)
| 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 |
To setup the environment locally, execute:
git clone https://github.com/Zer0-Bug/Perceptron-Binary-Classifier.gitcd Perceptron-Binary-ClassifierThe 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 openpyxlExecute the primary script to train the model and generate predictions:
python PerceptronAlgorithm.pyContributions 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:
- Fork the repository.
- Create a new branch for your change:
git checkout -b feature/your-feature-name - Commit your changes with a clear and descriptive message:
git commit -m "Add: brief description of the change" - Push your branch to your fork:
git push origin feature/your-feature-name - 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.
- Frank Rosenblatt (1958) - The Perceptron: A Probabilistic Model for Information Storage and Organization. Psychological Review.
- Hastie et al. (2009) - The Elements of Statistical Learning. Springer New York.
- Goodfellow, I., Bengio, Y., & Courville, A. (2016) - Deep Learning, MIT Press.
∞