.. index:: single: random_forest .. _random_forest/0: .. rst-class:: right **object** ``random_forest`` ================= Random Forest classifier using C4.5 decision trees as base learners. Builds an ensemble of decision trees trained on bootstrap samples with random feature subsets and combines their predictions through majority voting. | **Availability:** | ``logtalk_load(random_forest(loader))`` | **Author:** Paulo Moura | **Version:** 1:0:0 | **Date:** 2026-02-20 | **Compilation flags:** | ``static, context_switching_calls`` | **Implements:** | ``public`` :ref:`classifier_protocol ` | **Imports:** | ``public`` :ref:`options ` | **Uses:** | :ref:`c45 ` | :ref:`fast_random ` | :ref:`format ` | :ref:`list ` | :ref:`pairs ` | :ref:`type ` | **Remarks:** - Algorithm: Random Forest is an ensemble learning method that constructs multiple decision trees during training and outputs the class that is the mode of the classes predicted by individual trees. - Bootstrap sampling: Each tree is trained on a bootstrap sample (random sample with replacement) of the training data. - Feature randomization: At each tree, a random subset of features is selected. The default number of features is sqrt(total_features). - Classifier representation: The learned classifier is represented by default as a ``rf_classifier(Trees, ClassValues, Options)`` term. | **Inherited public predicates:** |  :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`classifier_protocol/0::classifier_to_clauses/4`  :ref:`classifier_protocol/0::classifier_to_file/4`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`classifier_protocol/0::learn/2`  :ref:`options_protocol/0::option/2`  :ref:`options_protocol/0::option/3`  :ref:`classifier_protocol/0::predict/3`  :ref:`classifier_protocol/0::print_classifier/1`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`   .. contents:: :local: :backlinks: top Public predicates ----------------- .. index:: learn/3 .. _random_forest/0::learn/3: ``learn/3`` ^^^^^^^^^^^ Learns a classifier from the given dataset object using the specified options. | **Compilation flags:** | ``static`` | **Template:** | ``learn(Dataset,Classifier,Options)`` | **Mode and number of proofs:** | ``learn(+object_identifier,-compound,+list(compound))`` - ``one`` ------------ .. index:: predict_probabilities/3 .. _random_forest/0::predict_probabilities/3: ``predict_probabilities/3`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Predicts class probabilities for a new instance using the learned classifier. Returns a list of ``Class-Probability`` pairs sorted by descending probability. The instance is a list of ``Attribute-Value`` pairs. | **Compilation flags:** | ``static`` | **Template:** | ``predict_probabilities(Classifier,Instance,Probabilities)`` | **Mode and number of proofs:** | ``predict_probabilities(+compound,+list,-list)`` - ``one`` ------------ Protected predicates -------------------- (no local declarations; see entity ancestors if any) Private predicates ------------------ (no local declarations; see entity ancestors if any) Operators --------- (none) .. seealso:: :ref:`dataset_protocol `, :ref:`c45 `, :ref:`isolation_forest `, :ref:`knn `, :ref:`naive_bayes `, :ref:`nearest_centroid `, :ref:`ada_boost `