I have been puzzled this morning on how slowly the SVM model to learn a binary classification. The training time used to way faster a few days ago.

This led me to suspect that there is a bug in my code, and there is one.

I refactored my code, and one common I usually do is to make sure that all matrices are stored as the same type. If they are sparse, the rest must be sparse. If they are an array, the rest should follow it.

Since I am developing a new model, storing data as 2d array is the most convenient because I can easily look up, slice, and calculate a few statistics.

That is why I train the SVM model (LIBSVM) by passing a huge 2D array with many zeros. By passing a huge array, LIBSVM took very long time to train a binary classifier. So once, I turned the 2d array to a sparse matrix, SVM training is now fast again.

Glad, I found it.

### Like this:

Like Loading...