class_docstr: Base class for estimators that use libsvm as backing library
  
  This implements support vector machine classification and regression.
  
  Parameter documentation is in the derived `SVC` class.
class_docstr_tok: ["Base","class","for","estimators","that","use","libsvm","as","backing","library","This","implements","support","vector","machine","classification","and","regression",".","Parameter","documentation","is","in","the","derived","`","SVC","`","class","."]
docstr: Fit the SVM model according to the given training data.
  
  Parameters
  ----------
  X : {array-like, sparse matrix}, shape (n_samples, n_features)
      Training vectors, where n_samples is the number of samples
      and n_features is the number of features.
      For kernel="precomputed", the expected shape of X is
      (n_samples, n_samples).
  
  y : array-like, shape (n_samples,)
      Target values (class labels in classification, real numbers in
      regression)
  
  sample_weight : array-like, shape (n_samples,)
      Per-sample weights. Rescale C per sample. Higher weights
      force the classifier to put more emphasis on these points.
  
  Returns
  -------
  self : object
      Returns self.
  
  Notes
  ------
  If X and y are not C-ordered and contiguous arrays of np.float64 and
  X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
  
  If X is a dense array, then the other methods will not support sparse
  matrices as input.
docstr_tok: ["Fit","the","SVM","model","according","to","the","given","training","data",".","Parameters","--","--","--","--","--","X",":","{","array-like",",","sparse","matrix","}",",","shape","(","n_samples",",","n_features",")","Training","vectors",",","where","n_samples","is","the","number","of","samples","and","n_features","is","the","number","of","features",".","For","kernel=","''","precomputed","''",",","the","expected","shape","of","X","is","(","n_samples",",","n_samples",")",".","y",":","array-like",",","shape","(","n_samples",",",")","Target","values","(","class","labels","in","classification",",","real","numbers","in","regression",")","sample_weight",":","array-like",",","shape","(","n_samples",",",")","Per-sample","weights",".","Rescale","C","per","sample",".","Higher","weights","force","the","classifier","to","put","more","emphasis","on","these","points",".","Returns","--","--","--","-","self",":","object","Returns","self",".","Notes","--","--","--","If","X","and","y","are","not","C-ordered","and","contiguous","arrays","of","np.float64","and","X","is","not","a","scipy.sparse.csr_matrix",",","X","and\/or","y","may","be","copied",".","If","X","is","a","dense","array",",","then","the","other","methods","will","not","support","sparse","matrices","as","input","."]
code: def fit(self, X, y, sample_weight=None):
      """Fit the SVM model according to the given training data.
  
      Parameters
      ----------
      X : {array-like, sparse matrix}, shape (n_samples, n_features)
          Training vectors, where n_samples is the number of samples
          and n_features is the number of features.
          For kernel="precomputed", the expected shape of X is
          (n_samples, n_samples).
  
      y : array-like, shape (n_samples,)
          Target values (class labels in classification, real numbers in
          regression)
  
      sample_weight : array-like, shape (n_samples,)
          Per-sample weights. Rescale C per sample. Higher weights
          force the classifier to put more emphasis on these points.
  
      Returns
      -------
      self : object
          Returns self.
  
      Notes
      ------
      If X and y are not C-ordered and contiguous arrays of np.float64 and
      X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
  
      If X is a dense array, then the other methods will not support sparse
      matrices as input.
      """
  
      rnd = check_random_state(self.random_state)
  
      sparse = sp.isspmatrix(X)
      if sparse and self.kernel == "precomputed":
          raise TypeError(
              "Sparse precomputed kernels are not supported."
          )
      self._sparse = sparse and not callable(self.kernel)
  
      X, y = check_X_y(
          X, y, dtype=np.float64, order="C", accept_sparse="csr"
      )
      y = self._validate_targets(y)
  
      sample_weight = np.asarray(
          [] if sample_weight is None else sample_weight,
          dtype=np.float64,
      )
      solver_type = LIBSVM_IMPL.index(self._impl)
  
      # input validation
      if solver_type != 2 and X.shape[0] != y.shape[0]:
          raise ValueError(
              "X and y have incompatible shapes.\n"
              + "X has %s samples, but y has %s."
              % (X.shape[0], y.shape[0])
          )
  
      if self.kernel == "precomputed" and X.shape[0] != X.shape[1]:
          raise ValueError("X.shape[0] should be equal to X.shape[1]")
  
      if (
          sample_weight.shape[0] > 0
          and sample_weight.shape[0] != X.shape[0]
      ):
          raise ValueError(
              "sample_weight and X have incompatible shapes: "
              "%r vs %r\n"
              "Note: Sparse matrices cannot be indexed w/"
              "boolean masks (use `indices=True` in CV)."
              % (sample_weight.shape, X.shape)
          )
  
      if self.gamma == "auto":
          self._gamma = 1.0 / X.shape[1]
      else:
          self._gamma = self.gamma
  
      kernel = self.kernel
      if callable(kernel):
          kernel = "precomputed"
  
      fit = self._sparse_fit if self._sparse else self._dense_fit
      if self.verbose:  # pragma: no cover
          print("[LibSVM]", end="")
  
      seed = rnd.randint(np.iinfo("i").max)
      fit(X, y, sample_weight, solver_type, kernel, random_seed=seed)
      # see comment on the other call to np.iinfo in this file
  
      self.shape_fit_ = X.shape
  
      # In binary case, we need to flip the sign of coef, intercept and
      # decision function. Use self._intercept_ and self._dual_coef_ internally.
      self._intercept_ = self.intercept_.copy()
      self._dual_coef_ = self.dual_coef_
      if self._impl in ["c_svc", "nu_svc"] and len(self.classes_) == 2:
          self.intercept_ *= -1
          self.dual_coef_ = -self.dual_coef_
  
      return self
  
imports: from __future__ import print_function
  import numpy
  import scipy.sparse
  import warnings
  from abc import ABCMeta, abstractmethod
  from .None import libsvm, liblinear
  from .None import libsvm_sparse
  from ..base import BaseEstimator, ClassifierMixin
  from ..preprocessing import LabelEncoder
  from ..utils.multiclass import _ovr_decision_function
  from ..utils import check_array, check_consistent_length, check_random_state
  from ..utils import column_or_1d, check_X_y
  from ..utils import compute_class_weight, deprecated
  from ..utils.extmath import safe_sparse_dot
  from ..utils.validation import check_is_fitted
  from ..utils.multiclass import check_classification_targets
  from ..externals import six
  from ..exceptions import ChangedBehaviorWarning
  from ..exceptions import ConvergenceWarning
  from ..exceptions import NotFittedError
label_desc: Use image node_id 3 for calling the BaseLibSVM obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self