Skip to main content

Creates tree data structures easily

Project description

Overview

SuperNodes is a Python package that creates tree data structures easily. It is designed to be similar to Python dictionaries but with more functions. The trees can be used:

  • For storing data
  • As decision trees
  • Both for storing data and as decision trees.

How to install

Run this command to install SuperNodes:

pip install supernodes

How to create a tree

To create a tree, first create the root node:

from supernodes import SuperNode

root_node = SuperNode(name="root")

You can add children nodes to the root node using different methods:

  • Using append function:
child_1 = SuperNode(name="child-1")
child_2 = SuperNode(name="child-2")
root_node.append(child_1)
root_node.append(child_2)
  • Using indexer:
root_node['child-1'] = SuperNode()
root_node['child-2'] = SuperNode()
  • Using split:
root_node.split(num=2, names=['child-1', 'child-2'])

You can view more methods for adding children nodes SuperNodes methods.

How to use as a decision tree

To create a tree that can be used as a decision tree, create the root node and add an inequality string or a function inside the function parameter:

root_node = SuperNode(name="root-node", function="x > 10")

Then create the children and add their names to the attributes, child_name_if_true and child_name_if_false.

root_node['first-child'] = SuperNode()
root_node['second-child'] = SuperNode()
root_node.child_name_if_true = "first-child"
root_node.child_name_if_false = "second-child"

Run the decision tree:

leaf = root_node.run_as_binary_tree(x=11)

Documentation

You can find the documentation in this link: SuperNodes docs.

More examples

You can find more examples this link: SuperNodes examples.

License and Copyrights

Copyrights (c) 2023 Mubarak Almehairbi. This package is licensed under the MIT license.

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

supernodes-1.0.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

supernodes-1.0.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file supernodes-1.0.1.tar.gz.

File metadata

  • Download URL: supernodes-1.0.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for supernodes-1.0.1.tar.gz
Algorithm Hash digest
SHA256 cc0522e10a4b14dfd5842cb66ef48e6a1f5e52c6ed748e0cb90128e07544fd37
MD5 19f552ce8bd29e797b6d5b94f6224d63
BLAKE2b-256 8b5d06cbc52890dbd29ee6b87e59c3f6ebaba8d361803ee25fcef72df0f6b8df

See more details on using hashes here.

File details

Details for the file supernodes-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: supernodes-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for supernodes-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 79ed7f33feb58f7c31040f06b9cedd4b52471a6460de3d40a153a499db6556f7
MD5 d80d82fd979131a1cf32c297c478709d
BLAKE2b-256 bf5615e7a3d8b35fd5fb8097533489b911723e92f4e95f8285a3652b913640aa

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