Metadata-Version: 2.4
Name: multilayer-perceptron-from-scratch
Version: 0.1.0
Summary: A clean and educational implementation of a Multilayer Perceptron from scratch using NumPy
Author-email: Nehorai Yosef <neopydev5454@gmail.com>
License: MIT
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Requires-Dist: numpy>=1.20.0
Description-Content-Type: text/markdown

# Multilayer Perceptron (MLP) from Scratch 🧠

A lightweight, educational, and high-performance implementation of a **Multilayer Perceptron** neural network, built entirely from scratch using **NumPy**.

This project implements the fundamental mathematics of deep learning—including **Backpropagation** and **Stochastic Gradient Descent (SGD)** with data shuffling—without the overhead of heavy frameworks like PyTorch or TensorFlow.

---

### ✨ Key Features

* **🎯 Pure NumPy:** Zero dependencies for the core engine (only `numpy`).

* **🔄 Stochastic Gradient Descent (SGD):** Includes automatic data shuffling every epoch for better convergence.

* **🏗️ Flexible Architecture:** Custom-define any number of hidden layers and neurons.

* **📉 Matrix-Based Backpropagation:** Efficient implementation using the four fundamental equations of backpropagation.

* **🎓 Educational Design:** Clean, commented code ideal for learning how neural networks actually work "under the hood."

---

### 📦 Installation

You can install the package directly from PyPI:

```bash
pip install multilayer-perceptron
```

---

### 🚀 Quick Start (XOR Example)

The following example demonstrates how to solve the classic XOR problem using the `Network` class.

```python
import numpy as np
from multilayer_perceptron import Network

# 1. Define Architecture: [Input (2), Hidden (20), Output (1)]
net = Network([2, 20, 1])

# 2. Prepare Training Data (XOR)
# Format: List of tuples (input_vector, target_vector)
training_data = [
    (np.array([[0], [0]]), np.array([[0]])),
    (np.array([[0], [1]]), np.array([[1]])),
    (np.array([[1], [0]]), np.array([[1]])),
    (np.array([[1], [1]]), np.array([[0]]))
]

# 3. Train using SGD
# Parameters: data, epochs, learning_rate
print("Starting Training...")
net.SGD(training_data, epochs=3000, learning_rate=0.2)

# 4. Test the model
print("\nResults:")
for x, y in training_data:
    output, _, _ = net.feedforward(x)
    prediction = 1 if output >= 0.5 else 0
    print(f"Input: {x.flatten()} | Target: {int(y[0][0])} | Predicted: {prediction}")
```

---

### 📜 License

Distributed under the **MIT License**. See `LICENSE` for more information.

---

**Created with ❤️ by Nehorai Yosef**