Felipe Polo
Felipe Polo

Reputation: 11

CatBoostRegressor with loss_function='Lq'

I am not sure how to specify the "q" variable in the "Lq" loss function. I receive the following error message:

CatBoostError: /src/catboost/catboost/private/libs/options/catboost_options.cpp:82: Param q is mandatory for Lq loss

My code is as follows:

from catboost import CatBoostRegressor
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
import numpy as np

# Generate an artificial regression dataset
X, y = make_regression(n_samples=1000, n_features=10, random_state=42)

# Split the dataset into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Create a CatBoostRegressor object
model = CatBoostRegressor(loss_function='Lq')

# Fit the model 
model.fit(X_train, y_train)

Upvotes: 0

Views: 340

Answers (1)

Roee Anuar
Roee Anuar

Reputation: 3438

For some loss functions, you will need to indicate extra parameters, you can specify them with ":" after the type of the loss function, for example:

model = CatBoostRegressor(loss_function='Lq:q=4')

In general, the parameters should be declared as such:

<Metric>[:<parameter 1>=<value>;..;<parameter N>=<value>]

For more information - Catboost Implemented metrics

Upvotes: 1

Related Questions