|
QDpy
|
A deterministic decision tree with portable JSON inference. More...
Public Member Functions | |
| depth (self) | |
| act (self, observation) | |
| Return the greedy environment action for one observation. | |
| save (self, path) | |
| Export the fitted policy as versioned JSON. | |
| load (cls, path) | |
| Reconstruct a fitted policy from a versioned JSON file. | |
A deterministic decision tree with portable JSON inference.
Evaluate an axis-aligned tree without training state or an environment. A node is either a zero-based action index or a list of four values containing a flat feature index, threshold, and the two child nodes. The left branch includes observations equal to the threshold. The action offset preserves Gymnasium Discrete spaces with nonzero starts. :param tree: Nested axis-aligned splits and greedy leaf action indices. :param observation_shape: Shape of the original numeric Box space. :param action_count: Number of possible categorical actions. :param action_start: First action in the original Discrete space.
Definition at line 46 of file tree_policy.py.
| qdpy.algorithms.tree_policy.DecisionTreePolicy.act | ( | self, | |
| observation ) |
Return the greedy environment action for one observation.
| observation | Finite observation with the shape saved in the policy. |
Follow the tree and add the environment's action offset.
Definition at line 75 of file tree_policy.py.
| qdpy.algorithms.tree_policy.DecisionTreePolicy.depth | ( | self | ) |
Return the maximum number of splits encountered along a route.
Definition at line 69 of file tree_policy.py.
| qdpy.algorithms.tree_policy.DecisionTreePolicy.load | ( | cls, | |
| path ) |
Reconstruct a fitted policy from a versioned JSON file.
| path | Filesystem path to a saved policy. |
Read and validate a policy independently of the search instance.
Definition at line 94 of file tree_policy.py.
| qdpy.algorithms.tree_policy.DecisionTreePolicy.save | ( | self, | |
| path ) |
Export the fitted policy as versioned JSON.
| path | Filesystem destination. |
Write only the tree, action layout, and observation shape.
Definition at line 84 of file tree_policy.py.