Question in Lab 1 model evaluation and selection

Hello dear community,

In this lab I see this loop going over nn.train_error and not also the nn.cv_error ? Can you please explain why ?

Thanks :pray:

Sorry, I don’t understand your question.

It looks to me like the loop considers both the training and validation sets.

The lengths of the training errors and cv errors will be the same. We don’t need to loop over them each separately.

1 Like

Hello TMosh !
Please why is their length the same ? Thanks

Because the length of those vectors is based on the number of models we are training - not the sizes of the training and validation sets.

# Loop over each model
for model in models_bc:
1 Like

Ah ! I get it ! We loop over the number of models right ! Thanks ! As I get it, the nn.train_error contains a list of train_error matrixes am I right ?

It contains the training error values for each model.

1 Like

May I know what is the type of these errors ? Is it a vector, a matrix like X_ train, a list, … I dont get it really well … ’

You can use the “shape” command to print the sizes of the data.

1 Like

Or you can inspect the code:

train_error = np.mean(yhat != y_bc_train)
nn_train_error.append(train_error)

This shows that train_error is a scalar, the result of computing the mean of a vector of 0’s and 1’s.

nn_train_error is a list of those scalars. It is initialized as a null list, then individual values are appended to it.

1 Like

I really appreciate it thank you so much TMosh !