class_docstr: Probability calibration with isotonic regression or sigmoid.
  
  With this class, the base_estimator is fit on the train set of the
  cross-validation generator and the test set is used for calibration.
  The probabilities for each of the folds are then averaged
  for prediction. In case that cv="prefit" is passed to __init__,
  it is assumed that base_estimator has been fitted already and all
  data is used for calibration. Note that data for fitting the
  classifier and for calibrating it must be disjoint.
  
  Read more in the :ref:`User Guide <calibration>`.
  
  Parameters
  ----------
  base_estimator : instance BaseEstimator
      The classifier whose output decision function needs to be calibrated
      to offer more accurate predict_proba outputs. If cv=prefit, the
      classifier must have been fit already on data.
  
  method : 'sigmoid' or 'isotonic'
      The method to use for calibration. Can be 'sigmoid' which
      corresponds to Platt's method or 'isotonic' which is a
      non-parametric approach. It is not advised to use isotonic calibration
      with too few calibration samples ``(<<1000)`` since it tends to
      overfit.
      Use sigmoids (Platt's calibration) in this case.
  
  cv : integer, cross-validation generator, iterable or "prefit", optional
      Determines the cross-validation splitting strategy.
      Possible inputs for cv are:
  
      - None, to use the default 3-fold cross-validation,
      - integer, to specify the number of folds.
      - An object to be used as a cross-validation generator.
      - An iterable yielding train/test splits.
  
      For integer/None inputs, if ``y`` is binary or multiclass,
      :class:`sklearn.model_selection.StratifiedKFold` is used. If ``y`` is
      neither binary nor multiclass, :class:`sklearn.model_selection.KFold`
      is used.
  
      Refer :ref:`User Guide <cross_validation>` for the various
      cross-validation strategies that can be used here.
  
      If "prefit" is passed, it is assumed that base_estimator has been
      fitted already and all data is used for calibration.
  
  Attributes
  ----------
  classes_ : array, shape (n_classes)
      The class labels.
  
  calibrated_classifiers_: list (len() equal to cv or 1 if cv == "prefit")
      The list of calibrated classifiers, one for each crossvalidation fold,
      which has been fitted on all but the validation fold and calibrated
      on the validation fold.
  
  References
  ----------
  .. [1] Obtaining calibrated probability estimates from decision trees
         and naive Bayesian classifiers, B. Zadrozny & C. Elkan, ICML 2001
  
  .. [2] Transforming Classifier Scores into Accurate Multiclass
         Probability Estimates, B. Zadrozny & C. Elkan, (KDD 2002)
  
  .. [3] Probabilistic Outputs for Support Vector Machines and Comparisons to
         Regularized Likelihood Methods, J. Platt, (1999)
  
  .. [4] Predicting Good Probabilities with Supervised Learning,
         A. Niculescu-Mizil & R. Caruana, ICML 2005
class_docstr_tok: ["Probability","calibration","with","isotonic","regression","or","sigmoid",".","With","this","class",",","the","base_estimator","is","fit","on","the","train","set","of","the","cross-validation","generator","and","the","test","set","is","used","for","calibration",".","The","probabilities","for","each","of","the","folds","are","then","averaged","for","prediction",".","In","case","that","cv=","''","prefit","''","is","passed","to","__init__",",","it","is","assumed","that","base_estimator","has","been","fitted","already","and","all","data","is","used","for","calibration",".","Note","that","data","for","fitting","the","classifier","and","for","calibrating","it","must","be","disjoint",".","Read","more","in","the",":","ref",":","`","User","Guide","<","calibration",">","`",".","Parameters","--","--","--","--","--","base_estimator",":","instance","BaseEstimator","The","classifier","whose","output","decision","function","needs","to","be","calibrated","to","offer","more","accurate","predict_proba","outputs",".","If","cv=prefit",",","the","classifier","must","have","been","fit","already","on","data",".","method",":","'sigmoid","'","or","'isotonic'","The","method","to","use","for","calibration",".","Can","be","'sigmoid","'","which","corresponds","to","Platt","'s","method","or","'isotonic","'","which","is","a","non-parametric","approach",".","It","is","not","advised","to","use","isotonic","calibration","with","too","few","calibration","samples","``","(","<","<","1000",")","``","since","it","tends","to","overfit",".","Use","sigmoids","(","Platt","'s","calibration",")","in","this","case",".","cv",":","integer",",","cross-validation","generator",",","iterable","or","``","prefit","''",",","optional","Determines","the","cross-validation","splitting","strategy",".","Possible","inputs","for","cv","are",":","-","None",",","to","use","the","default","3-fold","cross-validation",",","-","integer",",","to","specify","the","number","of","folds",".","-","An","object","to","be","used","as","a","cross-validation","generator",".","-","An","iterable","yielding","train\/test","splits",".","For","integer\/None","inputs",",","if","``","y","``","is","binary","or","multiclass",",",":","class",":","`","sklearn.model_selection.StratifiedKFold","`","is","used",".","If","``","y","``","is","neither","binary","nor","multiclass",",",":","class",":","`","sklearn.model_selection.KFold","`","is","used",".","Refer",":","ref",":","`","User","Guide","<","cross_validation",">","`","for","the","various","cross-validation","strategies","that","can","be","used","here",".","If","``","prefit","''","is","passed",",","it","is","assumed","that","base_estimator","has","been","fitted","already","and","all","data","is","used","for","calibration",".","Attributes","--","--","--","--","--","classes_",":","array",",","shape","(","n_classes",")","The","class","labels",".","calibrated_classifiers_",":","list","(","len","(",")","equal","to","cv","or","1","if","cv","==","``","prefit","''",")","The","list","of","calibrated","classifiers",",","one","for","each","crossvalidation","fold",",","which","has","been","fitted","on","all","but","the","validation","fold","and","calibrated","on","the","validation","fold",".","References","--","--","--","--","--","..","[","1","]","Obtaining","calibrated","probability","estimates","from","decision","trees","and","naive","Bayesian","classifiers",",","B.","Zadrozny","&","C.","Elkan",",","ICML","2001","..","[","2","]","Transforming","Classifier","Scores","into","Accurate","Multiclass","Probability","Estimates",",","B.","Zadrozny","&","C.","Elkan",",","(","KDD","2002",")","..","[","3","]","Probabilistic","Outputs","for","Support","Vector","Machines","and","Comparisons","to","Regularized","Likelihood","Methods",",","J.","Platt",",","(","1999",")","..","[","4","]","Predicting","Good","Probabilities","with","Supervised","Learning",",","A.","Niculescu-Mizil","&","R.","Caruana",",","ICML","2005"]
docstr: 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.
docstr_tok: ["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","."]
code: def fit(self, X, y, sample_weight=None):
      """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.
      """
      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_
  
      # Check that each cross-validation fold can have at least one
      # example per class
      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:
          # we want all classifiers that don't expose a random_state
          # to be deterministic (and we don't want to expose this one).
          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:
              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
  
imports: from __future__ import division
  import warnings
  from math import log
  import numpy
  from scipy.optimize import fmin_bfgs
  from sklearn.preprocessing import LabelEncoder
  from .base import BaseEstimator, ClassifierMixin, RegressorMixin, clone
  from .preprocessing import label_binarize, LabelBinarizer
  from .utils import check_X_y, check_array, indexable, column_or_1d
  from .utils.validation import check_is_fitted
  from .utils.fixes import signature
  from .isotonic import IsotonicRegression
  from .svm import LinearSVC
  from .model_selection import check_cv
  from .metrics.classification import _check_binary_probabilistic_predictions
label_desc: Use image node_id 2 for calling the CalibratedClassifierCV obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self