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
# 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), which comes with [Intel® AI Analytics Toolkit (AI Kit)](https://software.intel.com/content/www/us/en/develop/tools/oneapi/ai-analytics-toolkit.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).
4
4
5
5
6
6
| Area | Description
7
7
|:--- | :---
8
+
| Category | Getting Started
8
9
| What you will learn | How to use a basic Intel® Extension for Scikit-learn* programming model for Intel CPUs
9
10
| Time to complete | 5 minutes
10
-
| Category | Getting Started
11
11
12
12
## Prerequisites
13
13
@@ -28,113 +28,87 @@ In this sample, you will run a support vector classifier model from sklearn with
28
28
29
29
## Key Implementation Details
30
30
31
-
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).
32
-
33
-
## Configure the Local Environment
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.
34
32
35
-
> **Note**: If you have not already done so, set up your CLI
36
-
> environment by sourcing the `setvars` script in the root of your oneAPI installation.
37
-
>
38
-
> Linux*:
39
-
> - For system wide installations: `. /opt/intel/oneapi/setvars.sh`
40
-
> - For private installations: ` . ~/intel/oneapi/setvars.sh`
41
-
> - For non-POSIX shells, like csh, use the following command: `bash -c 'source <install-dir>/setvars.sh ; exec csh'`
42
-
>
43
-
> For more information on configuring environment variables, see *[Use the setvars Script with Linux* or macOS*](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup/use-the-setvars-script-with-linux-or-macos.html)*.
33
+
You will need to download and install the following toolkits, tools, and components to use the sample.
44
34
45
-
### On Linux*
35
+
**1. Get Intel® AI Tools**
46
36
47
-
#### Activate Conda with Root Access
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.
48
39
49
-
Intel Python environment will be active by default. However, if you activated another environment, you can return with the following command.
40
+
**2. Install dependencies**
50
41
```
51
-
source activate base
52
42
pip install -r requirements.txt
53
43
```
44
+
**Install Jupyter Notebook** by running `pip install notebook`. Alternatively, see [Installing Jupyter](https://jupyter.org/install) for detailed installation instructions.
54
45
55
-
#### Activate Conda without Root Access (Optional)
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:
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.
53
+
### AI Tools Offline Installer (Validated)
54
+
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
61
70
```
62
71
63
-
### Install Jupyter Notebook
64
-
65
-
1. Change to the sample directory.
66
-
2. Install Jupyter Notebook with the proper kernel.
67
-
```
68
-
conda install jupyter nb_conda_kernels
69
-
```
70
-
71
-
#### View in Jupyter Notebook
72
-
73
-
>**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.
74
-
75
-
1. Change to the sample directory.
76
-
2. Launch Jupyter Notebook.
77
-
```
78
-
jupyter notebook
79
-
```
80
-
3. Locate and select the Notebook.
81
-
```
82
-
Intel_Extension_For_SKLearn_GettingStarted.ipynb
83
-
```
84
-
4. Click the **Run** button to move through the cells in sequence.
85
-
86
-
87
-
#### Troubleshooting
88
-
89
-
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.
90
-
91
-
92
-
### Run the Sample on Intel® DevCloud (Optional)
93
-
94
-
1. If you do not already have an account, request an Intel® DevCloud account at [*Create an Intel® DevCloud Account*](https://intelsoftwaresites.secure.force.com/DevCloud/oneapi).
95
-
2. On a Linux* system, open a terminal.
96
-
3. SSH into Intel® DevCloud.
97
-
```
98
-
ssh DevCloud
99
-
```
100
-
> **Note**: You can find information about configuring your Linux system and connecting to Intel DevCloud at Intel® DevCloud for oneAPI [Get Started](https://devcloud.intel.com/oneapi/get_started).
101
-
102
-
#### Run the Notebook
103
-
104
-
1. Locate and select the Notebook.
105
-
```
106
-
Intel_Extension_For_SKLearn_GettingStarted.ipynb
107
-
````
108
-
2. Run every cell in the Notebook in sequence.
109
-
110
-
#### Run the Python Script
111
-
112
-
1. Change to the sample directory.
113
-
2. Configure the sample for the appropriate node.
114
-
<details>
115
-
<summary>You can specify nodes using a single line script.</summary>
116
-
117
-
```
118
-
qsub -I -l nodes=1:xeon:ppn=2 -d .
119
-
```
120
-
121
-
- `-I` (upper case I) requests an interactive session.
122
-
- `-l nodes=1:xeon:ppn=2` (lower case L) assigns one full GPU node.
123
-
- `-d .` makes the current folder as the working directory for the task.
124
-
125
-
|Available Nodes |Command Options
126
-
|:--- |:---
127
-
|GPU |`qsub -l nodes=1:gpu:ppn=2 -d .`
128
-
|CPU |`qsub -l nodes=1:xeon:ppn=2 -d .`
129
-
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
77
+
```
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:
81
+
```
82
+
Intel_Extension_For_SKLearn_GettingStarted.ipynb
83
+
```
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
106
+
```
130
107
131
-
>**Note**: For more information on how to specify compute nodes read *[Launch and manage jobs](https://devcloud.intel.com/oneapi/documentation/job-submission/)* in the Intel® DevCloud Documentation.
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.
138
112
139
113
## Example Output
140
114
@@ -150,9 +124,16 @@ Model accuracy on test data: 0.9833333333333333
Code samples are licensed under the MIT license. See
156
135
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details.
157
136
158
137
Third party program Licenses can be found here: [third-party-programs.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/third-party-programs.txt).
138
+
139
+
*Other names and brands may be claimed as the property of others. [Trademarks](https://www.intel.com/content/www/us/en/legal/trademarks.html)
0 commit comments