3
$\begingroup$

Problem

fit_resample(X,y)

is taking too long to complete execution for 2million rows.

Dataset specifications

I have a labeled dataset about network features, where the X(features) and Y(labels) are of shape (2M, 24) and (2M,11) respectively.

i.e. there are over 2million rows in the dataset. there are 24 features, and 11 different classes/labels.

Both X and Y are numpy arrays of float dtype.

Motivation for using SVM SMOTE

Due to class imbalance, I realized SVM SMOTE is a good technique balance it, thereby, giving better classification.

Testing with smaller sub-datasets

To test the performance of my classifier, I started small. I made small subdatasets out of the big 2million row dataset.

It took the following code:-

%%time
sm = SVMSMOTE(random_state=42)
X_res, Y_res = sm.fit_resample(X, Y)

1st dataset contains only 7.5k rows. It took about 800ms to run the cell. 2nd dataset contains 115k rows. It took 20min to execute the cell.

Solution Attempts

My system crashes after running continuously for more than 48hrs, running out of memory.

I've tried some ideas, such as

1. splitting it to run on multiple CPU cores using %%px

No improvement in quicker execution

2. using NVIDIA GPU's

Same as above. Which is more understandable since the _smote.py library functions aren't built with parallel programming for CUDA in mind.

I'm pretty frustrated by the lack of results, and a warm PC. What should I do?

$\endgroup$
  • $\begingroup$ Try a linear SVM. It’s less complex. Also reducing your data set will help $\endgroup$ – Jon Apr 6 at 0:58
4
$\begingroup$

This is expected and is not related to SMOTE sampling.

The computational complexity of non-linear SVM is on the order of $O(n^2)$ to $O(n^3)$ where $n$ is the number of samples. This means that if it takes 0.8 seconds for 7.5K data points, it should take [3, 48] minutes for 115K, $$[(115/7.5)^{2} \times 0.8, (115/7.5)^{3} \times 0.8]s=[3,48]m,$$and from 16 hours to 175 days, 11 days for $O(n^{2.5})$, for 2M data points.

You should continue using sample sizes on the order of 100K or less. Also, it is fruitful to track the accuracy (or any other score) as a function of samples for 1K, 10K, 50K, and 100K samples. It is possible that SVM accuracy stops improving well before 100K, therefore, there will be not much to lose by limiting the samples to 100K or less.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.