Skip to content

Commit 3a64b1a

Browse files
authored
template 2024.1 (#2244)
* Update README.md Changes by Stefana Raileanu * Update README.md environment setup template instructions
1 parent 0445d8c commit 3a64b1a

File tree

1 file changed

+80
-55
lines changed
  • AI-and-Analytics/Getting-Started-Samples/IntelPython_XGBoost_GettingStarted

1 file changed

+80
-55
lines changed
Lines changed: 80 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# `Intel® Python XGBoost* Getting Started` Sample
1+
# Intel® Python XGBoost* Getting Started Sample
22

33
The `Intel® Python XGBoost* Getting Started` sample demonstrates how to set up and train an XGBoost model on datasets for prediction.
44

55
| Area | Description
66
| :--- | :---
7+
| Category | Getting Started
78
| What you will learn | The basics of XGBoost programming model for Intel CPUs
89
| Time to complete | 5 minutes
9-
| Category | Getting Started
1010

1111
## Purpose
1212

@@ -24,75 +24,93 @@ In this code sample, you will learn how to use Intel optimizations for XGBoost p
2424

2525
## Key Implementation Details
2626

27-
This Getting Started sample code is implemented for CPU using the Python language. The example assumes you have XGboost 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 Tools](https://software.intel.com/en-us/oneapi/ai-kit).
27+
- This Getting Started sample code is implemented for CPU using the Python language. The example assumes you have XGboost 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 Tools](https://software.intel.com/en-us/oneapi/ai-kit).
2828

29-
XGBoost* is ready for use once you finish the Intel® AI Tools installation and have run the post installation script.
29+
- XGBoost* is ready for use once you finish the Intel® AI Tools installation and have run the post installation script.
3030

31-
## Configure Environment (Only applicable to Intel AI Tools Offline Installer)
32-
If you have already set up the PIP or Conda environment and installed AI Tools go directly to Run the Notebook.
33-
> **Note**: If you have not already done so, set up your CLI
34-
> environment by sourcing the `setvars` script in the root of your oneAPI installation.
35-
>
36-
> Linux*:
37-
> - For system wide installations: `. /opt/intel/oneapi/setvars.sh`
38-
> - For private installations: ` . ~/intel/oneapi/setvars.sh`
39-
> - For non-POSIX shells, like csh, use the following command: `bash -c 'source <install-dir>/setvars.sh ; exec csh'`
40-
>
41-
> 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)*.
31+
## Environment Setup
4232

33+
You will need to download and install the following toolkits, tools, and components to use the sample.
4334

44-
### Activate Conda with Root Access
35+
**1. Get Intel® AI Tools**
4536

46-
If you activated another environment, you can return with the following command:
47-
```
48-
source activate base
49-
```
50-
### Activate Conda without Root Access (Optional)
37+
Required AI Tools: Intel® Optimization for XGBoost*
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.
5139

52-
By default, the Intel® AI Tools are 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 active your desired conda environment using the following commands:
40+
**2. Install dependencies**
5341
```
54-
conda create --name user_base --clone base
55-
source activate user_base
42+
pip install -r requirements.txt
5643
```
44+
**Install Jupyter Notebook** by running `pip install notebook`. Alternatively, see [Installing Jupyter](https://jupyter.org/install) for detailed installation instructions.
5745

58-
## Run the `Intel® Python XGBoost* Getting Started` Sample
59-
60-
### Install Jupyter Notebook
61-
62-
1. Change to the sample directory.
63-
2. Install Jupyter Notebook with an appropriate kernel.
64-
```
65-
conda install jupyter nb_conda_kernels
66-
```
67-
### Run Jupyter Notebook
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/IntelPython_XGBoost_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:
49+
* [AI Tools Offline Installer (Validated)](#ai-tools-offline-installer-validated)
50+
* [Conda/PIP](#condapip)
51+
* [Docker](#docker)
6852

69-
>**Note**: You cannot execute the sample in Jupyter Notebook, but you can still view inside the notebook to follow the included write-up and description.
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
55+
```
56+
source $HOME/intel/oneapi/intelpython/bin/activate
57+
```
58+
If you used a separate location, open a terminal and type the following
59+
```
60+
source <custom_path>/bin/activate
61+
```
62+
2. Activate the Conda environment:
63+
```
64+
conda activate xgboost
65+
```
66+
3. Clone the GitHub repository:
67+
```
68+
git clone https://github.com/oneapi-src/oneAPI-samples.git
69+
cd oneapi-samples/AI-and-Analytics/Getting-Started-Samples/IntelPython_XGBoost_GettingStarted
70+
```
7071

71-
1. Change to the sample directory.
72-
2. Launch Jupyter Notebook.
73-
```
74-
jupyter notebook
75-
```
76-
3. Locate and select the Notebook.
77-
```
78-
IntelPython_XGBoost_GettingStarted.ipynb
79-
```
80-
4. Click the **Run** button to move through the cells in sequence.
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+
IntelPython_XGBoost_GettingStarted.ipynb
83+
```
8184

82-
### Run the Python Script
85+
7. Change the kernel to xgboost
86+
87+
8. Run every cell in the Notebook in sequence.
8388

84-
1. Still in Jupyter Notebook.
89+
### Conda/PIP
90+
> **Note**: Make sure your Conda/Python environment with AI Tools installed is activated
91+
1. Clone the GitHub repository:
92+
```
93+
git clone https://github.com/oneapi-src/oneAPI-samples.git
94+
cd oneapi-samples/AI-and-Analytics/Getting-Started-Samples/IntelPython_XGBoost_GettingStarted
95+
```
96+
2. Launch Jupyter Notebook:
97+
> **Note**: You might need to register Conda kernel to Jupyter Notebook kernel,
98+
feel free to check [the instruction](https://github.com/IntelAI/models/tree/master/docs/notebooks/perf_analysis#option-1-conda-environment-creation)
99+
```
100+
jupyter notebook --ip=0.0.0.0
101+
```
102+
<!-- add other flags to jupyter notebook command if needed, such as port 8888 or allow-root -->
103+
4. Follow the instructions to open the URL with the token in your browser.
104+
5. Select the Notebook:
105+
```
106+
IntelPython_XGBoost_GettingStarted.ipynb
107+
```
108+
6. Run every cell in the Notebook in sequence.
85109

86-
2. Select **File** > **Download as** > **Python (py)**.
87-
3. Run the script.
88-
```
89-
python IntelPython_XGBoost_GettingStarted.py
90-
```
91-
The output files of the script will be saved in **models** and **result** directories.
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.
92112

93-
#### Troubleshooting
94113

95-
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.
96114

97115
## Example Output
98116

@@ -102,10 +120,17 @@ If you receive an error message, troubleshoot the problem using the **Diagnostic
102120
RMSE: 11.113036205909719
103121
[CODE_SAMPLE_COMPLETED_SUCCESFULLY]
104122
```
123+
## Related Samples
124+
125+
* [Intel® Python XGBoost Daal4py Prediction](https://github.com/oneapi-src/oneAPI-samples/tree/master/AI-and-Analytics/Features-and-Functionality/IntelPython_XGBoost_daal4pyPrediction)
126+
* [Intel® Python Scikit-learn Extension Getting Started](https://github.com/oneapi-src/oneAPI-samples/tree/master/AI-and-Analytics/Getting-Started-Samples/Intel_Extension_For_SKLearn_GettingStarted)
127+
105128

106129
## License
107130

108131
Code samples are licensed under the MIT license. See
109132
[License.txt](https://github.com/oneapi-src/oneAPI-samples/blob/master/License.txt) for details.
110133

111134
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).
135+
136+
*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

Comments
 (0)