QDpy
Loading...
Searching...
No Matches
qdpy.algorithms.tree_policy.DecisionTreePolicy Class Reference

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.

Detailed Description

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.

Member Function Documentation

◆ act()

qdpy.algorithms.tree_policy.DecisionTreePolicy.act ( self,
observation )

Return the greedy environment action for one observation.

Parameters
observationFinite 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.

◆ depth()

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.

◆ load()

qdpy.algorithms.tree_policy.DecisionTreePolicy.load ( cls,
path )

Reconstruct a fitted policy from a versioned JSON file.

Parameters
pathFilesystem path to a saved policy.
Read and validate a policy independently of the search instance.

Definition at line 94 of file tree_policy.py.

◆ save()

qdpy.algorithms.tree_policy.DecisionTreePolicy.save ( self,
path )

Export the fitted policy as versioned JSON.

Parameters
pathFilesystem destination.
Write only the tree, action layout, and observation shape.

Definition at line 84 of file tree_policy.py.


The documentation for this class was generated from the following file: