hummingbird.ml.operator_converters.sklearn.iforest¶
Converters for scikit-learn isolation forest.
- class hummingbird.ml.operator_converters.sklearn.iforest.GEMMIsolationForestImpl(*args: Any, **kwargs: Any)[source]¶
Bases:
GEMMTreeImpl
Class implementing the GEMM strategy (in PyTorch) for isolation forest model.
- _abc_impl = <_abc_data object>¶
- class hummingbird.ml.operator_converters.sklearn.iforest.PerfectTreeTraversalIsolationForestImpl(*args: Any, **kwargs: Any)[source]¶
Bases:
PerfectTreeTraversalTreeImpl
Class implementing the Perfect Tree Traversal strategy in PyTorch for isolation forest model.
- _abc_impl = <_abc_data object>¶
- class hummingbird.ml.operator_converters.sklearn.iforest.TreeTraversalIsolationForestImpl(*args: Any, **kwargs: Any)[source]¶
Bases:
TreeTraversalTreeImpl
Class implementing the Tree Traversal strategy in PyTorch for isolation forest model.
- _abc_impl = <_abc_data object>¶
- hummingbird.ml.operator_converters.sklearn.iforest._average_path_length(n_samples_leaf)[source]¶
Taken from sklearn implementation of isolation forest: https://github.com/scikit-learn/scikit-learn/blob/fd237278e/sklearn/ensemble/_iforest.py#L480 For each given number of samples in the array n_samples_leaf, this calculates average path length of unsucceesful BST search.
- Args:
n_samples_leaf: array of number of samples (in leaf)
- Returns:
array of average path lengths
- hummingbird.ml.operator_converters.sklearn.iforest._get_iforest_anomaly_score_per_node(children_left, children_right, n_node_samples)[source]¶
Get anomaly score per node in isolation forest, which is node depth + _average_path_length(n_node_samples). Will be used to replace “value” in each tree.
- Args:
children_left: left children children_right: right children n_node_samples: number of samples per node
- hummingbird.ml.operator_converters.sklearn.iforest._get_parameters_for_sklearn_iforest(tree_infos, extra_config)[source]¶
Parse sklearn-based isolation forest, replace existing values of node with anomaly score calculated in _get_iforest_anomaly_score_per_node
- Args:
tree_infos: The information representing a tree (ensemble)
- Returns:
The tree parameters wrapped into an instance of operator_converters._tree_commons_TreeParameters
- hummingbird.ml.operator_converters.sklearn.iforest.convert_sklearn_isolation_forest(operator, device, extra_config)[source]¶
Converter for sklearn.ensemble.IsolationForest.
- Args:
operator: An operator wrapping a tree (ensemble) isolation forest model device: String defining the type of device the converted operator should be run on extra_config: Extra configuration used to select the best conversion strategy
- Returns:
A PyTorch model