odtlearn.flow_opt#

Module Contents#

Classes#

FlowOPT_IPW

An optimal decision tree that prescribes treatments (as opposed to predicting class labels),

FlowOPT_DM

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

FlowOPT_DR

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

class odtlearn.flow_opt.FlowOPT_IPW(solver, depth=1, time_limit=60, num_threads=None, verbose=False)[source]#

Bases: odtlearn.flow_opt_ss.FlowOPTSingleSink

An optimal decision tree that prescribes treatments (as opposed to predicting class labels), fitted on a binary-valued observational data set.

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.

depthint, default=1

A parameter specifying the depth of the tree to learn.

time_limitint

The given time limit for solving the MIP in seconds.

methodstr, default=’IPW’

The method of Prescriptive Trees to run. Choices in (‘IPW’, ‘DM’, ‘DR), which represents the inverse propensity weighting, direct method, and doubly robust methods, respectively.

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, t, y, ipw)[source]#

Method to fit the PrescriptiveTree class on the data

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

The training input samples.

tarray-like, shape (n_samples,)

The treatment values. An array of int.

yarray-like, shape (n_samples,)

The observed outcomes upon given treatment t. An array of int.

ipwarray-like, shape (n_samples,)

The inverse propensity weight estimates. An array of floats in [0, 1].

Returns:
selfobject

Returns self.

predict(X)[source]#

Method for making prescriptions using a PrescriptiveTree classifier

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

The input samples.

Returns:
tndarray, shape (n_samples,)

The prescribed treatments for the input samples.

class odtlearn.flow_opt.FlowOPT_DM(solver, depth=1, time_limit=60, num_threads=None, verbose=False)[source]#

Bases: odtlearn.flow_opt_ms.FlowOPTMultipleSink

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

fit(X, t, y, y_hat)[source]#

Method to fit the PrescriptiveTree class on the data

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

The training input samples.

tarray-like, shape (n_samples,)

The treatment values. An array of int.

yarray-like, shape (n_samples,)

The observed outcomes upon given treatment t. An array of int.

y_hat: array-like, shape (n_samples, n_treatments)

The counterfactual predictions.

Returns:
selfobject

Returns self.

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_opt.FlowOPT_DR(solver, depth=1, time_limit=60, num_threads=None, verbose=False)[source]#

Bases: odtlearn.flow_opt_ms.FlowOPTMultipleSink

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

fit(X, t, y, ipw, y_hat)[source]#

Method to fit the PrescriptiveTree class on the data

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

The training input samples.

tarray-like, shape (n_samples,)

The treatment values. An array of int.

yarray-like, shape (n_samples,)

The observed outcomes upon given treatment t. An array of int.

ipwarray-like, shape (n_samples,)

The inverse propensity weight estimates. An array of floats in [0, 1].

y_hat: array-like, shape (n_samples, n_treatments)

The counterfactual predictions.

Returns:
selfobject

Returns self.

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.