add support for afe with boolean indices (#272)
This commit is contained in:
Родитель
a745886376
Коммит
79ab1697a7
|
@ -1,4 +1,4 @@
|
|||
vi<!doctype html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -26,7 +26,7 @@ vi<!doctype html>
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/__init__.py#L0-L53" class="git-link">Browse git</a>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/__init__.py#L0-L54" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python"># -------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
|
|
@ -66,6 +66,10 @@ All scikit-learn operators converters are stored under this package.
|
|||
<dd>
|
||||
<div class="desc"><p>Converters for scikit-learn linear models: LinearRegression, LogisticRegression, LinearSVC, SGDClassifier, LogisticRegressionCV.</p></div>
|
||||
</dd>
|
||||
<dt><code class="name"><a title="hummingbird.ml.operator_converters.sklearn.missing_indicator" href="missing_indicator.html">hummingbird.ml.operator_converters.sklearn.missing_indicator</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Converter for scikit-learn MissingIndicator.</p></div>
|
||||
</dd>
|
||||
<dt><code class="name"><a title="hummingbird.ml.operator_converters.sklearn.mlp" href="mlp.html">hummingbird.ml.operator_converters.sklearn.mlp</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Converters for scikit-learn MLP models: MLPClassifier</p></div>
|
||||
|
@ -127,6 +131,7 @@ All scikit-learn operators converters are stored under this package.
|
|||
<li><code><a title="hummingbird.ml.operator_converters.sklearn.gbdt" href="gbdt.html">hummingbird.ml.operator_converters.sklearn.gbdt</a></code></li>
|
||||
<li><code><a title="hummingbird.ml.operator_converters.sklearn.iforest" href="iforest.html">hummingbird.ml.operator_converters.sklearn.iforest</a></code></li>
|
||||
<li><code><a title="hummingbird.ml.operator_converters.sklearn.linear" href="linear.html">hummingbird.ml.operator_converters.sklearn.linear</a></code></li>
|
||||
<li><code><a title="hummingbird.ml.operator_converters.sklearn.missing_indicator" href="missing_indicator.html">hummingbird.ml.operator_converters.sklearn.missing_indicator</a></code></li>
|
||||
<li><code><a title="hummingbird.ml.operator_converters.sklearn.mlp" href="mlp.html">hummingbird.ml.operator_converters.sklearn.mlp</a></code></li>
|
||||
<li><code><a title="hummingbird.ml.operator_converters.sklearn.nb" href="nb.html">hummingbird.ml.operator_converters.sklearn.nb</a></code></li>
|
||||
<li><code><a title="hummingbird.ml.operator_converters.sklearn.normalizer" href="normalizer.html">hummingbird.ml.operator_converters.sklearn.normalizer</a></code></li>
|
||||
|
|
|
@ -183,18 +183,10 @@ register_converter("SklearnMissingIndicator", convert_sklearn_missing_in
|
|||
<h3>Methods</h3>
|
||||
<dl>
|
||||
<dt id="hummingbird.ml.operator_converters.sklearn.missing_indicator.MissingIndicator.forward"><code class="name flex">
|
||||
<span>def <span class="ident">forward</span></span>(<span>self, x)</span>
|
||||
<span>def <span class="ident">forward</span></span>(<span>self, x) -> Callable[..., Any]</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Defines the computation performed at every call.</p>
|
||||
<p>Should be overridden by all subclasses.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>Although the recipe for forward pass needs to be defined within
|
||||
this function, one should call the :class:<code>Module</code> instance afterwards
|
||||
instead of this since the former takes care of running the
|
||||
registered hooks while the latter silently ignores them.</p>
|
||||
</div></div>
|
||||
<div class="desc"></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L0-L101" class="git-link">Browse git</a>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L0-L103" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python"># -------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
@ -88,6 +88,8 @@ def convert_sklearn_array_feature_extractor(operator, device, extra_config):
|
|||
assert operator is not None
|
||||
|
||||
indices = operator.column_indices
|
||||
if any([type(i) is bool for i in indices]):
|
||||
indices = [i for i in range(len(indices)) if indices[i]]
|
||||
return ArrayFeatureExtractor(np.ascontiguousarray(indices), device)
|
||||
|
||||
|
||||
|
@ -161,7 +163,7 @@ register_converter("SklearnMultiply", convert_sklearn_multiply)</code></
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L46-L61" class="git-link">Browse git</a>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L46-L63" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python">def convert_sklearn_array_feature_extractor(operator, device, extra_config):
|
||||
"""
|
||||
|
@ -178,6 +180,8 @@ register_converter("SklearnMultiply", convert_sklearn_multiply)</code></
|
|||
assert operator is not None
|
||||
|
||||
indices = operator.column_indices
|
||||
if any([type(i) is bool for i in indices]):
|
||||
indices = [i for i in range(len(indices)) if indices[i]]
|
||||
return ArrayFeatureExtractor(np.ascontiguousarray(indices), device)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
|
@ -203,7 +207,7 @@ register_converter("SklearnMultiply", convert_sklearn_multiply)</code></
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L64-L76" class="git-link">Browse git</a>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L66-L78" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python">def convert_sklearn_concat(operator, device=None, extra_config={}):
|
||||
"""
|
||||
|
@ -242,7 +246,7 @@ register_converter("SklearnMultiply", convert_sklearn_multiply)</code></
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L79-L97" class="git-link">Browse git</a>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/operator_converters/sklearn/pipeline.py#L81-L99" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python">def convert_sklearn_multiply(operator, device=None, extra_config={}):
|
||||
"""
|
||||
|
|
|
@ -70,7 +70,7 @@ XGBRegressor</p>
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/supported.py#L0-L322" class="git-link">Browse git</a>
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/supported.py#L0-L328" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python"># -------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
@ -170,7 +170,6 @@ def _build_sklearn_operator_list():
|
|||
# SVM-based models
|
||||
from sklearn.svm import LinearSVC, SVC, NuSVC
|
||||
|
||||
|
||||
# Imputers
|
||||
from sklearn.impute import MissingIndicator
|
||||
|
||||
|
@ -180,7 +179,6 @@ def _build_sklearn_operator_list():
|
|||
# Naive Bayes Models
|
||||
from sklearn.naive_bayes import BernoulliNB, GaussianNB, MultinomialNB
|
||||
|
||||
|
||||
# Preprocessing
|
||||
from sklearn.preprocessing import (
|
||||
Binarizer,
|
||||
|
@ -458,9 +456,7 @@ CONTAINER = "container"
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/supported.py#L277-L290" class="git-link">Browse git</a>
|
||||
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/supported.py#L283-L296" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python">def get_onnxml_api_operator_name(model_type):
|
||||
"""
|
||||
|
@ -497,9 +493,7 @@ or an object with scikit-learn API (e.g., LightGBM)</dd>
|
|||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/supported.py#L261-L274" class="git-link">Browse git</a>
|
||||
|
||||
<a href="https://github.com/microsoft/hummingbird/blob/master/hummingbird/ml/supported.py#L267-L280" class="git-link">Browse git</a>
|
||||
</summary>
|
||||
<pre><code class="python">def get_sklearn_api_operator_name(model_type):
|
||||
"""
|
||||
|
|
|
@ -58,6 +58,8 @@ def convert_sklearn_array_feature_extractor(operator, device, extra_config):
|
|||
assert operator is not None
|
||||
|
||||
indices = operator.column_indices
|
||||
if any([type(i) is bool for i in indices]):
|
||||
indices = [i for i in range(len(indices)) if indices[i]]
|
||||
return ArrayFeatureExtractor(np.ascontiguousarray(indices), device)
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче