lux.pyuid3.uid3.UId3
- class lux.pyuid3.uid3.UId3(max_depth=None, node_size_limit=1, grow_confidence_threshold=0, min_impurity_decrease=0)
A decision tree classifier with customizable parameters for controlling tree growth.
Parameters:
- param max_depth:
int or None, default=None The maximum depth of the tree. If None, then nodes are expanded until all leaves are pure or until all leaves contain less than node_size_limit samples.
- param node_size_limit:
int, default=1 The minimum number of samples required to split a node further. If the number of samples at a node is less than node_size_limit, the node is not split, and it becomes a leaf.
- param grow_confidence_threshold:
float, default=0 The minimum confidence level required for a split to occur. Splits with a confidence level below this threshold are not performed. Confidence level is typically defined by impurity measures such as Gini impurity or entropy.
- param min_impurity_decrease:
float, default=0 The minimum decrease in impurity required for a split to occur. A split is only considered if it leads to at least this amount of impurity decrease. If a split does not meet this criterion, it is not performed.
Attributes:
- TREE_DEPTH_LIMIT: int or None
The maximum depth of the tree.
- NODE_SIZE_LIMIT: int
The minimum number of samples required to split a node further.
- GROW_CONFIDENCE_THRESHOLD: float
The minimum confidence level required for a split to occur.
- tree: object or None
The decision tree model constructed after fitting the data.
- node_size_limit: int
The minimum number of samples required to split a node further.
- min_impurity_decrease: float
The minimum decrease in impurity required for a split to occur.
- __init__(max_depth=None, node_size_limit=1, grow_confidence_threshold=0, min_impurity_decrease=0)
A decision tree classifier with customizable parameters for controlling tree growth.
Parameters:
- param max_depth:
int or None, default=None The maximum depth of the tree. If None, then nodes are expanded until all leaves are pure or until all leaves contain less than node_size_limit samples.
- param node_size_limit:
int, default=1 The minimum number of samples required to split a node further. If the number of samples at a node is less than node_size_limit, the node is not split, and it becomes a leaf.
- param grow_confidence_threshold:
float, default=0 The minimum confidence level required for a split to occur. Splits with a confidence level below this threshold are not performed. Confidence level is typically defined by impurity measures such as Gini impurity or entropy.
- param min_impurity_decrease:
float, default=0 The minimum decrease in impurity required for a split to occur. A split is only considered if it leads to at least this amount of impurity decrease. If a split does not meet this criterion, it is not performed.
Attributes:
- TREE_DEPTH_LIMIT: int or None
The maximum depth of the tree.
- NODE_SIZE_LIMIT: int
The minimum number of samples required to split a node further.
- GROW_CONFIDENCE_THRESHOLD: float
The minimum confidence level required for a split to occur.
- tree: object or None
The decision tree model constructed after fitting the data.
- node_size_limit: int
The minimum number of samples required to split a node further.
- min_impurity_decrease: float
The minimum decrease in impurity required for a split to occur.
Methods
__init__([max_depth, node_size_limit, ...])A decision tree classifier with customizable parameters for controlling tree growth.
calculate_gains_numeric(stat_for_lt_value, ...)calculate_split_criterion(values, data, ...)fit(data[, y, classifier, beta, ...])Fits pyUID3 tree, optionally using SHAP values calculated for the classifier.
Get metadata routing of this object.
get_oblique_gains(data, svc_features, ...)get_params([deep])Get parameters for this estimator.
predict(X)set_fit_request(*[, beta, classifier, data, ...])Configure whether metadata should be requested to be passed to the
fitmethod.set_params(**params)Set the parameters of this estimator.
try_attribute_for_split(data, attribute, cl, ...)Attributes
PARALLEL_ENTRY_FACTOR- fit(data, y=None, *, depth, entropyEvaluator, classifier=None, beta=1, discount_importance=False, prune=False, oblique=False, n_jobs=None)
Fits pyUID3 tree, optionally using SHAP values calculated for the classifier.
Parameters
- datapyuid3.Data
Data object containing dataset. It has to be object from pyuid3.Data
- ynp.array
Vector containing target values
- depthint, optional
This parameter should not be used. It is used internally by recurrent calls to govern the depth of the tree.
- entropyEvaluator: pyuid3.EntropyEvaluator
Object responisble for calculating split criterion. Default is UncertainEntropyEvaluator. Although the naming might be confusing, other possibilities are: UncertainGiniEvaluator, UncertainSqrtGiniEvaluator
- classifier: optional
A classifier that is designed according to sckit paradigm. It is required from the classifier to have predict_proba function. Default is None
- beta: int
Parameter being a weight in harmonic mean between score obtained from EntropyEvaluator and SHAP values. The greater the value the more important are SHAP values when selecting a split. Default is 1.
- discount_importance: boolean,
Parameter indicating if the SHAP importances should be calculated resively at every split, or if the importances calculated for the whole data should be used. In the latter case, the importances are discounted by the percentage of reduction in split criterion (e.g. Information Gain). Default it False.
- prune: boolean, optional
Define if after training the tree should be pruned. The prounning is done by looking at the change in prediction on a training set. If removing a branch does not change the prediction outcome, the branch is pruned. It will provide more general trees, i.e.rules extracted from branches will have more coverage, but their precission may drop.
- oblique: boolean, optional
Define if the tree should assume building linear slipts, instead of simple inequality-based spolits. Deafult False.
- n_jobs: int, optional
Number of processess to use when building a tree. Default is None
Returns
- pyuid3.Tree
a fitted decision tree
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Returns
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_params(deep=True)
Get parameters for this estimator.
Parameters
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns
- paramsdict
Parameter names mapped to their values.
- set_fit_request(*, beta: bool | None | str = '$UNCHANGED$', classifier: bool | None | str = '$UNCHANGED$', data: bool | None | str = '$UNCHANGED$', depth: bool | None | str = '$UNCHANGED$', discount_importance: bool | None | str = '$UNCHANGED$', entropyEvaluator: bool | None | str = '$UNCHANGED$', n_jobs: bool | None | str = '$UNCHANGED$', oblique: bool | None | str = '$UNCHANGED$', prune: bool | None | str = '$UNCHANGED$') UId3
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Parameters
- betastr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
betaparameter infit.- classifierstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
classifierparameter infit.- datastr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
dataparameter infit.- depthstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
depthparameter infit.- discount_importancestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
discount_importanceparameter infit.- entropyEvaluatorstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
entropyEvaluatorparameter infit.- n_jobsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
n_jobsparameter infit.- obliquestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
obliqueparameter infit.- prunestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
pruneparameter infit.
Returns
- selfobject
The updated object.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.Parameters
- **paramsdict
Estimator parameters.
Returns
- selfestimator instance
Estimator instance.