wildboar.tree.base#

Module Contents#

Classes#

BaseTree

Base class for tree based estimators.

TreeClassifierMixin

Mixin for classification trees.

TreeRegressorMixin

Mixin for regression trees.

class wildboar.tree.base.BaseTree(*, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_impurity_decrease=0.0)[source]#

Bases: wildboar.base.BaseEstimator

Base class for tree based estimators.

apply(x, check_input=True)[source]#
decision_path(x, check_input=True)[source]#
class wildboar.tree.base.TreeClassifierMixin[source]#

Bases: sklearn.base.ClassifierMixin

Mixin for classification trees.

fit(x, y, sample_weight=None, check_input=True)[source]#

Fit a classification tree.

Parameters:
  • x (array-like of shape (n_samples, n_timesteps)) – The training time series.

  • y (array-like of shape (n_samples,)) – The target values

  • sample_weight (array-like of shape (n_samples,)) – If None, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. Splits are also ignored if they would result in any single class carrying a negative weight in either child node.

  • check_input (bool, optional) – Allow to bypass several input checks.

Returns:

self

Return type:

object

predict(x, check_input=True)[source]#

Predict the regression of the input samples x.

Parameters:
  • x (array-like of shape (n_samples, n_timesteps)) – The input time series

  • check_input (bool, optional) – Allow to bypass several input checking. Don’t use this parameter unless you know what you do.

Returns:

y – The predicted classes.

Return type:

ndarray of shape (n_samples,)

predict_proba(x, check_input=True)[source]#

Predict class probabilities of the input samples X. The predicted class probability is the fraction of samples of the same class in a leaf.

Parameters:
  • x (array-like of shape (n_samples, n_timesteps)) – The input time series

  • check_input (bool, optional) – Allow to bypass several input checking. Don’t use this parameter unless you know what you do.

Returns:

proba – The class probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_

Return type:

ndarray of shape (n_samples, n_classes)

class wildboar.tree.base.TreeRegressorMixin[source]#

Bases: sklearn.base.RegressorMixin

Mixin for regression trees.

fit(x, y, sample_weight=None, check_input=True)[source]#

Fit a shapelet tree regressor from the training set

Parameters:
  • X (array-like of shape (n_samples, n_timesteps)) – The training time series.

  • y (array-like of shape (n_samples,)) – Target values as floating point values

  • sample_weight (array-like of shape (n_samples,)) – If None, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. Splits are also ignored if they would result in any single class carrying a negative weight in either child node.

  • check_input (bool, optional) – Allow to bypass several input checks

Returns:

self

Return type:

object

predict(x, check_input=True)[source]#

Predict the regression of the input samples x.

Parameters:
  • x (array-like of shape (n_samples, n_timesteps)) – The input time series

  • check_input (bool, optional) – Allow to bypass several input checking. Don’t use this parameter unless you know what you do.

Returns:

y – The predicted classes.

Return type:

ndarray of shape (n_samples,)