.. index:: single: c45_classifier .. _c45_classifier/0: .. rst-class:: right **object** ``c45_classifier`` ================== C4.5 decision tree learning algorithm. Builds a decision tree from a dataset object implementing the ``dataset_protocol`` protocol and provides predicates for exporting the learned tree as a list of predicate clauses or to a file. Supports both discrete and continuous attributes, handles missing values, and supports tree pruning. | **Availability:** | ``logtalk_load(c45_classifier(loader))`` | **Author:** Paulo Moura | **Version:** 3:0:0 | **Date:** 2026-10-13 | **Compilation flags:** | ``static, context_switching_calls`` | **Imports:** | ``public`` :ref:`classifier_common ` | **Uses:** | :ref:`format ` | :ref:`list ` | :ref:`numberlist ` | :ref:`pairs ` | :ref:`type ` | **Remarks:** | (none) | **Inherited public predicates:** |  :ref:`classifier_protocol/0::check_classifier/1`  :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`classifier_protocol/0::classifier_options/2`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`classifier_protocol/0::diagnostic/2`  :ref:`classifier_protocol/0::diagnostics/2`  :ref:`classifier_protocol/0::export_to_clauses/4`  :ref:`classifier_protocol/0::export_to_file/4`  :ref:`classifier_protocol/0::learn/2`  :ref:`classifier_protocol/0::learn/3`  :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:`classifier_protocol/0::valid_classifier/1`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`   .. contents:: :local: :backlinks: top Public predicates ----------------- .. index:: prune/5 .. _c45_classifier/0::prune/5: ``prune/5`` ^^^^^^^^^^^ Prunes a decision tree using pessimistic error pruning (PEP). This post-pruning method estimates error rates using the upper confidence bound of the binomial distribution with the given confidence factor and replaces subtrees with leaf nodes when doing so would not increase the estimated error. Pruning helps reduce overfitting and can improve generalization to unseen data. | **Compilation flags:** | ``static`` | **Template:** | ``prune(Dataset,Tree,ConfidenceFactor,MinInstances,PrunedTree)`` | **Mode and number of proofs:** | ``prune(+object_identifier,+classifier,+float,+positive_integer,-classifier)`` - ``one`` | **Exceptions:** | An input parameter or tree is a variable: | ``instantiation_error`` | Confidence factor is not a float in (0.0, 0.5]: | ``domain_error(confidence_factor,ConfidenceFactor)`` | Minimum instances is not a positive integer: | ``domain_error(positive_integer,MinInstances)`` | Tree is invalid: | ``domain_error(classifier,Tree)`` | Dataset is empty: | ``domain_error(non_empty_dataset,Dataset)`` | Dataset class values are invalid: | ``domain_error(class_values,ClassValues)`` | Dataset attribute declarations are invalid: | ``domain_error(attribute_declarations,Attribute)`` | A required attribute binding is missing: | ``existence_error(attribute,Attribute)`` | **Remarks:** - Confidence factor: The confidence factor must be a float in ``(0.0, 0.5]`` so that the error estimate is an upper confidence bound. Lower values increase the estimated uncertainty. The default value is ``0.25``. - Minimum node population: A non-empty node with weighted population below this positive integer is replaced by its majority leaf. This does not require every leaf to meet the minimum. The default value is ``2``. - Statistical basis: The pruning uses the upper confidence bound of the binomial distribution to estimate the true error rate. ------------ .. index:: prune/3 .. _c45_classifier/0::prune/3: ``prune/3`` ^^^^^^^^^^^ Prunes a decision tree using pessimistic error pruning (PEP) with default parameter values. Calls ``prune/5`` with ``ConfidenceFactor = 0.25`` and ``MinInstances = 2``. | **Compilation flags:** | ``static`` | **Template:** | ``prune(Dataset,Tree,PrunedTree)`` | **Mode and number of proofs:** | ``prune(+object_identifier,+classifier,-classifier)`` - ``one`` | **Exceptions:** | Tree is a variable: | ``instantiation_error`` | Tree is invalid: | ``domain_error(classifier,Tree)`` | Dataset is empty: | ``domain_error(non_empty_dataset,Dataset)`` | Dataset class values are invalid: | ``domain_error(class_values,ClassValues)`` | Dataset attribute declarations are invalid: | ``domain_error(attribute_declarations,Attribute)`` | A required attribute binding is missing: | ``existence_error(attribute,Attribute)`` | **Remarks:** - Default parameters: Uses a confidence factor of ``0.25`` and minimum weighted node population of ``2``. Existing leaves and empty branches are preserved. ------------ 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:`isolation_forest_anomaly_detector `, :ref:`knn_classifier `, :ref:`naive_bayes_classifier `, :ref:`nearest_centroid_classifier `, :ref:`random_forest_classifier `, :ref:`adaptive_boosting_classifier `