## Evaluating and optimizing the model

This section will show you how to evaluate the performance of our recommender. Starting from the evaluation, we can try some parameter configurations and choose the one performing the best. For more details, see Chapter 4, *Evaluating the Recommender Systems*.

The following are the steps to evaluate and optimize the model:

Let's go through these steps in detail.

### Building a function to evaluate the model

This section will show you how to define a function that:

Sets up cross validation using the *k*-fold.

Builds a hybrid IBCF.

Recommends the items to the users in the test sets.

Evaluates the recommendation.

The inputs of our function are as follows:

**Data**: This is the rating matrix table with the item description

**k-fold parameters**: This is the number of folds, the number of items to keep in the test set

**Model parameters...**