Skip to main content

A simple experimental ML model

Project description

TreeNet

TreeNet is a lightweight and customizable machine learning model designed for flexible experimentation with layered network structures. It provides simple training and prediction interfaces and is well-suited for rapid prototyping and educational purposes.

Installation

You can install the package directly from PyPI:

pip install treenet

Or install it from the source:

git clone https://github.com/zeshanalvi/treenet.git
cd treenet
pip install .

Usage

Here’s a quick example of how to use TreeNet:

import numpy as np
from treenet import TreeNet

# Initialize the model
model = TreeNet(layer_count=3, breath_count=2)

# Sample training data
trainX = np.random.rand(100, 8)   # 100 samples, 8 features
trainY = np.random.randint(0, 2, size=(100, 1))  # Binary labels

# Train the model
model.train(trainX, trainY)

# Sample test data
testX = np.random.rand(10, 8)

# Predict probabilities
probabilities = model.predict_prob(testX)
print("Probabilities:\n", probabilities)

# Predict labels
predictions = model.predict(testX)
print("Predictions:\n", predictions)

API Reference

TreeNet

__init__(self, layer_count=2, breath_count=1)

Initializes a new TreeNet model.

layer_count (int): Number of layers in the network (default: 2).

breath_count (int): Number of parallel branches per layer (default: 1).

train(self, trainX, trainY)

Trains the model on given data.

trainX (np.ndarray): Training features of shape (n_samples, n_features).

trainY (np.ndarray): Training labels of shape (n_samples, 1).

predict_prob(self, testX) -> np.ndarray

Returns the probability distribution over classes for input samples.

testX (np.ndarray): Test features of shape (n_samples, n_features).

Returns: np.ndarray of shape (n_samples, n_classes).

predict(self, testX) -> np.ndarray

Returns predicted class labels for input samples.

testX (np.ndarray): Test features of shape (n_samples, n_features).

Returns: np.ndarray of shape (n_samples, 1).

Project Structure

treenet/
│
├── treenet/
│   ├── __init__.py
│   ├── model.py         # Implementation of TreeNet class
│
├── tests/
│   ├── test_model.py    # Unit tests for TreeNet
│
├── README.md
├── setup.py
├── pyproject.toml
├── LICENSE

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

TreeNet was built to simplify experimentation with layered machine learning structures and provide a lightweight package for educational and prototyping use.

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

dtreenetwork-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

dtreenetwork-0.1.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file dtreenetwork-0.1.0.tar.gz.

File metadata

  • Download URL: dtreenetwork-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dtreenetwork-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66c9bb7c7552555c994828febcaa5c8f30379b9609bd6904b8935d71ac60e51b
MD5 0e4de0379c1afb18c00c9d643258582b
BLAKE2b-256 04d64a48c088f1d795c142d67acf7b0ab4558533eed1492f468532da92f53c1f

See more details on using hashes here.

File details

Details for the file dtreenetwork-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dtreenetwork-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dtreenetwork-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 670780314ea385d459e6ef014605255c12f7e1ec677a4c7956aaac377f9ea86f
MD5 4280f6d4c236f47a646371571db1868e
BLAKE2b-256 396975429312f3e08ed53896b1c1cab15859cac777d002a8b15382f18106817f

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