-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsklearn.html
More file actions
executable file
·367 lines (343 loc) · 26.6 KB
/
sklearn.html
File metadata and controls
executable file
·367 lines (343 loc) · 26.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<!DOCTYPE html>
<html class="writer-html5" lang="en">
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Scikit-Learn API and patching — daal4py 2021.1 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css" />
<link rel="stylesheet" type="text/css" href="_static/style.css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="_static/jquery.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Examples" href="examples.html" />
<script defer type="text/javascript" src="https://www.intel.com/content/dam/www/global/wap/performance-config.js" ></script>
<script type="text/javascript">
// Configure TMS settings
var wapLocalCode = 'us-en'; // Dynamically set per localized site, see mapping table for values
var wapSection = "scikit-learn"; // WAP team will give you a unique section for your site
// Load TMS
if(document.location.href.contains("intel.github.io/scikit-learn-intelex")){
(function () {
var url = 'https://www.intel.com/content/dam/www/global/wap/tms-loader.js'; // WAP file URL
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = url;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
}
</script>
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="contents.html" class="icon icon-home">
daal4py
</a>
<div class="version">
2021
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index.html">About daal4py</a></li>
<li class="toctree-l1"><a class="reference internal" href="data.html">Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="model-builders.html">Model Builders</a></li>
<li class="toctree-l1"><a class="reference internal" href="algorithms.html">Supported Algorithms</a></li>
<li class="toctree-l1"><a class="reference internal" href="scaling.html">Distributed Mode</a></li>
<li class="toctree-l1"><a class="reference internal" href="streaming.html">Streaming Mode</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Scikit-Learn API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#deprecation-notice">Deprecation Notice</a></li>
<li class="toctree-l2"><a class="reference internal" href="#onedal-accelerated-scikit-learn">oneDAL accelerated scikit-learn</a></li>
<li class="toctree-l2"><a class="reference internal" href="#scikit-learn-verbose">scikit-learn verbose</a></li>
<li class="toctree-l2"><a class="reference internal" href="#scikit-learn-api">scikit-learn API</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="contents.html">daal4py</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="contents.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Scikit-Learn API and patching</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/sklearn.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="scikit-learn-api-and-patching">
<span id="sklearn"></span><h1>Scikit-Learn API and patching<a class="headerlink" href="#scikit-learn-api-and-patching" title="Permalink to this heading"></a></h1>
<p>Python interface to efficient Intel(R) oneAPI Data Analytics Library provided by daal4py allows one
to create scikit-learn compatible estimators, transformers, clusterers, etc. powered by oneDAL which
are nearly as efficient as native programs.</p>
<section id="deprecation-notice">
<h2>Deprecation Notice<a class="headerlink" href="#deprecation-notice" title="Permalink to this heading"></a></h2>
<p>Scikit-learn patching functionality in daal4py was deprecated and moved to a separate
package, <a class="reference external" href="https://github.com/intel/scikit-learn-intelex">Intel(R) Extension for Scikit-learn*</a>.
All future patches will be available only in Intel(R) Extension for Scikit-learn*.
Please use the scikit-learn-intelex package instead of daal4py for the scikit-learn acceleration.</p>
</section>
<section id="onedal-accelerated-scikit-learn">
<span id="sklearn-patches"></span><h2>oneDAL accelerated scikit-learn<a class="headerlink" href="#onedal-accelerated-scikit-learn" title="Permalink to this heading"></a></h2>
<p>daal4py can dynamically patch scikit-learn estimators to use Intel(R) oneAPI Data Analytics Library
as the underlying solver, while getting the same solution faster.</p>
<p>It is possible to enable those patches without editing the code of a scikit-learn application by
using the following commandline flag:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">daal4py</span> <span class="n">my_application</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
<p>If you are using Scikit-Learn from Intel® Distribution for Python, then
you can enable daal4py patches through an environment variable. To do this, set <code class="docutils literal notranslate"><span class="pre">USE_DAAL4PY_SKLEARN</span></code> to one of the values
<code class="docutils literal notranslate"><span class="pre">True</span></code>, <code class="docutils literal notranslate"><span class="pre">'1'</span></code>, <code class="docutils literal notranslate"><span class="pre">'y'</span></code>, <code class="docutils literal notranslate"><span class="pre">'yes'</span></code>, <code class="docutils literal notranslate"><span class="pre">'Y'</span></code>, <code class="docutils literal notranslate"><span class="pre">'YES'</span></code>, <code class="docutils literal notranslate"><span class="pre">'Yes'</span></code>, <code class="docutils literal notranslate"><span class="pre">'true'</span></code>, <code class="docutils literal notranslate"><span class="pre">'True'</span></code> or <code class="docutils literal notranslate"><span class="pre">'TRUE'</span></code> as shown below.</p>
<p>On Linux and Mac OS:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">USE_DAAL4PY_SKLEARN</span><span class="o">=</span><span class="mi">1</span>
</pre></div>
</div>
<p>On Windows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">set</span> <span class="n">USE_DAAL4PY_SKLEARN</span><span class="o">=</span><span class="mi">1</span>
</pre></div>
</div>
<p>To disable daal4py patches, set the <code class="docutils literal notranslate"><span class="pre">USE_DAAL4PY_SKLEARN</span></code> environment variable to 0.</p>
<p>Patches can also be enabled programmatically:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">daal4py.sklearn</span>
<span class="n">daal4py</span><span class="o">.</span><span class="n">sklearn</span><span class="o">.</span><span class="n">patch_sklearn</span><span class="p">()</span>
</pre></div>
</div>
<p>It is possible to undo the patch with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">daal4py</span><span class="o">.</span><span class="n">sklearn</span><span class="o">.</span><span class="n">unpatch_sklearn</span><span class="p">()</span>
</pre></div>
</div>
<p id="sklearn-algorithms">Applying the monkey patch will impact the following existing scikit-learn
algorithms:</p>
<table class="docutils align-left">
<colgroup>
<col style="width: 15%" />
<col style="width: 15%" />
<col style="width: 46%" />
<col style="width: 23%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Task</p></th>
<th class="head"><p>Functionality</p></th>
<th class="head"><p>Parameters support</p></th>
<th class="head"><p>Data support</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Classification</p></td>
<td><p>SVC</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">poly</span></code> and <code class="docutils literal notranslate"><span class="pre">sigmoid</span></code> kernels.</p></td>
<td><p>No limitations.</p></td>
</tr>
<tr class="row-odd"><td><p>Classification</p></td>
<td><p>RandomForestClassifier</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">warm_start</span></code> = True, <code class="docutils literal notranslate"><span class="pre">cpp_alpha</span></code> != 0, <code class="docutils literal notranslate"><span class="pre">criterion</span></code> != ‘gini’, <code class="docutils literal notranslate"><span class="pre">oob_score</span></code> = True.</p></td>
<td><p>Multi-output, sparse data and out-of-bag score are not supported.</p></td>
</tr>
<tr class="row-even"><td><p>Classification</p></td>
<td><p>KNeighborsClassifier</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">metric</span></code> != ‘euclidean’ or <code class="docutils literal notranslate"><span class="pre">minkowski</span></code> with <code class="docutils literal notranslate"><span class="pre">p</span></code> = 2.</p></td>
<td><p>Multi-output and sparse data is not supported.</p></td>
</tr>
<tr class="row-odd"><td><p>Classification</p></td>
<td><p>LogisticRegression</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">solver</span></code> != ‘lbfgs’ or ‘newton-cg’, <code class="docutils literal notranslate"><span class="pre">class_weight</span></code> != None, <code class="docutils literal notranslate"><span class="pre">sample_weight</span></code> != None.</p></td>
<td><p>Only dense data is supported.</p></td>
</tr>
<tr class="row-even"><td><p>Regression</p></td>
<td><p>RandomForestRegressor</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">warm_start</span></code> = True, <code class="docutils literal notranslate"><span class="pre">cpp_alpha</span></code> != 0, <code class="docutils literal notranslate"><span class="pre">criterion</span></code> != ‘mse’, <code class="docutils literal notranslate"><span class="pre">oob_score</span></code> = True.</p></td>
<td><p>Multi-output, sparse data and out-of-bag score are not supported.</p></td>
</tr>
<tr class="row-odd"><td><p>Regression</p></td>
<td><p>KNeighborsRegressor</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">metric</span></code> != ‘euclidean’ or <code class="docutils literal notranslate"><span class="pre">minkowski</span></code> with <code class="docutils literal notranslate"><span class="pre">p</span></code> = 2.</p></td>
<td><p>Multi-output and sparse data is not supported.</p></td>
</tr>
<tr class="row-even"><td><p>Regression</p></td>
<td><p>LinearRegression</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">normalize</span></code> != False and <code class="docutils literal notranslate"><span class="pre">sample_weight</span></code> != None.</p></td>
<td><p>Only dense data is supported, #observations should be >= #features.</p></td>
</tr>
<tr class="row-odd"><td><p>Regression</p></td>
<td><p>Ridge</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">normalize</span></code> != False, <code class="docutils literal notranslate"><span class="pre">solver</span></code> != ‘auto’ and <code class="docutils literal notranslate"><span class="pre">sample_weight</span></code> != None.</p></td>
<td><p>Only dense data is supported, #observations should be >= #features.</p></td>
</tr>
<tr class="row-even"><td><p>Regression</p></td>
<td><p>ElasticNet</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">sample_weight</span></code> != None.</p></td>
<td><p>Multi-output and sparse data is not supported, #observations should be >= #features.</p></td>
</tr>
<tr class="row-odd"><td><p>Regression</p></td>
<td><p>Lasso</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">sample_weight</span></code> != None.</p></td>
<td><p>Multi-output and sparse data is not supported, #observations should be >= #features.</p></td>
</tr>
<tr class="row-even"><td><p>Clustering</p></td>
<td><p>KMeans</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">precompute_distances</span></code> and <code class="docutils literal notranslate"><span class="pre">sample_weight</span></code> != None.</p></td>
<td><p>No limitations.</p></td>
</tr>
<tr class="row-odd"><td><p>Clustering</p></td>
<td><p>DBSCAN</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">metric</span></code> != ‘euclidean’ or <code class="docutils literal notranslate"><span class="pre">minkowski</span></code> with <code class="docutils literal notranslate"><span class="pre">p</span></code> = 2.</p></td>
<td><p>Only dense data is supported.</p></td>
</tr>
<tr class="row-even"><td><p>Dimensionality reduction</p></td>
<td><p>PCA</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">svd_solver</span></code> != ‘full’.</p></td>
<td><p>Sparse data is not supported.</p></td>
</tr>
<tr class="row-odd"><td><p>Unsupervised</p></td>
<td><p>NearestNeighbors</p></td>
<td><p>All parameters except <code class="docutils literal notranslate"><span class="pre">metric</span></code> != ‘euclidean’ or <code class="docutils literal notranslate"><span class="pre">minkowski</span></code> with <code class="docutils literal notranslate"><span class="pre">p</span></code> = 2.</p></td>
<td><p>Sparse data is not supported.</p></td>
</tr>
<tr class="row-even"><td><p>Other</p></td>
<td><p>train_test_split</p></td>
<td><p>All parameters are supported.</p></td>
<td><p>Only dense data is supported.</p></td>
</tr>
<tr class="row-odd"><td><p>Other</p></td>
<td><p>assert_all_finite</p></td>
<td><p>All parameters are supported.</p></td>
<td><p>Only dense data is supported.</p></td>
</tr>
<tr class="row-even"><td><p>Other</p></td>
<td><p>pairwise_distance</p></td>
<td><p>With metric=``cosine`` and <code class="docutils literal notranslate"><span class="pre">correlation</span></code>.</p></td>
<td><p>Only dense data is supported.</p></td>
</tr>
<tr class="row-odd"><td><p>Other</p></td>
<td><p>roc_auc_score</p></td>
<td><p>Parameters <code class="docutils literal notranslate"><span class="pre">average</span></code>, <code class="docutils literal notranslate"><span class="pre">sample_weight</span></code>, <code class="docutils literal notranslate"><span class="pre">max_fpr</span></code> and <code class="docutils literal notranslate"><span class="pre">multi_class</span></code> are not supported.</p></td>
<td><p>No limitations.</p></td>
</tr>
</tbody>
</table>
<p>Monkey-patched scikit-learn classes and functions passes scikit-learn’s own test
suite, with few exceptions, specified in <a class="reference external" href="https://github.com/IntelPython/daal4py/blob/main/deselected_tests.yaml">deselected_tests.yaml</a>.</p>
<p>In particular the tests execute <a class="reference external" href="https://scikit-learn.org/stable/modules/generated/sklearn.utils.estimator_checks.check_estimator.html">check_estimator</a>
on all added and monkey-patched classes, which are discovered by means of
introspection. This assures scikit-learn API compatibility of all
<cite>daal4py.sklearn</cite> classes.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>daal4py supports optimizations for the last four versions of scikit-learn.
The latest release of daal4py-2021.1 supports scikit-learn 0.21.X, 0.22.X, 0.23.X and 0.24.X.</p>
</div>
</section>
<section id="scikit-learn-verbose">
<span id="sklearn-verbose"></span><h2>scikit-learn verbose<a class="headerlink" href="#scikit-learn-verbose" title="Permalink to this heading"></a></h2>
<p>To find out which implementation of the algorithm is currently used,
set the environment variable.</p>
<p>On Linux and Mac OS:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">IDP_SKLEARN_VERBOSE</span><span class="o">=</span><span class="n">INFO</span>
</pre></div>
</div>
<p>On Windows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">set</span> <span class="n">IDP_SKLEARN_VERBOSE</span><span class="o">=</span><span class="n">INFO</span>
</pre></div>
</div>
<p>During the calls that use Intel-optimized scikit-learn, you will receive additional print statements
that indicate which implementation is being called.
These print statements are only available for <a class="reference internal" href="#sklearn-algorithms"><span class="std std-ref">scikit-learn algorithms with daal4py patches</span></a>.</p>
<p>For example, for DBSCAN you get one of these print statements depending on which implementation is used:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">INFO</span><span class="p">:</span> <span class="n">sklearn</span><span class="o">.</span><span class="n">cluster</span><span class="o">.</span><span class="n">DBSCAN</span><span class="o">.</span><span class="n">fit</span><span class="p">:</span> <span class="n">running</span> <span class="n">accelerated</span> <span class="n">version</span> <span class="n">on</span> <span class="n">CPU</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">INFO</span><span class="p">:</span> <span class="n">sklearn</span><span class="o">.</span><span class="n">cluster</span><span class="o">.</span><span class="n">DBSCAN</span><span class="o">.</span><span class="n">fit</span><span class="p">:</span> <span class="n">fallback</span> <span class="n">to</span> <span class="n">original</span> <span class="n">Scikit</span><span class="o">-</span><span class="n">learn</span>
</pre></div>
</div>
</section>
<section id="scikit-learn-api">
<span id="sklearn-api"></span><h2>scikit-learn API<a class="headerlink" href="#scikit-learn-api" title="Permalink to this heading"></a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">daal4py.sklearn</span></code> package contains scikit-learn compatible API which
implement a subset of scikit-learn algorithms using Intel(R) oneAPI Data Analytics Library.</p>
<p>Currently, these include:</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.neighbors.KNeighborsClassifier</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.neighbors.KNeighborsRegressor</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.neighbors.NearestNeighbors</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.tree.DecisionTreeClassifier</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.ensemble.RandomForestClassifier</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.ensemble.RandomForestRegressor</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.ensemble.AdaBoostClassifier</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.cluster.KMeans</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.cluster.DBSCAN</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.decomposition.PCA</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.linear_model.Ridge</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.svm.SVC</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.linear_model.logistic_regression_path</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.linear_model.LogisticRegression</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.linear_model.ElasticNet</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.linear_model.Lasso</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.model_selection._daal_train_test_split</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">daal4py.sklearn.metrics._daal_roc_auc_score</span></code></p></li>
</ol>
<p>These classes are always available, whether the scikit-learn itself has been
patched, or not. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">daal4py.sklearn</span>
<span class="n">daal4py</span><span class="o">.</span><span class="n">sklearn</span><span class="o">.</span><span class="n">unpatch_sklearn</span><span class="p">()</span>
<span class="kn">import</span> <span class="nn">sklearn.datasets</span><span class="o">,</span> <span class="nn">sklearn.svm</span>
<span class="n">digits</span> <span class="o">=</span> <span class="n">sklearn</span><span class="o">.</span><span class="n">datasets</span><span class="o">.</span><span class="n">load_digits</span><span class="p">()</span>
<span class="n">X</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">digits</span><span class="o">.</span><span class="n">data</span><span class="p">,</span> <span class="n">digits</span><span class="o">.</span><span class="n">target</span>
<span class="n">clf_d</span> <span class="o">=</span> <span class="n">daal4py</span><span class="o">.</span><span class="n">sklearn</span><span class="o">.</span><span class="n">svm</span><span class="o">.</span><span class="n">SVC</span><span class="p">(</span><span class="n">kernel</span><span class="o">=</span><span class="s1">'rbf'</span><span class="p">,</span> <span class="n">gamma</span><span class="o">=</span><span class="s1">'scale'</span><span class="p">,</span> <span class="n">C</span> <span class="o">=</span> <span class="mf">0.5</span><span class="p">)</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="n">clf_v</span> <span class="o">=</span> <span class="n">sklearn</span><span class="o">.</span><span class="n">svm</span><span class="o">.</span><span class="n">SVC</span><span class="p">(</span><span class="n">kernel</span><span class="o">=</span><span class="s1">'rbf'</span><span class="p">,</span> <span class="n">gamma</span><span class="o">=</span><span class="s1">'scale'</span><span class="p">,</span> <span class="n">C</span> <span class="o">=</span><span class="mf">0.5</span><span class="p">)</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="n">clf_d</span><span class="o">.</span><span class="n">score</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="c1"># output: 0.9905397885364496</span>
<span class="n">clf_v</span><span class="o">.</span><span class="n">score</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="c1"># output: 0.9905397885364496</span>
</pre></div>
</div>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="examples.html" class="btn btn-neutral float-left" title="Examples" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright Intel.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>