verticapy.machine_learning.memmodel.ensemble.RandomForestClassifier.predict_proba#
- RandomForestClassifier.predict_proba(X: list | ndarray) ndarray #
Computes the model’s probabilites using the input matrix.
Parameters#
- X: list | numpy.array
The data on which to make the prediction.
Returns#
- numpy.array
Probabilities.
Examples#
Import the required modules and create many
BinaryTreeClassifier
.from verticapy.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 verticapy.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) Out[8]: array([[1. , 0. , 0. ], [0. , 0.66666667, 0.33333333], [0. , 0.33333333, 0.66666667]])
Note
Refer to
RandomForestClassifier
for more information about the different methods and usages.