Stree

class stree.Stree(C: float = 1.0, kernel: str = 'linear', max_iter: int = 100000.0, random_state: Optional[int] = None, max_depth: Optional[int] = None, tol: float = 0.0001, degree: int = 3, gamma='scale', split_criteria: str = 'impurity', criterion: str = 'entropy', min_samples_split: int = 0, max_features=None, splitter: str = 'random', multiclass_strategy: str = 'ovo', normalize: bool = False)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.ClassifierMixin

Estimator that is based on binary trees of svm nodes can deal with sample_weights in predict, used in boosting sklearn methods inheriting from BaseEstimator implements get_params and set_params methods inheriting from ClassifierMixin implement the attribute _estimator_type with “classifier” as value

_build_clf()[source]

Build the right classifier for the node

_initialize_max_features() int[source]
_more_tags() dict[source]

Required by sklearn to supply features of the classifier make mandatory the labels array

Returns

the tag required

Return type

dict

static _reorder_results(y: numpy.array, indices: numpy.array) numpy.array[source]

Reorder an array based on the array of indices passed

ynp.array

data untidy

indicesnp.array

indices used to set order

np.array

array y ordered

_train(X: numpy.ndarray, y: numpy.ndarray, sample_weight: numpy.ndarray, depth: int, title: str) Optional[stree.Splitter.Snode][source]

Recursive function to split the original dataset into predictor nodes (leaves)

Xnp.ndarray

samples dataset

ynp.ndarray

samples labels

sample_weightnp.ndarray

weight of samples. Rescale C per sample.

depthint

actual depth in the tree

titlestr

description of the node

Optional[Snode]

binary tree

fit(X: numpy.ndarray, y: numpy.ndarray, sample_weight: Optional[numpy.array] = None) stree.Strees.Stree[source]

Build the tree based on the dataset of samples and its labels

Stree

itself to be able to chain actions: fit().predict() …

ValueError

if C < 0

ValueError

if max_depth < 1

ValueError

if all samples have 0 or negative weights

nodes_leaves() tuple[source]

Compute the number of nodes and leaves in the built tree

[tuple]

tuple with the number of nodes and the number of leaves

predict(X: numpy.array) numpy.array[source]

Predict labels for each sample in dataset passed

Xnp.array

dataset of samples

np.array

array of labels

ValueError

if dataset with inconsistent number of features

NotFittedError

if model is not fitted