https://github.com/gbroques/perceptron
Perceptron learning algorithm implemented in Python.
https://github.com/gbroques/perceptron
machine-learning perceptron perceptron-learning-algorithm python3
Last synced: 3 months ago
JSON representation
Perceptron learning algorithm implemented in Python.
- Host: GitHub
- URL: https://github.com/gbroques/perceptron
- Owner: gbroques
- License: mit
- Created: 2018-04-23T14:22:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T02:14:40.000Z (almost 3 years ago)
- Last Synced: 2025-01-12T09:42:37.322Z (10 months ago)
- Topics: machine-learning, perceptron, perceptron-learning-algorithm, python3
- Language: Python
- Size: 130 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Perceptron
[](https://travis-ci.org/gbroques/perceptron)
[](https://coveralls.io/github/gbroques/perceptron?branch=master)
Perceptron learning algorithm implemented in Python.

## Getting Started
This project depends upon the popular numerical processing library [NumPy](http://www.numpy.org/) for lightning-fast vector arithmetic, and other packages for unit testing.
### Prerequisites
To install NumPy, it's recommended you use Python's offical package manager **pip**.
To ensure pip is installed on your machine, run the command:
```
$ pip --version
```
pip should come installed with Python depending upon your version.
For more details, see [installation](https://pip.pypa.io/en/stable/installing/)
on pip's documentation.
### Installing
It's recommended you use `virtualenv` to create isolated Python environments.
You can find details on [virtualenv's documentation](https://virtualenv.pypa.io/en/stable/).
Once pip is installed, run:
```
$ pip install -r requirements.txt
```
This will install this project's dependencies on your machine.
## How to Run
```
$ python main.py
```
## Usage
API inspired by the popular machine learning library
[scikit-learn](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Perceptron.html).
```python
import numpy as np
from perceptron import Perceptron
# Training data for logical OR function
training_data = np.array([
[0, 0, 0],
[0, 1, 1],
[1, 0, 1],
[1, 1, 1]
])
design_matrix = training_data[:, :2]
target_values = training_data[:, -1]
perceptron = Perceptron(max_iter=100, learning_rate=0.2)
perceptron.fit(design_matrix, target_values)
predictions = perceptron.predict(design_matrix)
print(predictions) # [0, 1, 1, 1]
```