Skip to main content

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.
  • Matplotlib library is required.
  • Json (built-in) library is required.

Install NumPy python library by using the below.

pip install numpy
pip install pandas
pip install matplotlib

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 NeuralNetworkMLP as nn
import numpy as np

# Load or create the datasets
xTrain = np.array([[0, 1],
                   [1, 0],
                   [1, 1],
                   [0, 0]])

yTrain = np.array([[1], [1], [0], [0]])

xTest = 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.
neuralNetwork = nn.NeuralNetwork(
    inputLayerNeurons=2,
    hiddenLayersNeurons=[10],
    outputLayerNeurons=1,
    activationFunctions=[nn.RELU, nn.SIGMOID]
)

# Train the model on your training data
neuralNetwork.train(xTrain, yTrain)

# Predict on new data
predictions = neuralNetwork.predict(xTest)

# Save the model
neuralNetwork.saveModel("NeuralNetworkModel.json")

# Load the model
neuralNetwork.loadModel("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

neuralnetworkmlp-1.1.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

NeuralNetworkMLP-1.1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file neuralnetworkmlp-1.1.1.tar.gz.

File metadata

  • Download URL: neuralnetworkmlp-1.1.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for neuralnetworkmlp-1.1.1.tar.gz
Algorithm Hash digest
SHA256 6d394702047f629f7618f3c87755c5bd735306dbcfee205f1c6f1624b6bff523
MD5 2e160c0963b1c0f1f9c5ded8977038cd
BLAKE2b-256 10010b840666fac14243980889f95ebba0f594df182d8f9582b3ed1112cc43c2

See more details on using hashes here.

File details

Details for the file NeuralNetworkMLP-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for NeuralNetworkMLP-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ae842e8b76a63ecdc3983888ab02cce3c386048c8027afadd1034113cdf3d9e
MD5 feb4d5859564049aaf6bb62cd0f56605
BLAKE2b-256 d22001edd745449d36b3b402a14217cb77925fcdef148cfeaa7397e03d95ea3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page