Skip to content

Commit

Permalink
change the kernel parameters to be the same as libsvm in scikit inter…
Browse files Browse the repository at this point in the history
…face
  • Loading branch information
QinbinLi committed Jul 3, 2018
1 parent 0b4648e commit 82443c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ class SVR(kernel = 2, degree = 3, gamma = 'auto', coef0 = 0.0, C = 1.0, epsilon


### Parameters
*kernel*: int, optional(default=2)\
*kernel*: string, optional(default='rbf')\
set type of kernel function\
0 -- linear: u'\*v\
1 -- polynomial: (gamma\*u'\*v + coef0)^degree\
2 -- radial basis function: exp(-gamma\*|u-v|^2)\
3 -- sigmoid: tanh(gamma\*u'\*v + coef0)\
4 -- precomputed kernel (kernel values in training_set_file)
'linear': u'\*v\
'polynomial': (gamma\*u'\*v + coef0)^degree\
'rbf': exp(-gamma\*|u-v|^2)\
'sigmoid': tanh(gamma\*u'\*v + coef0)\
'precomputed' -- precomputed kernel (kernel values in training_set_file)

*degree*: int, optional(default=3)\
set degree in kernel function
Expand Down
3 changes: 2 additions & 1 deletion python/thundersvmScikit.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
exit()

SVM_TYPE = ['c_svc', 'nu_svc', 'one_class', 'epsilon_svr', 'nu_svr']
KERNEL_TYPE = ['linear', 'polynomial', 'rbf', 'sigmoid', 'precomputed']

class SvmModel(ThundersvmBase):
def __init__(self, kernel, degree,
Expand Down Expand Up @@ -92,7 +93,7 @@ def fit(self, X, y):
else:
self._gamma = self.gamma

kernel = self.kernel
kernel = KERNEL_TYPE.index(self.kernel)

fit = self._sparse_fit if self._sparse else self._dense_fit
self.model = thundersvm.model_new(solver_type)
Expand Down

0 comments on commit 82443c0

Please sign in to comment.