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
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.Strees.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