How to find optimal parameters for CatBoost using GridSearchCV for Regression?

How to find optimal parameters for CatBoost using GridSearchCV for Regression?

How to find optimal parameters for CatBoost using GridSearchCV for Regression?

This recipe helps you find optimal parameters for CatBoost using GridSearchCV for Regression

In [1]:
def Snippet_199():
    print(format('How to find optimal parameters for CatBoost using GridSearchCV for Regression','*^82'))

    import warnings

    # load libraries
    from sklearn import datasets
    from sklearn.model_selection import train_test_split
    from sklearn.model_selection import GridSearchCV
    from catboost import CatBoostRegressor

    # load the iris datasets
    dataset = datasets.load_boston()
    X =; y =
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)

    model = CatBoostRegressor()
    parameters = {'depth'         : [6,8,10],
                  'learning_rate' : [0.01, 0.05, 0.1],
                  'iterations'    : [30, 50, 100]
    grid = GridSearchCV(estimator=model, param_grid = parameters, cv = 2, n_jobs=-1), y_train)

    # Results from Grid Search
    print(" Results from Grid Search " )
    print("\n The best estimator across ALL searched params:\n",
    print("\n The best score across ALL searched params:\n",
    print("\n The best parameters across ALL searched params:\n",
    print("\n ========================================================")

**How to find optimal parameters for CatBoost using GridSearchCV for Regression***
/Users/nilimesh/anaconda3/lib/python3.6/site-packages/sklearn/model_selection/ DeprecationWarning: The default of the `iid` parameter will change from True to False in version 0.22 and will be removed in 0.24. This will change numeric results when test-set sizes are unequal.
0:	learn: 24.3387613	total: 82.8ms	remaining: 2.4s
1:	learn: 24.1574633	total: 109ms	remaining: 1.53s
2:	learn: 23.9656719	total: 136ms	remaining: 1.23s
3:	learn: 23.7609700	total: 137ms	remaining: 894ms
4:	learn: 23.5788095	total: 164ms	remaining: 820ms
5:	learn: 23.3981448	total: 194ms	remaining: 776ms
6:	learn: 23.2204106	total: 221ms	remaining: 725ms
7:	learn: 23.0637082	total: 248ms	remaining: 683ms
8:	learn: 22.8991486	total: 275ms	remaining: 642ms
9:	learn: 22.7361343	total: 304ms	remaining: 609ms
10:	learn: 22.5820524	total: 332ms	remaining: 573ms
11:	learn: 22.4015054	total: 339ms	remaining: 509ms
12:	learn: 22.2254804	total: 365ms	remaining: 478ms
13:	learn: 22.0342073	total: 367ms	remaining: 419ms
14:	learn: 21.8495471	total: 368ms	remaining: 368ms
15:	learn: 21.6805878	total: 380ms	remaining: 333ms
16:	learn: 21.5233731	total: 407ms	remaining: 311ms
17:	learn: 21.3576118	total: 420ms	remaining: 280ms
18:	learn: 21.1949842	total: 445ms	remaining: 258ms
19:	learn: 21.0149778	total: 446ms	remaining: 223ms
20:	learn: 20.8692226	total: 473ms	remaining: 203ms
21:	learn: 20.7145938	total: 500ms	remaining: 182ms
22:	learn: 20.5647041	total: 531ms	remaining: 162ms
23:	learn: 20.4190385	total: 559ms	remaining: 140ms
24:	learn: 20.2797164	total: 586ms	remaining: 117ms
25:	learn: 20.1265513	total: 594ms	remaining: 91.4ms
26:	learn: 19.9603994	total: 620ms	remaining: 68.9ms
27:	learn: 19.8206477	total: 647ms	remaining: 46.2ms
28:	learn: 19.6781954	total: 674ms	remaining: 23.2ms
29:	learn: 19.5353669	total: 701ms	remaining: 0us

 Results from Grid Search

 The best estimator across ALL searched params:
 <catboost.core.CatBoostRegressor object at 0x1a2302af60>

 The best score across ALL searched params:

 The best parameters across ALL searched params:
 {'depth': 10, 'iterations': 30, 'learning_rate': 0.01}


Relevant Projects

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

Data Science Project-All State Insurance Claims Severity Prediction
Data science project in R to develop automated methods for predicting the cost and severity of insurance claims.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.