CatBoost Regression Model Training Function

  • Share this:

Code introduction


This function uses the CatBoost library to train a regression model. It accepts training data X_train and corresponding labels y_train as input and returns the trained model.


Technology Stack : CatBoost, NumPy

Code Type : The type of code

Code Difficulty : Intermediate


                
                    
import numpy as np
import catboost as cb

def train_catboost_model(X_train, y_train):
    # Initialize the CatBoost model
    model = cb.CatBoostRegressor(
        depth=5,
        learning_rate=0.1,
        boosting_type='gbdt',
        objective='RMSE'
    )
    
    # Train the model
    model.fit(X_train, y_train)
    
    return model                
              
Tags: