'Fit the calibrated model
Parameters
X : array-like, shape (n_samples, n_features)
Training data.
y : array-like, shape (n_samples,)
Target values.
sample_weight : array-like, shape = [n_samples] or None
Sample weights. If None, then samples are equally weighted.
Returns
self : object
Returns an instance of self.'

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

    (X, y) = check_X_y(X, y, accept_sparse=['csc', 'csr', 'coo'], force_all_finite=False)
    (X, y) = indexable(X, y)
    le = LabelBinarizer().fit(y)
    self.classes_ = le.classes_
    n_folds = (self.cv if isinstance(self.cv, int) else (self.cv.n_folds if hasattr(self.cv, 'n_folds') else None))
    if (n_folds and np.any([(np.sum((y == class_)) < n_folds) for class_ in self.classes_])):
        raise ValueError(('Requesting    %d-fold    cross-validation    but    provided    less    than    %d    examples    for    at    least    one    class.' % (n_folds, n_folds)))
    self.calibrated_classifiers_ = []
    if (self.base_estimator is None):
        base_estimator = LinearSVC(random_state=0)
    else:
        base_estimator = self.base_estimator
    if (self.cv == 'prefit'):
        calibrated_classifier = _CalibratedClassifier(base_estimator, method=self.method)
        if (sample_weight is not None):
            calibrated_classifier.fit(X, y, sample_weight)
        else:
            calibrated_classifier.fit(X, y)
        self.calibrated_classifiers_.append(calibrated_classifier)
    else:
        cv = check_cv(self.cv, y, classifier=True)
        fit_parameters = signature(base_estimator.fit).parameters
        estimator_name = type(base_estimator).__name__
        if ((sample_weight is not None) and ('sample_weight' not in fit_parameters)):
            warnings.warn(('%s    does    not    support    sample_weight.    Samples    weights    are    only    used    for    the    calibration    itself.' % estimator_name))
            base_estimator_sample_weight = None
        else:
            if (sample_weight is not None):
                sample_weight = check_array(sample_weight, ensure_2d=False)
                check_consistent_length(y, sample_weight)
            base_estimator_sample_weight = sample_weight
        for (train, test) in cv.split(X, y):
            this_estimator = clone(base_estimator)
            if (base_estimator_sample_weight is not None):
                this_estimator.fit(X[train], y[train], sample_weight=base_estimator_sample_weight[train])
            else:
                this_estimator.fit(X[train], y[train])
            calibrated_classifier = _CalibratedClassifier(this_estimator, method=self.method, classes=self.classes_)
            if (sample_weight is not None):
                calibrated_classifier.fit(X[test], y[test], sample_weight[test])
            else:
                calibrated_classifier.fit(X[test], y[test])
            self.calibrated_classifiers_.append(calibrated_classifier)
    return self
