thundersvm icon indicating copy to clipboard operation
thundersvm copied to clipboard

thundersvm.dense_model_scikit not parsing parameter?

Open civilinformer opened this issue 4 years ago • 3 comments

I am able to run thundersvm but under certain multithreaded environments I get this error:

lib/python3.6/site-packages/thundersvm-0.3.4-py3.6.egg/thundersvm/thundersvm.py", line 237, in _dense_fit n_classes, self._train_succeed, c_void_p(self.model)) ctypes.ArgumentError: argument 19: <class 'TypeError'>: Don't know how to convert parameter 19

I tried printing out parameter 19, which I believe is either just max_iter or n_jobs (depending on whether the count is from 1 or zero) and they are normal: self.max_iter, # 18 self.n_jobs, # 19

max_iter 3126 n_jobs 8

Any idea to why this might be failing?

civilinformer avatar Mar 11 '20 18:03 civilinformer

This fix worked:

       `c_int(self.max_iter), # 18
        c_int(self.n_jobs), # 19`

civilinformer avatar Mar 12 '20 13:03 civilinformer

Thanks for the feedback. It doesn't look like a common issue. Most of the users of ThunderSVM don't have this problem.

Would you explain the reason for the ctypes.ArgumentError? Usually, float type needs to be explicitly converted to c_float.

zeyiwen avatar Mar 13 '20 12:03 zeyiwen

I agree that it is a very rare enviroment where this occurs. Hopefully I have built something special then. In any case the fix occurred to me because I saw that there are other integer arguments to thundersvm.dense_model_scikit, including: weight_label = (c_int * weight_size)() n_features = (c_int * 1)() n_classes = (c_int * 1)() self._train_succeed = (c_int * 1)(). max_iter and n_jobs are integers, also, so it seems that they need to be converted to ctype integers to work properly. Maybe this is broken but you did not notice because the conversion is normally equivalent or ignored. Not sure what the default is here or how the library works. Just guessing.

civilinformer avatar Mar 13 '20 15:03 civilinformer