garydoranjr / misvm

Multiple-Instance Support Vector Machines
BSD 3-Clause "New" or "Revised" License
230 stars 81 forks source link

Problem: Rank(A) < p or Rank([P; A; G]) < n #15

Open gnawJ opened 6 years ago

gnawJ commented 6 years ago

Here is the problem I got:

Traceback (most recent call last): File "/Applications/PyCharm Edu.app/Contents/helpers/pydev/pydevd.py", line 1599, in globals = debugger.run(setup['file'], None, None, is_module) File "/Applications/PyCharm Edu.app/Contents/helpers/pydev/pydevd.py", line 1026, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/Users/chilab/PycharmProjects/MILSVM/mis_stress.py", line 87, in classifier.fit(X_train, y_train) File "/Users/chilab/src/misvm/misvm/sil.py", line 45, in fit super(SIL, self).fit(svm_X, svm_y) File "/Users/chilab/src/misvm/misvm/svm.py", line 68, in fit self.verbose) File "/Users/chilab/src/misvm/misvm/quadprog.py", line 106, in quadprog return qp.solve(verbose) File "/Users/chilab/src/misvm/misvm/quadprog.py", line 77, in solve raise e ValueError: Rank(A) < p or Rank([P; A; G]) < n

Thx!

garydoranjr commented 6 years ago

I've seen this error before if there are duplicate instances in the dataset. This can cause the matrix in the optimization program to be rank-deficient.

gnawJ commented 6 years ago

Thanks for the reply! Is it possible to turn off the optimization? Thx.

Also, I checked my dataset, it seems like there are no duplicated instances.

garydoranjr commented 6 years ago

No, the optimization cannot be turned off; it is fundamental to SVM classification: https://en.wikipedia.org/wiki/Support_vector_machine#Kernel_trick

It looks like the SVM code is being called by mis_stress.py (not in this repository). It is possible that however the data is manipulated by that code prior to calling the SIL fit method is leading to this issue.

eugeneyuchunlin commented 4 months ago

I have encountered the same issue in my implementation of SVM. I solve the problem by standardizing the data.