Id3

The documentation of the id3 module.

class id3.id3.Id3Estimator(max_depth=None, min_samples_split=2, prune=False, gain_ratio=False, min_entropy_decrease=0.0, is_repeating=False)[source]

A decision tree estimator for deriving ID3 decision trees.

Parameters:

max_depth : int, optional

max depth of features.

min_samples_split : int, optional (default=2)

min samples to split on.

prune : bool, optional (default=False)

set to True to prune the tree.

gain_ratio : bool, optional (default=False)

use gain ratio on split calculations.

is_repeating: bool, optional (default=False)

use repeating features.

Attributes

max_depth (int)
min_samples_split (int)
prune (bool)
gain_ratio (bool)
min_entropy_decrease (float)
is_repeating (bool)

Methods

fit(X, y, check_input=True)[source]

Build a decision tree based on samples X and corresponding classifications y.

Parameters:

X : array-like or sparse matrix of shape = [n_samples, n_features]

The training input samples.

y : array-like, shape = [n_samples] or [n_samples, n_outputs]

The target values (class labels in classification, real numbers in regression).

check_input : bool (default=True)

check if the input for numerical features

Returns:

self : object

Returns self.

Attributes

n_features_ (int) The number of features when fit is performed.
X_encoders_ (list) List of LabelEncoders that transforms input from labels to binary encodings and vice versa.
y_encoder_ (LabelEncoder) LabelEncoders that transforms output from labels to binary encodings and vice versa.
is_numerical_ (bool array of size [n_features]) Array flagging which features that are asumed to be numerical
builder_ (TreeBuilder) Instance of the tree builder
tree_ (Tree) Instance of the build tree
predict(X)[source]

Predict class for every sample in X.

Parameters:

X : array-like of shape = [n_samples, n_features_idx]

The input samples.

Returns:

y : array of shape = [n_samples]

predict_proba(X)[source]

Predict class probabilities for every sample in X.

Parameters:

X : array-like of shape = [n_samples, n_features_idx]

The input samples.

Returns:

y : array of shape = [n_samples, n_classes]