wings
wings

Reputation: 418

How to calculate size of svm classifier in sklearn-python?

I am using LinearSVC from svm. I want to know how much memory the classifiers take after being trained.

from sklearn.svm import LinearSVC
clf_svm = LinearSVC()
clf_svm.fit(xtrain,ytrain)

I used sys.getsizeof but it always returns 56 as it doesn't take complexity of objects into consideration. Is there a way to calculate exact size the classifier takes in memory?

Upvotes: 2

Views: 1454

Answers (1)

Vivek Kumar
Vivek Kumar

Reputation: 36599

Just pickle the object and check the file size. No easy way otherwise.

Anyways, LinearSVC is a simple model which saves its learnt data into coef_ and intercept_ attributes. So you can check the memory taken by these two. The actual size will depend on the features in the data (X).

Other than that, the actual LinearSVC in scikit will also contain some info about the classes learnt, the parameters used to initialize etc.

Upvotes: 1

Related Questions