You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DOC: Showcase usage without patching in readme (#2411)
* mention usage without patching
* move unpatched examples to separate section
* add snippet also to online docs
* use tabs for different ways of showcasing usage
Copy file name to clipboardExpand all lines: README.md
+48-8Lines changed: 48 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,9 +59,11 @@ With Extension for Scikit-learn, you can:
59
59
60
60
## Optimizations
61
61
62
+
Easiest way to benefit from accelerations from the extension is by patching scikit-learn with it:
63
+
62
64
-**Enable CPU optimizations**
63
65
64
-
```py
66
+
```python
65
67
import numpy as np
66
68
from sklearnex import patch_sklearn
67
69
patch_sklearn()
@@ -77,7 +79,7 @@ With Extension for Scikit-learn, you can:
77
79
78
80
_Note: executing on GPU has [additional system software requirements](https://www.intel.com/content/www/us/en/developer/articles/system-requirements/intel-oneapi-dpcpp-system-requirements.html) - see [details](https://uxlfoundation.github.io/scikit-learn-intelex/latest/oneapi-gpu.html)._
79
81
80
-
```py
82
+
```python
81
83
import numpy as np
82
84
from sklearnex import patch_sklearn, config_context
83
85
patch_sklearn()
@@ -89,21 +91,50 @@ With Extension for Scikit-learn, you can:
89
91
with config_context(target_offload="gpu:0"):
90
92
clustering = DBSCAN(eps=3, min_samples=2).fit(X)
91
93
```
94
+
92
95
:eyes: Check out available [notebooks](https://github.com/uxlfoundation/scikit-learn-intelex/tree/master/examples/notebooks) for more examples.
93
96
97
+
### Usage without patching
98
+
99
+
Alternatively, all functionalities are also available under a separate module which can be imported directly, without involving any patching.
See all installation instructions in the [Installation Guide](https://github.com/uxlfoundation/scikit-learn-intelex/blob/main/INSTALL.md).
133
+
Package is also offered through other channels such as conda-forge. See all installation instructions in the [Installation Guide](https://github.com/uxlfoundation/scikit-learn-intelex/blob/main/INSTALL.md).
103
134
104
135
## Integration
105
136
106
-
The software acceleration isachieved through patching. It means, replacing the stock scikit-learn algorithms with their optimized versions provided by the extension.
137
+
The easiest way of accelerating scikit-learn workflows with the extension isthrough through [patching](https://uxlfoundation.github.io/scikit-learn-intelex/latest/quick-start.html#patching), which replaces the stock scikit-learn algorithms with their optimized versions provided by the extension using the same namespaces in the same modules as scikit-learn.
107
138
108
139
The patching only affects [supported algorithms and their parameters](https://uxlfoundation.github.io/scikit-learn-intelex/latest/algorithms.html).
109
140
You can still use not supported ones in your code, the package simply fallbacks into the stock version of scikit-learn.
@@ -112,16 +143,25 @@ You can still use not supported ones in your code, the package simply fallbacks
112
143
113
144
To patch scikit-learn, you can:
114
145
* Use the following command-line flag:
115
-
```
146
+
```shell
116
147
python -m sklearnex my_application.py
117
148
```
118
149
* Add the following lines to the script:
119
-
```
150
+
```python
120
151
from sklearnex import patch_sklearn
121
152
patch_sklearn()
122
153
```
123
154
124
-
:eyes: Read about [other ways to patch scikit-learn](https://uxlfoundation.github.io/scikit-learn-intelex/index.html#usage).
155
+
:eyes: Read about [other ways to patch scikit-learn](https://uxlfoundation.github.io/scikit-learn-intelex/latest/quick-start.html#patching).
156
+
157
+
As an alternative, accelerated classes from the extension can also be imported directly without patching, thereby allowing to keep them separate from stock scikit-learn ones -for example:
Note: executing on GPU has `additional system software requirements <https://www.intel.com/content/www/us/en/developer/articles/system-requirements/intel-oneapi-dpcpp-system-requirements.html>`__ - see :doc:`oneapi-gpu`.
71
84
72
-
::
85
+
.. tabs::
86
+
.. tab:: By patching
87
+
.. tabs::
88
+
.. tab:: By moving data to device
89
+
.. code-block:: python
90
+
91
+
import numpy as np
92
+
from sklearnex import patch_sklearn, config_context
0 commit comments