'Calibrate the fitted 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):

    self.label_encoder_ = LabelEncoder()
    if (self.classes is None):
        self.label_encoder_.fit(y)
    else:
        self.label_encoder_.fit(self.classes)
    self.classes_ = self.label_encoder_.classes_
    Y = label_binarize(y, self.classes_)
    (df, idx_pos_class) = self._preproc(X)
    self.calibrators_ = []
    for (k, this_df) in zip(idx_pos_class, df.T):
        if (self.method == 'isotonic'):
            calibrator = IsotonicRegression(out_of_bounds='clip')
        elif (self.method == 'sigmoid'):
            calibrator = _SigmoidCalibration()
        else:
            raise ValueError(('method    should    be    "sigmoid"    or    "isotonic".    Got    %s.' % self.method))
        calibrator.fit(this_df, Y[:, k], sample_weight)
        self.calibrators_.append(calibrator)
    return self
