'Fit the model according to the given training data.
Parameters
X : {array-like, sparse matrix}, shape = [n_samples, n_features]
Training vector, where n_samples in the number of samples and
n_features is the number of features.
y : array-like, shape = [n_samples]
Target vector relative to X
sample_weight : array-like, shape = [n_samples], optional
Array of weights that are assigned to individual
samples. If not provided,
then each sample is given unit weight.
Returns
self : object
Returns self.'

def fit(self, X, y, sample_weight=None):

    msg = "loss='%s'    has    been    deprecated    in    favor    of    loss='%s'    as    of    0.16.    Backward    compatibility    for    the    loss='%s'    will    be    removed    in    %s"
    if (self.loss in ('l1', 'l2')):
        old_loss = self.loss
        self.loss = {'l1': 'hinge', 'l2': 'squared_hinge'}.get(self.loss)
        warnings.warn((msg % (old_loss, self.loss, old_loss, '1.0')), DeprecationWarning)
    if (self.C < 0):
        raise ValueError(('Penalty    term    must    be    positive;    got    (C=%r)' % self.C))
    (X, y) = check_X_y(X, y, accept_sparse='csr', dtype=np.float64, order='C')
    check_classification_targets(y)
    self.classes_ = np.unique(y)
    (self.coef_, self.intercept_, self.n_iter_) = _fit_liblinear(X, y, self.C, self.fit_intercept, self.intercept_scaling, self.class_weight, self.penalty, self.dual, self.verbose, self.max_iter, self.tol, self.random_state, self.multi_class, self.loss, sample_weight=sample_weight)
    if ((self.multi_class == 'crammer_singer') and (len(self.classes_) == 2)):
        self.coef_ = (self.coef_[1] - self.coef_[0]).reshape(1, (-1))
        if self.fit_intercept:
            intercept = (self.intercept_[1] - self.intercept_[0])
            self.intercept_ = np.array([intercept])
    return self
