2010-09-28 20:04:29 +08:00
|
|
|
import numpy as np
|
2011-11-07 18:03:14 +08:00
|
|
|
import scipy.sparse
|
2012-06-08 03:38:11 +08:00
|
|
|
from abc import ABCMeta, abstractmethod
|
2010-09-28 20:04:29 +08:00
|
|
|
|
2012-01-20 06:39:06 +08:00
|
|
|
from ..base import BaseLibSVM
|
2010-10-26 13:51:54 +08:00
|
|
|
|
2011-02-06 02:27:03 +08:00
|
|
|
|
2010-09-28 20:04:29 +08:00
|
|
|
class SparseBaseLibSVM(BaseLibSVM):
|
2012-06-08 03:38:11 +08:00
|
|
|
__metaclass__ = ABCMeta
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
2011-05-13 15:44:03 +08:00
|
|
|
def __init__(self, impl, kernel, degree, gamma, coef0,
|
2011-11-12 05:43:03 +08:00
|
|
|
tol, C, nu, epsilon, shrinking, probability, cache_size,
|
2012-10-06 06:41:43 +08:00
|
|
|
class_weight, verbose, max_iter):
|
2010-12-07 19:18:07 +08:00
|
|
|
|
2011-10-09 10:11:10 +08:00
|
|
|
super(SparseBaseLibSVM, self).__init__(impl, kernel, degree, gamma,
|
2011-12-18 19:45:58 +08:00
|
|
|
coef0, tol, C, nu, epsilon, shrinking, probability, cache_size,
|
2012-10-06 06:41:43 +08:00
|
|
|
True, class_weight, verbose, max_iter)
|
2010-09-28 20:04:29 +08:00
|
|
|
|
2012-02-07 07:24:02 +08:00
|
|
|
def fit(self, X, y, sample_weight=None):
|
2012-01-20 06:39:06 +08:00
|
|
|
X = scipy.sparse.csr_matrix(X, dtype=np.float64)
|
2012-09-03 02:42:50 +08:00
|
|
|
return super(SparseBaseLibSVM, self).fit(X, y,
|
|
|
|
|
sample_weight=sample_weight)
|