odtlearn.flow_oct#

Module Contents#

Classes#

FlowOCT

An optimal decision tree classifier, fitted on a given

BendersOCT

Helper class that provides a standard way to create an ABC using

class odtlearn.flow_oct.FlowOCT(solver, _lambda=0, obj_mode='acc', depth=1, time_limit=60, num_threads=None, verbose=False)[source]#

Bases: odtlearn.flow_oct_ss.FlowOCTSingleSink

An optimal decision tree classifier, fitted on a given integer-valued data set to produce a provably optimal decision tree.

Parameters:
solver: str

A string specifying the name of the solver to use to solve the MIP. Options are “Gurobi” and “CBC”. If the CBC binaries are not found, Gurobi will be used by default.

_lambda: float, default = 0

The regularization parameter in the objective, taking values between 0 and 1, that controls the complexity of a the learned tree.

obj_mode: str, default=”acc”

The objective should be used to learn an optimal decision tree. The two options are “acc” and “balance”. The accuracy objective attempts to maximize prediction accuracy while the balance objective aims to learn a balanced optimal decision tree to better generalize to our of sample data.

depthint, default=1

A parameter specifying the depth of the tree to learn.

time_limitint, default=60

The given time limit for solving the MIP in seconds.

num_threads: int, default=None

The number of threads the solver should use. If not specified, solver uses all available threads

verbosebool, default = False

Flag for logging solver outputs.

fit(X, y)[source]#
predict(X)[source]#

Classify test points using the StrongTree classifier

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

The input samples.

Returns:
yndarray, shape (n_samples,)

The label for each sample is the label of the closest sample seen during fit.

class odtlearn.flow_oct.BendersOCT(solver, _lambda=0, obj_mode='acc', depth=1, time_limit=60, num_threads=None, verbose=False)[source]#

Bases: odtlearn.flow_oct_ss.FlowOCTSingleSink

Helper class that provides a standard way to create an ABC using inheritance.

fit(X, y)[source]#
predict(X)[source]#

Classify test points using the Benders’ Formulation Classifier

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

The input samples.

Returns:
yndarray, shape (n_samples,)

The label for each sample is the label of the closest sample seen during fit.