TreeClassifier which allows to create hierarchy of classifiers
Functions by grouping some labels into a single “meta-label” and training classifier first to separate between meta-labels. Then each group further proceeds with classification within each group.
Possible scenarios:
TreeClassifier(SVM(),
{'animate': ((1,2,3,4),
TreeClassifier(SVM(),
{'human': (('male', 'female'), SVM()),
'animals': (('monkey', 'dog'), SMLR())})),
'inanimate': ((5,6,7,8), SMLR())})
would create classifier which would first do binary classification to separate animate from inanimate, then for animate result it would separate to classify human vs animal and so on:
SVM
/ animate inanimate
/ SVM SMLR
/ \ / | \ human animal 5 6 7 8
| |
SVM SVM
/ \ / male female monkey dog
1 2 3 4
If it is desired to have a trailing node with a single label and thus without any classification, such as in
SVM/ g1 g2
- / 1 SVM
- / 2 3
then just specify None as the classifier to use:
TreeClassifier(SVM(),
{'g1': ((1,), None),
'g2': ((1,2,3,4), SVM())})
Notes
Available conditional attributes:
(Conditional attributes enabled by default suffixed with +)
Methods
clone() | Create full copy of the classifier. |
generate(ds) | Yield processing results. |
get_postproc() | Returns the post-processing node or None. |
get_sensitivity_analyzer(*args_, **kwargs_) | |
get_space() | Query the processing space name of this node. |
is_trained([dataset]) | Either classifier was already trained. |
predict(obj, data, *args, **kwargs) | |
repredict(obj, data, *args, **kwargs) | |
reset() | |
retrain(dataset, **kwargs) | Helper to avoid check if data was changed actually changed Useful if just some aspects of classifier were changed since its previous training. |
set_postproc(node) | Assigns a post-processing node Set to None to disable postprocessing. |
set_space(name) | Set the processing space name of this node. |
summary() | Provide summary for the TreeClassifier. |
train(ds) | The default implementation calls _pretrain(), _train(), and finally _posttrain(). |
untrain() | Reverts changes in the state of this node caused by previous training |
Initialize TreeClassifier
Parameters: | clf : Classifier
groups : dict of meta-label: tuple of (tuple of labels, classifier)
enable_ca : None or list of str
disable_ca : None or list of str
auto_train : bool
force_train : bool
space: str, optional :
postproc : Node instance, optional
descr : str
|
---|
Methods
clone() | Create full copy of the classifier. |
generate(ds) | Yield processing results. |
get_postproc() | Returns the post-processing node or None. |
get_sensitivity_analyzer(*args_, **kwargs_) | |
get_space() | Query the processing space name of this node. |
is_trained([dataset]) | Either classifier was already trained. |
predict(obj, data, *args, **kwargs) | |
repredict(obj, data, *args, **kwargs) | |
reset() | |
retrain(dataset, **kwargs) | Helper to avoid check if data was changed actually changed Useful if just some aspects of classifier were changed since its previous training. |
set_postproc(node) | Assigns a post-processing node Set to None to disable postprocessing. |
set_space(name) | Set the processing space name of this node. |
summary() | Provide summary for the TreeClassifier. |
train(ds) | The default implementation calls _pretrain(), _train(), and finally _posttrain(). |
untrain() | Reverts changes in the state of this node caused by previous training |
Dictionary of classifiers used by the groups
Provide summary for the TreeClassifier.