Loading...

vastorbit.machine_learning.memmodel.tree.Tree.predict

Tree.predict(X: Annotated[list | ndarray, 'Array Like Structure']) ndarray

Predicts using the BinaryTree model.

Parameters:

X (ArrayLike) – The data on which to make the prediction.

Returns:

Predicted values.

Return type:

numpy.array

Examples

Import the required module.

from vastorbit.machine_learning.memmodel.tree import BinaryTreeClassifier

We will use the following attributes:

# Different Attributes
children_left = [1, 3, None, None, None]
children_right = [2, 4, None, None, None]
feature = [0, 1, None, None, None]
threshold = ["female", 30, None, None, None]
value = [
    None,
    None,
    [0.8, 0.1, 0.1],
    [0.1, 0.8, 0.1],
    [0.2, 0.2, 0.6],
]
classes = ["a", "b", "c"]

Let’s create a model.

# Building the Model
model_btc = BinaryTreeClassifier(
    children_left = children_left,
    children_right = children_right,
    feature = feature,
    threshold = threshold,
    value = value,
    classes = classes,
)

Create a dataset.

data = [["male", 100], ["female", 20], ["female", 50]]

Compute the predictions.

model_btc.predict(data)

Important

For this example, a specific model is utilized, and it may not correspond exactly to the model you are working with. To see a comprehensive example specific to your class of interest, please refer to that particular class.