A class that implements an MLP neural network
Project description
MLP Neural Network
MLP Neural Network is a lightweight Python library for building and training Multi-Layer Perceptron (MLP) models. This repository provides a simple yet powerful framework for experimenting with neural networks, along with an example program and dataset to help you get started quickly.
Features
- Simple API: Quickly build and train neural network models with a few lines of code.
- Customizable Architecture: Easily configure the number of layers, neurons per layer, activation functions, learning rates, epochs, batch size and threshold.
- Example Program: The included "test.py" script demonstrates how to integrate and use the library in a real-world scenario.
- Sample Dataset: Comes with an iris.csv file containing the famous Iris dataset, ideal for testing and learning.
Getting Started
Requirements
- Python 3.x is required.
- NumPy library is required.
- Pandas library is required.
- Json (built-in) library is required.
Install NumPy python library by using the below.
pip install numpy
pip install pandas
Installation
Clone the repository to your local machine:
git clone https://github.com/ThePhantom2307/MLP-Neural-Network.git
cd MLP-Neural-Network
Or you can use the built-in function pip
pip install NeuralNetworkMLP
Running the Example
The repository includes an example script (test.py) that shows how to use the library. The script loads the provided iris.csv dataset, builds an MLP model, trains it, and evaluates its performance. To run the example, simply execute:
python test.py
Usage
You can incorporate the MLP Neural Network library into your own projects. Below is a short example to illustrate how to use the library:
# Import the neural network class
import NeuralNetworkMLP as nn
import numpy as np
# Load or create the datasets
X_train = np.array([[0, 1],
[1, 0],
[1, 1],
[0, 0]])
y_train = np.array([[1], [1], [0], [0]])
X_test = np.array([[1, 0]])
# Define your network architecture: for example, input layer of size 2, one hidden layer with 10 neurons, and output layer of size 1.
neural_network = nn.NeuralNetwork(
input_layer_neurons=2,
hidden_layers_neurons=[10],
output_layer_neurons=1,
activation_functions=[nn.RELU, nn.SIGMOID]
)
# Train the model on your training data (X_train and y_train should be defined appropriately)
neural_network.train(X_train, y_train)
# Predict on new data
predictions = neural_network.predict(X_test)
# Save the model
neural_network.save_model("NeuralNetworkModel.json")
# Load the model
neural_network.load_model("NeuralNetworkModel.json")
For more detailed usage, refer to the test.py file, which provides a complete example.
Contributing
Contributions, suggestions, and bug reports are welcome! If you’d like to contribute, please fork the repository and create a pull request. Alternatively, feel free to open an issue to discuss improvements.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neuralnetworkmlp-1.0.4.tar.gz.
File metadata
- Download URL: neuralnetworkmlp-1.0.4.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b2383269ad3f2bb1856b90ae95fa84edc05c9fe868252d4c159cd6e0223c838
|
|
| MD5 |
fd11aefbd9dedb67322b1709ed13194d
|
|
| BLAKE2b-256 |
d27c2b4f7dd12d1d878eb0cb76b82268645d21cf70f5ecdaa738d280bbc85b77
|
File details
Details for the file NeuralNetworkMLP-1.0.4-py3-none-any.whl.
File metadata
- Download URL: NeuralNetworkMLP-1.0.4-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e8842cc409e3942a49ef3263aa619e220c38f541b5ea214e7aa40c4a7f58ada
|
|
| MD5 |
50c9d90619a4d4c80990d5add4703bc7
|
|
| BLAKE2b-256 |
deb366b135ef0e0f31b4bc8fbecb5dfa52b7715f61376f2aed0eb2b7775fbd77
|