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
Copy file name to clipboardExpand all lines: AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_SKLearn_GettingStarted/readme.md
+47-66Lines changed: 47 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Intel® Python Scikit-learn Extension Getting Started Sample
2
2
3
-
The `Intel® Python Scikit-learn Extension Getting Started` sample demonstrates how to use a support vector machine classifier from Intel® Extension for Scikit-learn* for digit recognition problem. All other machine learning algorithms available with Scikit-learn can be used in the similar way. Intel® Extension for Scikit-learn* speeds up scikit-learn applications. The acceleration is achieved through the use of the Intel® oneAPI Data Analytics Library (oneDAL) [Intel oneAPI Data Analytics Library](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onedal.html).
3
+
The `Intel® Python Scikit-learn Extension Getting Started` sample demonstrates how to use a support vector machine classifier from Intel® Extension for Scikit-learn* for digit recognition problem. All other machine learning algorithms available with Scikit-learn can be used in the similar way. Intel® Extension for Scikit-learn* speeds up scikit-learn applications. The acceleration is achieved through the use of the Intel® oneAPI Data Analytics Library (oneDAL) [Intel oneAPI Data Analytics Library](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onedal.html), which comes with [Intel® AI Analytics Toolkit (AI Kit)](https://software.intel.com/content/www/us/en/develop/tools/oneapi/ai-analytics-toolkit.html).
| What you will learn | How to use a basic Intel® Extension for Scikit-learn* programming model for Intel CPUs
10
10
| Time to complete | 5 minutes
11
11
12
+
13
+
## Purpose
14
+
15
+
In this sample, you will run a support vector classifier model from sklearn with oneDAL Daal4py library memory objects. You will also learn how to train a model and save the information to a file. Intel® Extension for Scikit-learn* depends on Intel® Daal4py. Daal4py is a simplified API to oneDAL that allows for fast usage of the framework suited for Data Scientists or Machine Learning users. Built to help provide an abstraction to oneDAL for direct usage or integration into one's own framework.
12
16
## Prerequisites
13
17
14
18
| Optimized for | Description
@@ -22,35 +26,13 @@ You can refer to the oneAPI [product page](https://software.intel.com/en-us/onea
22
26
23
27
oneDAL is ready for use once you finish the AI Kit installation and have run the post installation script.
24
28
25
-
## Purpose
26
-
27
-
In this sample, you will run a support vector classifier model from sklearn with oneDAL Daal4py library memory objects. You will also learn how to train a model and save the information to a file. Intel® Extension for Scikit-learn* depends on Intel® Daal4py. Daal4py is a simplified API to oneDAL that allows for fast usage of the framework suited for Data Scientists or Machine Learning users. Built to help provide an abstraction to oneDAL for direct usage or integration into one's own framework.
28
29
29
30
## Key Implementation Details
30
31
31
-
This Getting Started sample code is implemented for CPU using the Python language. Intel® Extension for Scikit-learn* is available as a part of Intel® AI Tools.
32
-
33
-
You will need to download and install the following toolkits, tools, and components to use the sample.
32
+
This Getting Started sample code is implemented for CPU using the Python language. The example assumes you have Intel® Extension for Scikit-learn* installed inside a conda environment, similar to what is delivered with the installation of the Intel® Distribution for Python* as part of the [Intel® AI Analytics Toolkit](https://software.intel.com/en-us/oneapi/ai-kit). Intel® Extension for Scikit-learn* is available as a part of Intel® AI Analytics Toolkit (AI kit).
34
33
35
-
**1. Get Intel® AI Tools**
34
+
## Environment Setup
36
35
37
-
Required AI Tools: Intel® Extension for Scikit-learn*
38
-
<br>If you have not already, select and install these Tools via [AI Tools Selector](https://www.intel.com/content/www/us/en/developer/tools/oneapi/ai-tools-selector.html). AI and Analytics samples are validated on AI Tools Offline Installer. It is recommended to select Offline Installer option in AI Tools Selector.
39
-
40
-
**2. Install dependencies**
41
-
```
42
-
pip install -r requirements.txt
43
-
```
44
-
**Install Jupyter Notebook** by running `pip install notebook`. Alternatively, see [Installing Jupyter](https://jupyter.org/install) for detailed installation instructions.
45
-
46
-
## Run the Sample
47
-
>**Note**: Before running the sample, make sure [Environment Setup](https://github.com/oneapi-src/oneAPI-samples/tree/master/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_SKLearn_GettingStarted#environment-setup) is completed.
48
-
Go to the section which corresponds to the installation method chosen in [AI Tools Selector](https://www.intel.com/content/www/us/en/developer/tools/oneapi/ai-tools-selector.html) to see relevant instructions:
1. If you have not already done so, activate the AI Tools bundle base environment. If you used the default location to install AI Tools, open a terminal and type the following
cd oneapi-samples/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_SKLearn_GettingStarted
49
+
source activate base
50
+
pip install -r requirements.txt
70
51
```
71
52
72
-
4. Launch Jupyter Notebook:
73
-
> **Note**: You might need to register Conda kernel to Jupyter Notebook kernel,
74
-
feel free to check [the instruction](https://github.com/IntelAI/models/tree/master/docs/notebooks/perf_analysis#option-1-conda-environment-creation)
75
-
```
76
-
jupyter notebook --ip=0.0.0.0
53
+
2a. Activate Conda without Root Access (Optional)
54
+
55
+
By default, the Intel® AI Analytics Toolkit is installed in the inteloneapi folder, which requires root privileges to manage it. If you would like to bypass using root access to manage your conda environment, then you can clone and activate your desired conda environment using the following commands.
77
56
```
78
-
<!-- add other flags to jupyter notebook command if needed, such as port 8888 or allow-root -->
79
-
5. Follow the instructions to open the URL with the token in your browser.
80
-
6. Select the Notebook:
57
+
conda create --name usr_intelpython --clone base
58
+
source activate usr_intelpython
81
59
```
82
-
Intel_Extension_For_SKLearn_GettingStarted.ipynb
60
+
3. Clone the GitHub repository
83
61
```
84
-
7. Change the kernel to sklearnex
85
-
86
-
8. Run every cell in the Notebook in sequence.
87
-
88
-
### Conda/PIP
89
-
> **Note**: Make sure your Conda/Python environment with AI Tools installed is activated
cd oneapi-samples/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_SKLearn_GettingStarted
94
-
```
95
-
2. Launch Jupyter Notebook:
96
-
> **Note**: You might need to register Conda kernel to Jupyter Notebook kernel,
97
-
feel free to check [the instruction](https://github.com/IntelAI/models/tree/master/docs/notebooks/perf_analysis#option-1-conda-environment-creation)
98
-
```
99
-
jupyter notebook --ip=0.0.0.0
100
-
```
101
-
<!-- add other flags to jupyter notebook command if needed, such as port 8888 or allow-root -->
102
-
4. Follow the instructions to open the URL with the token in your browser.
103
-
5. Select the Notebook:
104
-
```
105
-
Intel_Extension_For_SKLearn_GettingStarted.ipynb
63
+
cd oneapi-samples/AI-and-Analytics/Getting-Started-Samples
106
64
```
107
65
108
-
6. Run every cell in the Notebook in sequence.
66
+
### Install Jupyter Notebook
67
+
68
+
1. Change to the sample directory.
69
+
2. Install Jupyter Notebook with the proper kernel.
70
+
```
71
+
conda install jupyter nb_conda_kernels
72
+
```
73
+
74
+
#### View in Jupyter Notebook
75
+
76
+
>**Note**: This distributed execution cannot be launched from Jupyter Notebook, but you can still view inside the notebook to follow the included write-up and description.
77
+
78
+
1. Change to the sample directory.
79
+
2. Launch Jupyter Notebook.
80
+
```
81
+
jupyter notebook
82
+
```
83
+
3. Locate and select the Notebook.
84
+
```
85
+
Intel_Extension_For_SKLearn_GettingStarted.ipynb
86
+
```
87
+
4. Click the **Run** button to move through the cells in sequence.
88
+
89
+
90
+
#### Troubleshooting
109
91
110
-
### Docker
111
-
AI Tools Docker images already have Get Started samples pre-installed. Refer to [Working with Preset Containers](https://github.com/intel/ai-containers/tree/main/preset) to learn how to run the docker and samples.
92
+
If you receive an error message, troubleshoot the problem using the **Diagnostics Utility for Intel® oneAPI Toolkits**. The diagnostic utility provides configuration and system checks to help find missing dependencies, permissions errors, and other issues. See the *[Diagnostics Utility for Intel® oneAPI Toolkits User Guide](https://www.intel.com/content/www/us/en/develop/documentation/diagnostic-utility-user-guide/top.html)* for more information on using the utility.
112
93
113
94
## Example Output
114
95
@@ -127,7 +108,7 @@ Model accuracy on test data: 0.9833333333333333
0 commit comments