Neural Network lib for ncxlib
Project description
NCxLib: A Lightweight Neural Network Library in Python
ncxlib is a lightweight and easy-to-use neural network library built in Python. It provides a simple API for constructing and training neural networks, along with tools for data preprocessing and generation.
Features
- Modular Design: Easily build custom neural networks by combining different layers, activation functions, and loss functions.
- Data Handling: Includes data loaders for CSV and image data, with preprocessing capabilities like scaling and grayscaling.
- Training and Evaluation: Train your networks with various optimization algorithms and evaluate their performance.
- Extensible: Add your own custom layers, activations, and loss functions to expand the library's functionality.
Installation
pip install ncxlib
Getting Started
Here's a quick example of how to use ncxlib to create and train a simple neural network:
import numpy as np
from ncxlib.dataloaders import CSVDataLoader
from ncxlib.preprocessing import MinMaxScaler
from ncxlib.neuralnetwork import NeuralNetwork
from ncxlib.neuralnetwork.layers import FullyConnectedLayer
from ncxlib.neuralnetwork.activations import Sigmoid, ReLU
from ncxlib.neuralnetwork.losses import BinaryCrossEntropy
from ncxlib.generators import generate_training_data, train_test_split
# Generate synthetic data
generate_training_data(
num_samples=100,
num_features=3,
to_csv=True,
)
# Load data with preprocessing
loader = CSVDataLoader("training_data.csv", preprocessors=[MinMaxScaler()])
X, y = loader.get_data()
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
# Define the neural network architecture
network = NeuralNetwork(
[
FullyConnectedLayer(n_neurons=4, activation=ReLU(), name="first_hidden"),
FullyConnectedLayer(n_neurons=6, activation=ReLU(), name="second_hidden"),
FullyConnectedLayer(n_neurons=2 , activation=Sigmoid(), name="output"),
],
loss_fn=BinaryCrossEntropy()
)
# Train the network
network.train(X_train, y_train, epochs=100, learning_rate=0.01)
# Evaluate the network
network.evaluate(X_test, y_test)
License
This project is licensed under the MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ncxlib-0.2.1.tar.gz
(15.2 kB
view details)
Built Distribution
ncxlib-0.2.1-py3-none-any.whl
(27.0 kB
view details)
File details
Details for the file ncxlib-0.2.1.tar.gz
.
File metadata
- Download URL: ncxlib-0.2.1.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52310203ffd1a74e08c9ee112d2eb9695aafbb2cd104210755f1f470871eb1d4 |
|
MD5 | 44f826be5fd0458e292d088d608ce42f |
|
BLAKE2b-256 | 6dc58ce53ea260a60fed8cf6110fee62cfc99cc994973e9b71a5faa52f5e8c9d |
File details
Details for the file ncxlib-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: ncxlib-0.2.1-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d8d6671afdacdbca934432e047b4b13cc0487f240e081c90e93f4d6858ab547 |
|
MD5 | 884ccacefd6f82da0124e30e38fb2890 |
|
BLAKE2b-256 | 3a57bc416400f154788f9083536475b2ba7ceb2be3f929b54d94432a9b7fbf87 |