FERL API Reference#
Estimator#
- class ex_fuzzy.FERL(fuzzy_partitions=None, max_rules=15, max_depth=5, coverage_threshold=0.0, min_improvement=0.01, ccp_alpha=0.0, target_metric='cci', sample_for_splits=None, sample_size=10000, reliability_k=None, partition='quantile', n_partitions=3, overlap_frac=0.8, split_mode='fixed', learned_width='bootstrap', learned_n_boot=25, prediction_mode='soft', consistent_cci=True, coverage_weight=0.0, multiway_splits=False, random_state=None, backend='python')[source]#
Bases:
BaseEstimator,ClassifierMixinFast Evidential Rule Learning classifier.
FERL greedily grows a fuzzy rule tree and aggregates activated rules for ordinary probabilities or Dempster–Shafer evidential predictions. It can use a compact, human-readable fixed partition or learn soft split locations and widths from the data for a deeper model.
- Parameters:
fuzzy_partitions (list[fs.fuzzyVariable], optional) – One fuzzy variable per feature. When omitted, FERL constructs the partitions during
fit().max_rules (int, default=15) – Maximum number of rules (leaf nodes) allowed in the tree. Controls tree complexity and helps prevent overfitting.
max_depth (int, default=5) – Maximum depth of the tree. Limits how deep the tree can grow.
coverage_threshold (float, default=0.00) – Minimum coverage ratio required for a split to be considered valid. Splits covering fewer samples than this threshold are rejected.
min_improvement (float, default=0.01) – Minimum split-quality improvement. FERL stops after
patienceconsecutive candidates do not exceed it.ccp_alpha (float, default=0.0) – Cost-complexity parameter used by the explicit pruning methods.
target_metric ({"cci", "purity"}, default="cci") – Greedy split criterion. CCI aligns compact-tree growth with the classifier decision; purity uses weighted Gini impurity.
sample_for_splits (bool, optional) – Whether to evaluate split candidates on a sample of the training data.
Noneenables sampling automatically above 50,000 rows.sample_size (int, default=10000) – Maximum rows used by sampled split evaluation.
reliability_k (float, optional) – Support pseudo-count for reliability discounting in evidential output.
partition ({"quantile", "mdlp"}, default="quantile") – Automatic partition construction used when
fuzzy_partitionsis omitted.n_partitions (int, default=3) – Number of quantile terms per numerical feature.
overlap_frac (float, default=0.8) – Overlap fraction for supervised MDLP trapezoids.
split_mode ({"fixed", "learned"}, default="fixed") – Search the fitted linguistic terms or learn soft binary split ramps.
learned_width ({"bootstrap"} or float, default="bootstrap") – How learned ramps obtain their half-width. A float multiplies the weighted feature standard deviation.
learned_n_boot (int, default=25) – Bootstrap replicates used to estimate learned ramp widths.
prediction_mode ({"soft", "soft_gate", "hard_gate", "winner"}, default="soft") – Rule aggregation used by point prediction.
consistent_cci (bool, default=True) – Score CCI candidates in the same additive vote space as soft inference.
coverage_weight (float, default=0.0) – Optional reward for covering samples not activated by current rules.
multiway_splits (bool, default=False) – Add all remaining terms of a selected feature as sibling rules.
random_state (int, optional) – Seed for split sampling and learned-width bootstrapping.
- classes_#
Unique class labels found in the training data.
- Type:
np.array
- tree_rules#
Current number of rules (nodes) in the tree.
- Type:
int
- _root#
Root node of the decision tree containing tree structure.
- Type:
dict
- node_dict_access#
Dictionary for fast access to tree nodes by name.
- Type:
dict
- fuzzy_partitions_#
Fitted partitions, including learned ramp sets when applicable.
- Type:
list[fs.fuzzyVariable]
- __init__(fuzzy_partitions=None, max_rules=15, max_depth=5, coverage_threshold=0.0, min_improvement=0.01, ccp_alpha=0.0, target_metric='cci', sample_for_splits=None, sample_size=10000, reliability_k=None, partition='quantile', n_partitions=3, overlap_frac=0.8, split_mode='fixed', learned_width='bootstrap', learned_n_boot=25, prediction_mode='soft', consistent_cci=True, coverage_weight=0.0, multiway_splits=False, random_state=None, backend='python')[source]#
Initialize FERL.
- Parameters:
sample_for_splits (bool, optional) – If True, use sampling for split evaluation on large datasets. If None, automatically enabled for datasets > 50,000 samples.
sample_size (int, default=10000) – Number of samples to use for split evaluation when sampling is enabled.
reliability_k (float, optional) – Pseudo-count for the Shafer reliability discount used in predict_ds. A node with fuzzy training support N is trusted by r = N / (N + k), so low-support (thin, deep) leaves send mass to ignorance instead of their noisy class estimate. None (default) disables discounting.
backend ({'python', 'cython'}, default='python') – Use the optional compiled additive-vote scoring kernel during CCI split search. Both backends retain the same tree and prediction API. Other criteria and inference modes use the Python implementation.
- fit(X, y, patience=3)[source]#
Train FERL on the provided dataset.
This method builds the fuzzy decision tree by identifying the unique classes in the target variable and then constructing the tree structure using the fuzzy partitions and splitting criteria.
- Parameters:
X (np.array) – Training data features with shape (n_samples, n_features). Each row represents a sample and each column a feature.
y (np.array) – Target class labels with shape (n_samples,). Contains the class labels for each training sample.
- predict(X, observed_mask=None)[source]#
Predicts the class for given samples using fuzzy membership evaluation across ALL nodes.
In fuzzy decision trees, any node can provide the best prediction based on membership strength, not just leaf nodes. This method evaluates all nodes in the tree and selects the prediction from the node with highest membership for each sample.
- Parameters:
X (np.array) – Data to predict. Each row is a sample.
- Returns:
- np.array
Predicted class for each sample.
- Return type:
array
- predict_with_path(X, observed_mask=None)[source]#
Predicts the class for given samples along with membership and path information.
In fuzzy decision trees, evaluates all nodes to find the one with highest membership for each sample, providing the prediction from the best-matching node.
- Parameters:
X (np.array) – Data to predict. Each row is a sample.
- Returns:
- tuple[np.array, np.array, np.array]
Predicted classes, membership values, and paths for each sample.
- Return type:
tuple[array, array, array]
- predict_proba(X, observed_mask=None)[source]#
Predict class probabilities for given samples using fuzzy membership weighting across ALL nodes.
This method computes probability distributions over all classes for each sample by evaluating fuzzy membership to all nodes in the tree, not just leaves. The probabilities are derived from the weighted voting mechanism across all nodes, providing soft predictions that reflect the true fuzzy nature of decision tree classification.
- Parameters:
X (np.array) – Data to predict probabilities for. Each row is a sample.
observed_mask (np.array, optional) – Boolean mask indicating which features are observed (True) vs unobserved (False). Shape should be (n_samples, n_features). If None, assumes all features are observed.
- Returns:
- np.array
Array of shape (n_samples, n_classes) where each row contains the probability distribution over classes for the corresponding sample. Probabilities sum to 1.0 for each sample.
- Return type:
array
- firing_strength(X, observed_mask=None)[source]#
Total rule-firing strength Phi(x) = sum over non-root nodes of path membership.
This is the (unnormalized) total fuzzy activation a sample receives from the rule base. Low values mean the sample lies far from every rule (the model is extrapolating) and is a natural fuzzy coverage / epistemic-uncertainty signal, e.g. as a conformal nonconformity ingredient.
- Returns:
- np.array
Per-sample total firing strength, shape (n_samples,).
- Return type:
array
- node_activation_matrix(X, observed_mask=None, membership_floor=0.0)[source]#
Expose the per-node firing matrix used by ‘soft’ inference.
Returns (M, consequents, names) where M[i, k] is the path membership of non-root node k for sample i, consequents[k] is that node’s current (MLE) class-probability vector, and names[k] its identifier. Soft inference is exactly P(c|x) = (M @ consequents) / M.sum(1) (root excluded). This lets the node consequents be treated as differentiable parameters for post-hoc recalibration while the tree stays frozen.
membership_floor(epsilon leak) clamps each per-feature membership to [floor, 1] before the product, so bounded-support trapezoids never zero out a rule entirely – a fix for samples that otherwise get zero total firing and fall back to the prior.
- predict_ds(X, observed_mask=None, leaves_only=False, rule='dempster', reliability_k=None, prior_strength=None, reliability_vec=None, top_p=None)[source]#
Combine activated rule nodes as Dempster–Shafer evidence.
A rule firing with strength
mucommitsmu * p(c)to its class consequent and assigns the residual1 - muto ignorance. Optional support reliability, Dirichlet prior smoothing, and top-p routing move additional mass to ignorance.- Parameters:
X (array) – Samples of shape
(n_samples, n_features).observed_mask (array) – Boolean feature-observation mask with the same shape as
X.leaves_only (bool) – Combine leaf rules only.
rule (str) – Combination rule. Supported values are
"dempster","cautious","hybrid","incremental","incremental_local", and"mixture". Any other value raisesValueError.reliability_k (float) – Support pseudo-count used to discount thin rules.
prior_strength (float) – Dirichlet prior strength for consequent smoothing.
reliability_vec (array) – Explicit per-node reliability values.
top_p (float) – Optional nucleus threshold applied to each consequent.
- Returns:
A tuple
(betp, belief, plausibility, ignorance). The first three arrays have shape(n_samples, n_classes)and ignorance has shape(n_samples,).
- predict_dirichlet(X, observed_mask=None, u_floor=0.001, **ds_kwargs)[source]#
Dirichlet (second-order) distribution per sample, via the Subjective-Logic isomorphism of the DS singleton+Theta mass:
alpha_c = K * Bel(c) / m(Theta) + 1, S = sum_c alpha_c = K / m(Theta)
(uniform base rate, prior weight W=K). The Dirichlet mean alpha/S equals the pignistic
betp; the concentration S is set by the ignorance, so total ignorance -> Dir(1,…,1) (uniform). Per-class marginals are Beta(alpha_c, S - alpha_c), giving a full distribution – not just the [Bel, Pl] range – for each class probability.u_floorclamps m(Theta) away from 0 so confident samples give a finite (very peaked) Dirichlet instead of an infinite concentration. Extra keyword args (e.g.reliability_k,prior_strength,rule) pass through topredict_ds. Returns the (n_samples, n_classes) Dirichlet parameters.
- predict_credal(X, observed_mask=None, leaves_only=None, rule='dempster', **kwargs)[source]#
Return pignistic probabilities, belief, plausibility, and ignorance.
leaves_only defaults to True for learned-split (deep) FERL and False for compact fixed-partition FERL.
- predict_set(X, observed_mask=None, leaves_only=None, rule='dempster', **kwargs)[source]#
Return native credal prediction sets as a boolean class mask.
- predict_all_leaves(X, observed_mask=None)[source]#
Get membership values and predictions for all leaf nodes for each sample.
This method computes the fuzzy membership degree of each sample to every leaf node in the tree, along with each leaf’s prediction. This provides a complete picture of how samples relate to all possible decision paths.
- Parameters:
X (np.array) – Data to predict. Each row is a sample.
observed_mask (np.array, optional) – Boolean mask indicating which features are observed (True) vs unobserved (False). Shape should be (n_samples, n_features). If None, assumes all features are observed.
- Returns:
- tuple[dict, dict]
Two dictionaries: - memberships_dict: {leaf_name: np.array of memberships for each sample} - predictions_dict: {leaf_name: prediction_class}
- Return type:
tuple[dict, dict]
- predict_all_leaves_matrix(X, observed_mask=None)[source]#
Get memberships and predictions for all leaves in matrix format.
This is a convenience method that returns the same information as predict_all_leaves but in matrix format for easier analysis.
- Parameters:
X (np.array) – Data to predict. Each row is a sample.
observed_mask (np.array, optional) – Boolean mask indicating which features are observed (True) vs unobserved (False). Shape should be (n_samples, n_features). If None, assumes all features are observed.
- Returns:
- tuple[np.array, np.array, list]
membership_matrix: (n_samples, n_leaves) matrix of memberships
predictions_array: (n_leaves,) array of leaf predictions
leaf_names: list of leaf node names in same order as columns
- Return type:
tuple[array, array, list]
- print_tree(node=None, prefix='', is_last=True)[source]#
Print the tree structure in a hierarchical format showing coverage information.
- Parameters:
node – The node to start printing from (default: root)
prefix – String prefix for indentation
is_last – Whether this is the last child at this level
- get_tree_stats()[source]#
Calculate comprehensive statistics about the tree structure.
This method provides detailed information about the tree’s structural properties including the total number of nodes, leaf/internal node counts, and maximum depth. Useful for understanding tree complexity and for debugging purposes.
- Returns:
- dict
Dictionary containing tree statistics: - ‘total_nodes’: Total number of nodes in the tree - ‘leaves’: Number of leaf nodes (terminal nodes) - ‘internal’: Number of internal nodes (non-terminal nodes) - ‘depth’: Maximum depth of the tree
- cost_complexity_pruning(X, y, alpha=None)[source]#
Perform cost-complexity pruning on the tree.
- Parameters:
X (np.array) – Training data features used for pruning decisions.
y (np.array) – Training data labels used for impurity calculations.
alpha (float, optional) – Complexity parameter. If None, uses self.ccp_alpha.
- Returns:
- list[float]
Sequence of alpha values used for pruning.
- fit_with_pruning(X, y, X_val=None, y_val=None)[source]#
Fit the tree and apply cost-complexity pruning.
- Parameters:
X (np.array) – Training data features.
y (np.array) – Training data labels.
X_val (np.array, optional) – Validation data for selecting optimal alpha. If None, uses training data.
y_val (np.array, optional) – Validation labels for selecting optimal alpha. If None, uses training labels.
- set_fit_request(*, patience='$UNCHANGED$')#
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.Added in version 1.3.
- Parameters:
patience (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
patienceparameter infit.- Returns:
self – The updated object.
- Return type:
object
- set_predict_proba_request(*, observed_mask='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
predict_probamethod.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 topredict_probaif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict_proba.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.Added in version 1.3.
- Parameters:
observed_mask (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
observed_maskparameter inpredict_proba.- Returns:
self – The updated object.
- Return type:
object
- set_predict_request(*, observed_mask='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
predictmethod.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 topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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.Added in version 1.3.
- Parameters:
observed_mask (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
observed_maskparameter inpredict.- Returns:
self – The updated object.
- Return type:
object
- set_score_request(*, sample_weight='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
scoremethod.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 toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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.Added in version 1.3.
- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
self – The updated object.
- Return type:
object
Deep rule trees#
- class ex_fuzzy.DeepFERL(max_depth=12, min_leaf_w=2.0, n_boot=25, width='bootstrap', criterion='gini', bounded_support=True, oob_margin=1.0, random_state=None)[source]#
Bases:
BaseEstimator,ClassifierMixinDeep FERL: a recursively grown fuzzy rule tree with learned soft splits.
- Parameters:
max_depth (int, default=12) – Maximum depth of the tree.
min_leaf_w (float, default=2.0) – Minimum fuzzy weight (sum of memberships) each child of a split must keep. Nodes with less than twice this weight become leaves.
n_boot (int, default=25) – Bootstrap replicates used to estimate each split’s location and width when
width="bootstrap".width ({"bootstrap"} or float, default="bootstrap") –
"bootstrap"centers each ramp on the mean of the bootstrap thresholds, with half-width equal to their standard deviation. A positive floatccenters the ramp on the optimal threshold, with half-widthctimes the node’s weighted feature standard deviation.criterion ({"gini", "cci"}, default="gini") – Split criterion. Gini is the stronger choice once split locations are learned; CCI favors changes to the majority class.
bounded_support (bool, default=True) – Gate each split to the node’s training range on its feature, widened on both sides by
oob_margintimes that range. Far out-of-distribution samples then reach no leaf and surface as ignorance; in-distribution predictions are unaffected.oob_margin (float, default=1.0) – Relative margin of the bounded support gate.
random_state (int, optional) – Seed for the bootstrap resampling.
- classes_#
Class labels seen during
fit.- Type:
np.ndarray
- n_features_in_#
Number of features seen during
fit.- Type:
int
- feature_names_in_#
Feature names, when
Xwas a DataFrame with string column names.- Type:
np.ndarray
- root_#
Root of the fitted tree. Internal nodes hold the split feature
f, rampcenterand half-widthh, the node’s training rangelo/hi, and childrenL(below) andR(above). Every node holds its Laplace-smoothed class distributiondistand fuzzy trainingsupport.- Type:
dict
- n_leaves_#
Number of leaves, which are the model’s rules.
- Type:
int
- __init__(max_depth=12, min_leaf_w=2.0, n_boot=25, width='bootstrap', criterion='gini', bounded_support=True, oob_margin=1.0, random_state=None)[source]#
- fit(X, y)[source]#
Grow the tree.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Training features. Must be finite.
y (array-like of shape (n_samples,)) – Class labels.
- Returns:
- DeepFERL
The fitted estimator.
- predict_proba(X, observed_mask=None)[source]#
Class probabilities from the soft vote of the leaves.
Samples that reach no leaf, such as far out-of-distribution inputs under
bounded_support, receive uniform probabilities.- Parameters:
X (array-like of shape (n_samples, n_features)) – Samples to predict.
observed_mask (array-like of bool, optional) – Same shape as
X;Falsemarks an unobserved feature value.
- Returns:
- np.ndarray
Probabilities of shape (n_samples, n_classes).
- Return type:
ndarray
- node_activation_matrix(X, observed_mask=None)[source]#
Path membership of every non-root node.
- Returns:
- tuple
(M, cons, names, support): firing of shape (n_samples, n_nodes), consequents of shape (n_nodes, n_classes), hierarchical node names (a child extends its parent’s name with"_0"or"_1"), and each node’s fuzzy training support.
- firing_strength(X, observed_mask=None)[source]#
Total leaf firing per sample.
In-distribution samples route all of their weight to the leaves (total 1). Under
bounded_supportthe total falls toward 0 outside the training range, which makes it an out-of-distribution signal.
- predict_ds(X, observed_mask=None, leaves_only=False, rule='dempster', top_p=None, reliability_vec=None, beta=10.0)[source]#
Combine activated rule nodes as Dempster–Shafer evidence.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Samples to predict.
observed_mask (array-like of bool, optional) – Same shape as
X;Falsemarks an unobserved feature value.leaves_only (bool, default=False) – Combine leaf rules only.
rule (str, default="dempster") – One of
"dempster","cautious","hybrid","incremental","incremental_local"or"mixture".top_p (float, optional) – Top-p routing threshold applied to each consequent.
reliability_vec (array-like, optional) – Per-node reliability in [0, 1], aligned with the combined nodes, that discounts firing toward ignorance.
beta (float, default=10.0) – Support pseudo-count for the incremental and mixture reliabilities.
- Returns:
- tuple
(betp, belief, plausibility, ignorance); the first three have shape (n_samples, n_classes) and ignorance has shape (n_samples,).
- predict_credal(X, observed_mask=None, leaves_only=True, rule='dempster', **kwargs)[source]#
Pignistic probabilities, belief, plausibility and ignorance.
Leaves are combined by default, which avoids repeating the evidence of nested internal rules on a deep tree.
- predict_set(X, observed_mask=None, leaves_only=True, rule='dempster', **kwargs)[source]#
Native credal prediction sets as a boolean class mask.
A class is kept when its plausibility reaches the largest belief. A singleton is a confident prediction; a larger set abstains between its classes.
- predict_dirichlet(X, observed_mask=None, u_floor=0.001, **ds_kwargs)[source]#
Dirichlet parameters
alpha_c = K * Bel(c) / m(Theta) + 1per sample.u_floorkeeps ignorance away from zero so confident samples give a finite concentration. Extra keyword arguments go topredict_ds().
- print_tree(feature_names=None, decimals=3)[source]#
Print the tree as soft threshold rules.
Each split reads “feature is below/above center (± half-width)”, and each leaf shows its most probable class, that probability and its support.
- set_predict_proba_request(*, observed_mask='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
predict_probamethod.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 topredict_probaif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict_proba.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.Added in version 1.3.
- Parameters:
observed_mask (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
observed_maskparameter inpredict_proba.- Returns:
self – The updated object.
- Return type:
object
- set_predict_request(*, observed_mask='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
predictmethod.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 topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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.Added in version 1.3.
- Parameters:
observed_mask (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
observed_maskparameter inpredict.- Returns:
self – The updated object.
- Return type:
object
- set_score_request(*, sample_weight='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
scoremethod.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 toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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.Added in version 1.3.
- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
self – The updated object.
- Return type:
object
Supervised partitioning#
- ex_fuzzy.learn_partitions_mdlp(X, y, overlap_frac=0.8, fallback_median=True)[source]#
Supervised trapezoidal partitions via MDLP, as a list[fuzzyVariable].
fallback_mediancontrols uninformative features (MDLP returns no cut): if True they get a single median split (2 terms) so the feature stays usable by the tree; if False they get a single all-covering term.
- ex_fuzzy.mdlp_cuts(x, y)[source]#
Return sorted MDLP cut points for one feature.
Vectorized implementation: sort once, and at each recursion level evaluate all candidate splits at once via cumulative class counts (no Python loop). Typical cost O(N log N * C); the cut selection is identical to the naive O(N^2) version (validated to match exactly).