Compute probabilities of possible outcomes for samples in X. The model needs to have probability information computed at training time: fit with attribute `probability` set to True. Parameters ---------- X : array-like of shape (n_samples, n_features)
(self, X)
| 875 | |
| 876 | @available_if(_check_proba) |
| 877 | def predict_proba(self, X): |
| 878 | """Compute probabilities of possible outcomes for samples in X. |
| 879 | |
| 880 | The model needs to have probability information computed at training |
| 881 | time: fit with attribute `probability` set to True. |
| 882 | |
| 883 | Parameters |
| 884 | ---------- |
| 885 | X : array-like of shape (n_samples, n_features) |
| 886 | For kernel="precomputed", the expected shape of X is |
| 887 | (n_samples_test, n_samples_train). |
| 888 | |
| 889 | Returns |
| 890 | ------- |
| 891 | T : ndarray of shape (n_samples, n_classes) |
| 892 | Returns the probability of the sample for each class in |
| 893 | the model. The columns correspond to the classes in sorted |
| 894 | order, as they appear in the attribute :term:`classes_`. |
| 895 | |
| 896 | Notes |
| 897 | ----- |
| 898 | The probability model is created using cross validation, so |
| 899 | the results can be slightly different than those obtained by |
| 900 | predict. Also, it will produce meaningless results on very small |
| 901 | datasets. |
| 902 | """ |
| 903 | X = self._validate_for_predict(X) |
| 904 | if self._probA.size == 0 or self._probB.size == 0: |
| 905 | raise NotFittedError( |
| 906 | "predict_proba is not available when fitted with probability=False" |
| 907 | ) |
| 908 | pred_proba = ( |
| 909 | self._sparse_predict_proba if self._sparse else self._dense_predict_proba |
| 910 | ) |
| 911 | return pred_proba(X) |
| 912 | |
| 913 | @available_if(_check_proba) |
| 914 | def predict_log_proba(self, X): |