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
col_labels = [''.join(random.choices(string.ascii_uppercase, k=10)) for _ in range(20)] # labels of 20 columns
trainXnp = np.random.rand(100, 20)   # 100 samples, 20 features
trainX = pd.DataFrame(trainXnp, columns=col_labels) # Dataframe
trainY = np.random.randint(0, 8, size=(100,)) # Multiclass labels with 8 classes

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

# Sample test data
testXnp = np.random.rand(10, 8)
trainX = pd.DataFrame(trainXnp, columns=col_labels) # Dataframe

# 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.1.tar.gz (16.1 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.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dtreenetwork-0.1.1.tar.gz
  • Upload date:
  • Size: 16.1 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.1.tar.gz
Algorithm Hash digest
SHA256 af56257a190ea5fac9be263b6af14221898218fd2c12b5fa4117f097883aeae1
MD5 3b75600c2df2b776fed4249a394750e4
BLAKE2b-256 b8b67493457f91d5737227a095179f08fbbed3d5d667c7f080cc8dd48705cbaf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dtreenetwork-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b76c0ded9ecb6eb009c39adc06f75e8b9eaf8ea3460b5b316b5ac18257b14b2
MD5 cb422214114a5a2eb20b4a392fc2c5f2
BLAKE2b-256 dc3986e5a9ad1f74433125c3935c35ff7770c61febb507d5175637964859dbea

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