CatBoostReranker

class rectools.models.ranking.catboost_reranker.CatBoostReranker(model: Union[CatBoostClassifier, CatBoostRanker], fit_kwargs: Optional[Dict[str, Any]] = None, pool_kwargs: Optional[Dict[str, Any]] = None)[source]

Bases: Reranker

A reranker using CatBoost models for classification or ranking tasks.

This class supports both CatBoostClassifier and CatBoostRanker models to rerank candidates based on their features and optionally provided additional parameters for fitting and pool creation.

Inherited-members

Parameters
  • model (Union[CatBoostClassifier, CatBoostRanker]) –

  • fit_kwargs (Optional[Dict[str, Any]]) –

  • pool_kwargs (Optional[Dict[str, Any]]) –

Methods

fit(candidates_with_target)

Fit the CatBoost model using the given candidates with target data.

predict_scores(candidates)

Predict scores for the provided candidates using the fitted model.

prepare_fit_kwargs(candidates_with_target)

Prepare the keyword arguments for fitting the model, based on the provided candidates with targets.

prepare_training_pool(candidates_with_target)

Prepare a CatBoost Pool for training from the given candidates with target.

recommend(scored_pairs, k[, add_rank_col])

Generate top-k recommendations for each user based on the provided scores.

fit(candidates_with_target: DataFrame) None[source]

Fit the CatBoost model using the given candidates with target data.

This method prepares the training pool and fits the model using the specified fit parameters.

Parameters

candidates_with_target (pd.DataFrame) – DataFrame containing candidate features and target values, along with user and item identifiers.

Return type

None

prepare_training_pool(candidates_with_target: DataFrame) Pool[source]

Prepare a CatBoost Pool for training from the given candidates with target.

Depending on whether the model is a classifier or a ranker, the pool is prepared differently. For classifiers, only data and label are used. For rankers, group information is also included.

Parameters

candidates_with_target (pd.DataFrame) – DataFrame containing candidate features and target values, along with user and item identifiers.

Returns

A CatBoost Pool object ready for training.

Return type

Pool