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
appendfunction:
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file supernodes-1.0.0.tar.gz.
File metadata
- Download URL: supernodes-1.0.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b3422e42622dbad29ce52eaf3b32f2eb50424200fefd65e0e97977dc1fbc1af
|
|
| MD5 |
fb6b4679f1ff3b7ab1885b14374d6c5c
|
|
| BLAKE2b-256 |
f6f839e8c312d4e3fe71277cdc871fcf3b77111599f02f9e15ac4e3984c280ec
|
File details
Details for the file supernodes-1.0.0-py3-none-any.whl.
File metadata
- Download URL: supernodes-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f5494a4582bc49a0fdd15e4f3d49fa619ca236a0f6f3b7255138f42d3554b52
|
|
| MD5 |
8a4757990dd255114a6ee6d4ae400bb1
|
|
| BLAKE2b-256 |
b039e9a6039835c70409c5b42772f9c3c7da212300d5eabff4297c96fdbaeb97
|