
- CatBoost - Home
- CatBoost - Overview
- CatBoost - Architecture
- CatBoost - Installation
- CatBoost - Features
- CatBoost - Decision Trees
- CatBoost - Boosting Process
- CatBoost - Core Parameters
- CatBoost - Data Preprocessing
- CatBoost - Handling Categorical Features
- CatBoost - Handling Missing Values
- CatBoost - Classifier
- CatBoost - Model Training
- CatBoost - Metrics for Model Evaluation
- CatBoost - Classification Metrics
- CatBoost - Over-fitting Detection
- CatBoost vs Other Boosting Algorithms
- CatBoost Useful Resources
- CatBoost - Quick Guide
- CatBoost - Useful Resources
- CatBoost - Discussion
CatBoost - Installation
CatBoost is very fast, scalable and an open source gradient-boosting on decision trees library from Yandex. Installing CatBoost can be done in different ways as per your operating system and development environment. In this chapter we are providing different ways to install CatBoost in your system. Here are some common methods:
Using pip (for Python)
This is the most common and simple eay to install CatBoost in your system. You can follow the below command on your terminal and it will download the library and install it in the system with its dependencies.
Open your command line or terminal and run the below command −
pip install catboost
Here is the process after running the above command on terminal or command prompt −
Collecting catboost Downloading catboost-1.2.7-cp312-cp312-macosx_11_0_universal2.whl.metadata (1.2 kB) Requirement already satisfied: graphviz in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from catboost) (0.20.3) Requirement already satisfied: matplotlib in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from catboost) (3.9.2) Collecting numpy=1.16.0 (from catboost) Downloading numpy-1.26.4-cp312-cp312-macosx_11_0_arm64.whl.metadata (61 kB) 61.1/61.1 kB 1.9 MB/s eta 0:00:00 Requirement already satisfied: pandas>=0.24 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from catboost) (2.2.2) Requirement already satisfied: scipy in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from catboost) (1.14.1) Collecting plotly (from catboost) Downloading plotly-5.24.1-py3-none-any.whl.metadata (7.3 kB) Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from catboost) (1.16.0) Requirement already satisfied: python-dateutil>=2.8.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas>=0.24->catboost) (2.8.2) Requirement already satisfied: pytz>=2020.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas>=0.24->catboost) (2024.1) Requirement already satisfied: tzdata>=2022.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas>=0.24->catboost) (2023.4) Requirement already satisfied: contourpy>=1.0.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from matplotlib->catboost) (1.3.0) Requirement already satisfied: cycler>=0.10 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from matplotlib->catboost) (0.12.1) Requirement already satisfied: fonttools>=4.22.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from matplotlib->catboost) (4.53.1) Requirement already satisfied: kiwisolver>=1.3.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from matplotlib->catboost) (1.4.7) Requirement already satisfied: packaging>=20.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from matplotlib->catboost) (24.1) Requirement already satisfied: pillow>=8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from matplotlib->catboost) (10.3.0) Requirement already satisfied: pyparsing>=2.3.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from matplotlib->catboost) (3.1.4) Collecting tenacity>=6.2.0 (from plotly->catboost) Downloading tenacity-9.0.0-py3-none-any.whl.metadata (1.2 kB) Downloading catboost-1.2.7-cp312-cp312-macosx_11_0_universal2.whl (27.0 MB) 27.0/27.0 MB 4.7 MB/s eta 0:00:0000:0100:01 Downloading numpy-1.26.4-cp312-cp312-macosx_11_0_arm64.whl (13.7 MB) 13.7/13.7 MB 3.6 MB/s eta 0:00:0000:0100:01 Downloading plotly-5.24.1-py3-none-any.whl (19.1 MB) 19.1/19.1 MB 4.7 MB/s eta 0:00:0000:0100:01 Downloading tenacity-9.0.0-py3-none-any.whl (28 kB) Installing collected packages: tenacity, numpy, plotly, catboost Attempting uninstall: numpy Found existing installation: numpy 2.1.1 Uninstalling numpy-2.1.1: Successfully uninstalled numpy-2.1.1 Successfully installed catboost-1.2.7 numpy-1.26.4 plotly-5.24.1 tenacity-9.0.0 [notice] A new release of pip is available: 24.0 -> 24.2 [notice] To update, run: pip install --upgrade pip Note: you may need to restart the kernel to use updated packages.
Using Conda (for Anaconda users)
If you are working with Anaconda or Miniconda then you can install CatBoost using Conda. When you run the below command it will download the necessary package and dependencies and install it in your system.
conda install -c conda-forge catboost
The terminal output would typically look like this −
(base) $ conda install -c conda-forge catboost Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /path/to/conda/environment added / updated specs: - catboost The following packages will be downloaded: package | build ------------------------------|----------------- catboost-1.1 | py38h9b699db_0 16.0 MB libcxx-11.1.0 | habf9029_0 1.3 MB libgfortran-5.4.0 | h6c81a4c_10 2.2 MB openmp-4.5 | h44a4d74_1 3.1 MB ------------------------------------------------------------ Total: 22.6 MB The following NEW packages will be INSTALLED: catboost conda-forge/osx-64::catboost-1.1-py38h9b699db_0 libcxx conda-forge/osx-64::libcxx-11.1.0-habf9029_0 libgfortran conda-forge/osx-64::libgfortran-5.4.0-h6c81a4c_10 openmp conda-forge/osx-64::openmp-4.5-h44a4d74_1 Proceed ([y]/n)? y Downloading and Extracting Packages catboost-1.1 | 16.0 MB | ########## | 100% libcxx-11.1.0 | 1.3 MB | ########## | 100% libgfortran-5.4.0 | 2.2 MB | ########## | 100% openmp-4.5 | 3.1 MB | ########## | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done
Building from Source
If you are an advanced user then you can build CatBoost from the source code if you want the latest version. So install CMake, Git, Python, and other build tools needed for your system. First you need to clone the CatBoost repository −
git clone https://github.com/catboost/catboost.git
Here is the terminal output −
$ git clone https://github.com/catboost/catboost.git Cloning into 'catboost'... remote: Enumerating objects: 345600, done. remote: Counting objects: 100% (2147/2147), done. remote: Compressing objects: 100% (1098/1098), done. remote: Total 345600 (delta 1345), reused 1623 (delta 1019), pack-reused 343453 Receiving objects: 100% (345600/345600), 297.60 MiB | 5.50 MiB/s, done. Resolving deltas: 100% (266248/266248), done.
After running the above command you have to navigate to the cloned directory −
cd catboost
Then build the project like below −
./ya make -r -DUSE_SYSTEM_PYTHON=1 catboost/python-package
The terminal output is as follows −
$ ./ya make -r -DUSE_SYSTEM_PYTHON=1 catboost/python-package Configuring the build... [INFO] [18:34:56] Project configuration complete [INFO] [18:34:57] Building CatBoost package... [INFO] [18:34:58] Running CMake... [INFO] [18:35:02] Generating build system... [INFO] [18:35:03] Build started... [ 10%] Building CXX object contrib/libs/oblivious_tree/CMakeFiles/oblivious_tree.dir/tree.cpp.o [ 20%] Building CXX object contrib/libs/model/CMakeFiles/model.dir/model.cpp.o [ 30%] Linking CXX static library libcatboostmodel.a [ 40%] Building wheel for Python package [ 60%] Linking CXX shared library libcatboost.so [ 80%] Generating Python bindings... [100%] Completed successfully
And lastly Install the package −
cd catboost/python-package pip install .
Here is the output for the above command after installing the package −
$ pip install . Processing /path/to/catboost/python-package Preparing metadata (setup.py) ... done Requirement already satisfied: numpy in /path/to/conda/env/lib/python3.8/site-packages (from catboost==1.1) (1.20.0) Requirement already satisfied: six in /path/to/conda/env/lib/python3.8/site-packages (from catboost==1.1) (1.15.0) Building wheels for collected packages: catboost Building wheel for catboost (setup.py) ... done Created wheel for catboost: filename=catboost-1.1-cp38-cp38-linux_x86_64.whl size=1234567 Stored in directory: /tmp/pip-ephem-wheel-cache-abcd1234 Successfully built catboost Installing collected packages: catboost Successfully installed catboost-1.1
Installing for R
If you want to use R programming language then you can install CatBoost for R using the below command. To run the command you just need to open R console or RStudio and then run the command −
install.packages('catboost', repos = 'https://cloud.r-project.org/', dependencies=TRUE)
So the command will install CatBoost for R programming.