verticapy.machine_learning.memmodel.ensemble.RandomForestRegressor.predict#
- RandomForestRegressor.predict(X: list | ndarray) ndarray #
Predicts using the Random Forest regressor model.
Parameters#
- X: ArrayLike
The data on which to make the prediction.
Returns#
- numpy.array
Predicted values.
Examples#
Import the required modules and create many
BinaryTreeRegressor
.from verticapy.machine_learning.memmodel.tree import BinaryTreeRegressor model1 = BinaryTreeRegressor( 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, 3.0, 11.0, 23.5], ) model2 = BinaryTreeRegressor( 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, -3, 12, 56], ) model3 = BinaryTreeRegressor( 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, 1, 3, 6], )
Let’s create a model.
from verticapy.machine_learning.memmodel.ensemble import RandomForestRegressor model_rfr = RandomForestRegressor(trees = [model1, model2, model3])
Create a dataset.
data = [["male", 100], ["female", 20], ["female", 50]]
Compute the predictions.
model_rfr.predict(data) Out[8]: array([ 0.33333333, 8.66666667, 28.5 ])
Note
Refer to
RandomForestRegressor
for more information about the different methods and usages.