col_gen_estimator.DTreeClassifier

class col_gen_estimator.DTreeClassifier(initial_paths=[], leaves=[], nodes=[], splits=[], tree_depth=1, targets=[], max_iterations=-1, time_limit=-1, num_master_cuts_round=3, master_beta_constraints_as_cuts=False, master_generate_cuts=False, data_rows=None, use_old_sp=False, master_solver_type='glop', rmp_solver_params='', master_ip_solver_params='', subproblem_params='')[source]

Decision Tree classifier using column generation.

Parameters:
initial_paths: list(Path), default=[],

List of paths used to initialize the master problem. The user must ensure that a valid tree can be formed using the initial paths.

leaves: list(Leaf), default=[],

List of leaves in the tree.

nodes: list(Node), default=[],

List of nodes in the tree.

splits: list(Split), default=[],

List of split checks used in the nodes.

tree_depth: int, default=1,

Depth of the tree.

targets: list(int), default=[],

List of target ids. They must start from 0.

max_iterations: int, default=-1

Maximum column generation iterations. Negative values removes the iteration limit and the problem is solved till optimality.

time_limit: int, default=-1,

Time limit in seconds for training. Negative values removes the time limit and the problem is solved till optimality.

num_master_cuts_round: int, default=3,

Number of times the master problem adds cuts in an iteration.

master_beta_constraints_as_cuts: bool, default=False,

If True, adds existing beta constraints (constraints for data rows) as cutting planes in the master problem.

master_generate_cuts: bool, default=False,

If True, master problem generates new beta cuts using SAT solver.

data_rows: list(Row), default=None,

Preprocessed data rows. The preprocessed rows help with faster running times.

use_old_sp: bool, default=False,

If True, uses the old subproblem model published in Firat et. al. 2020.

master_solver_type: str, default=’glop’,

Solver for RMP from OR-Tools. Use ‘glop’ for tests. See OR-Tools documentation for other possible values.

rmp_solver_params: string, default = “”,

Solver parameters for solving restricted master problem (rmp).

master_ip_solver_params: string, default = “”,

Solver parameters for solving the integer master problem.

subproblem_params: list of strings, default = [“”],

Parameters for solving the subproblem.

__init__(initial_paths=[], leaves=[], nodes=[], splits=[], tree_depth=1, targets=[], max_iterations=-1, time_limit=-1, num_master_cuts_round=3, master_beta_constraints_as_cuts=False, master_generate_cuts=False, data_rows=None, use_old_sp=False, master_solver_type='glop', rmp_solver_params='', master_ip_solver_params='', subproblem_params='')[source]
predict(X)[source]

Predicts the class based on the solution of master problem.

Parameters:
Xarray-like, shape (n_samples, n_features)

The input samples. The inputs should only contain numeric values.

Returns:
yndarray, shape (n_samples,)

The label for each sample.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') DTreeClassifier

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.

Examples using col_gen_estimator.DTreeClassifier

sphx_glr_auto_examples_dtree_experiment.py

Code to launch decision tree experiments.