class_docstr: Corrects predictions of the inner classifier by taking into account a (subjective) prior distribution of the
  classes.
  
  This can be useful when there is a difference in class distribution between the training data set and the real
  world. Using the confusion matrix of the inner classifier and the prior, the posterior probability for a class,
  given the prediction of the inner classifier, can be computed.
  
  The background for this posterior estimation is given in
  [this article](https://lucdemortier.github.io/articles/16/PerformanceMetrics).
  
  Based on the `evidence` attribute, this meta estimator's predictions are based on simple weighing of the inner
  estimator's `predict_proba()` results, the posterior probabilities based on the confusion matrix, or a combination
  of the two approaches.
  
  Parameters
  ----------
  estimator : scikit-learn compatible classifier
      Classifier that will be wrapped with SubjectiveClassifier. It should implement `predict_proba` method.
  prior : dict[int, float]
      A dictionary mapping `class -> frequency` representing the prior (a.k.a. subjective real-world) class
      distribution. The class frequencies should sum to 1.
  evidence : Literal["predict_proba", "confusion_matrix", "both"], default="both"
      A string indicating which evidence should be used to correct the inner estimator's predictions.
  
      - If `"both"` the the inner estimator's `predict_proba()` results are multiplied by the posterior probabilities.
      - If `"predict_proba"`, the inner estimator's `predict_proba()` results are multiplied by the prior
          distribution.
      - If `"confusion_matrix"`, the inner estimator's discrete predictions are converted to posterior probabilities
          using the prior and the inner estimator's confusion matrix (obtained from the train data used in `fit()`).
  
  Attributes
  ----------
  estimator_ : scikit-learn compatible classifier
      The fitted classifier.
  classes_ : array-like, shape=(n_classes,)
      The classes labels.
  posterior_matrix_ : array-like, shape=(n_classes, n_classes)
      The posterior probabilities for each class, given the prediction of the inner classifier.
class_docstr_tok: ["Corrects","predictions","of","the","inner","classifier","by","taking","into","account","a","(","subjective",")","prior","distribution","of","the","classes",".","This","can","be","useful","when","there","is","a","difference","in","class","distribution","between","the","training","data","set","and","the","real","world",".","Using","the","confusion","matrix","of","the","inner","classifier","and","the","prior",",","the","posterior","probability","for","a","class",",","given","the","prediction","of","the","inner","classifier",",","can","be","computed",".","The","background","for","this","posterior","estimation","is","given","in","[","this","article","]","(","https",":","\/\/lucdemortier.github.io\/articles\/16\/PerformanceMetrics",")",".","Based","on","the","`","evidence","`","attribute",",","this","meta","estimator","'s","predictions","are","based","on","simple","weighing","of","the","inner","estimator","'s","`","predict_proba","(",")","`","results",",","the","posterior","probabilities","based","on","the","confusion","matrix",",","or","a","combination","of","the","two","approaches",".","Parameters","--","--","--","--","--","estimator",":","scikit-learn","compatible","classifier","Classifier","that","will","be","wrapped","with","SubjectiveClassifier",".","It","should","implement","`","predict_proba","`","method",".","prior",":","dict","[","int",",","float","]","A","dictionary","mapping","`","class","-",">","frequency","`","representing","the","prior","(","a.k.a",".","subjective","real-world",")","class","distribution",".","The","class","frequencies","should","sum","to","1.","evidence",":","Literal","[","``","predict_proba","''",",","``","confusion_matrix","''",",","``","both","''","]",",","default=","''","both","''","A","string","indicating","which","evidence","should","be","used","to","correct","the","inner","estimator","'s","predictions",".","-","If","`","``","both","''","`","the","the","inner","estimator","'s","`","predict_proba","(",")","`","results","are","multiplied","by","the","posterior","probabilities",".","-","If","`","``","predict_proba","''","`",",","the","inner","estimator","'s","`","predict_proba","(",")","`","results","are","multiplied","by","the","prior","distribution",".","-","If","`","``","confusion_matrix","''","`",",","the","inner","estimator","'s","discrete","predictions","are","converted","to","posterior","probabilities","using","the","prior","and","the","inner","estimator","'s","confusion","matrix","(","obtained","from","the","train","data","used","in","`","fit","(",")","`",")",".","Attributes","--","--","--","--","--","estimator_",":","scikit-learn","compatible","classifier","The","fitted","classifier",".","classes_",":","array-like",",","shape=","(","n_classes",",",")","The","classes","labels",".","posterior_matrix_",":","array-like",",","shape=","(","n_classes",",","n_classes",")","The","posterior","probabilities","for","each","class",",","given","the","prediction","of","the","inner","classifier","."]
code: def _evidence(self, predicted_class, cfm):
      return sum(
          [
              self._likelihood(predicted_class, given_class, cfm)
              * self.prior[self.classes_[given_class]]
              for given_class in range(cfm.shape[0])
          ]
      )
  
file_path: scikit-lego/sklego/meta/subjective_classifier.py
imports: import numpy
  from sklearn.base import BaseEstimator, ClassifierMixin, MetaEstimatorMixin
  from sklearn.metrics import confusion_matrix
  from sklearn.preprocessing import normalize
  from sklearn.utils.validation import FLOAT_DTYPES, check_array, check_is_fitted, check_X_y
label_desc: Use image node_id 3 for calling the SubjectiveClassifier obj's underlying member method code with example usage: obj._evidence(predicted_class, cfm) and returns: sum