Loading...

vastorbit.machine_learning.memmodel.ensemble.RandomForestClassifier.predict_proba

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

Computes the model’s probabilites using the input matrix.

Parameters:

X (list | numpy.array) – The data on which to make the prediction.

Returns:

Probabilities.

Return type:

numpy.array

Examples

Import the required modules and create many BinaryTreeClassifier.

from vastorbit.machine_learning.memmodel.tree import BinaryTreeClassifier

model1 = BinaryTreeClassifier(
    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"],
)
model2 = BinaryTreeClassifier(
    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.7, 0.2, 0.1], [0.3, 0.5, 0.2], [0.2, 0.2, 0.6]],
    classes = ["a", "b", "c"],
)
model3 = BinaryTreeClassifier(
    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.4, 0.4, 0.2], [0.2, 0.2, 0.6], [0.2, 0.5, 0.3]],
    classes = ["a", "b", "c"],
)

Let’s create a model.

from vastorbit.machine_learning.memmodel.ensemble import RandomForestClassifier

model_rfc = RandomForestClassifier(
    trees = [model1, model2, model3],
    classes = ["a", "b", "c"],
)

Create a dataset.

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

Compute the predictions.

model_rfc.predict_proba(data)

Note

Refer to RandomForestClassifier for more information about the different methods and usages.