scikit-learn/sklearn/svm/sparse/base.py

24 lines
829 B
Python
Raw Normal View History

import numpy as np
import scipy.sparse
2012-06-08 03:38:11 +08:00
from abc import ABCMeta, abstractmethod
from ..base import BaseLibSVM
class SparseBaseLibSVM(BaseLibSVM):
2012-06-08 03:38:11 +08:00
__metaclass__ = ABCMeta
@abstractmethod
def __init__(self, impl, kernel, degree, gamma, coef0,
tol, C, nu, epsilon, shrinking, probability, cache_size,
2012-10-06 06:41:43 +08:00
class_weight, verbose, max_iter):
super(SparseBaseLibSVM, self).__init__(impl, kernel, degree, gamma,
coef0, tol, C, nu, epsilon, shrinking, probability, cache_size,
2012-10-06 06:41:43 +08:00
True, class_weight, verbose, max_iter)
def fit(self, X, y, sample_weight=None):
X = scipy.sparse.csr_matrix(X, dtype=np.float64)
return super(SparseBaseLibSVM, self).fit(X, y,
sample_weight=sample_weight)