MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / OutputCodeClassifier

Class OutputCodeClassifier

sklearn/multiclass.py:1043–1289  ·  view source on GitHub ↗

(Error-Correcting) Output-Code multiclass strategy. Output-code based strategies consist in representing each class with a binary code (an array of 0s and 1s). At fitting time, one binary classifier per bit in the code book is fitted. At prediction time, the classifiers are used to

Source from the content-addressed store, hash-verified

1041
1042
1043class OutputCodeClassifier(MetaEstimatorMixin, ClassifierMixin, BaseEstimator):
1044 """(Error-Correcting) Output-Code multiclass strategy.
1045
1046 Output-code based strategies consist in representing each class with a
1047 binary code (an array of 0s and 1s). At fitting time, one binary
1048 classifier per bit in the code book is fitted. At prediction time, the
1049 classifiers are used to project new points in the class space and the class
1050 closest to the points is chosen. The main advantage of these strategies is
1051 that the number of classifiers used can be controlled by the user, either
1052 for compressing the model (0 < `code_size` < 1) or for making the model more
1053 robust to errors (`code_size` > 1). See the documentation for more details.
1054
1055 Read more in the :ref:`User Guide <ecoc>`.
1056
1057 Parameters
1058 ----------
1059 estimator : estimator object
1060 An estimator object implementing :term:`fit` and one of
1061 :term:`decision_function` or :term:`predict_proba`.
1062
1063 code_size : float, default=1.5
1064 Percentage of the number of classes to be used to create the code book.
1065 A number between 0 and 1 will require fewer classifiers than
1066 one-vs-the-rest. A number greater than 1 will require more classifiers
1067 than one-vs-the-rest.
1068
1069 random_state : int, RandomState instance, default=None
1070 The generator used to initialize the codebook.
1071 Pass an int for reproducible output across multiple function calls.
1072 See :term:`Glossary <random_state>`.
1073
1074 n_jobs : int, default=None
1075 The number of jobs to use for the computation: the multiclass problems
1076 are computed in parallel.
1077
1078 ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
1079 ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
1080 for more details.
1081
1082 Attributes
1083 ----------
1084 estimators_ : list of `int(n_classes * code_size)` estimators
1085 Estimators used for predictions.
1086
1087 classes_ : ndarray of shape (n_classes,)
1088 Array containing labels.
1089
1090 code_book_ : ndarray of shape (n_classes, `len(estimators_)`)
1091 Binary array containing the code of each class.
1092
1093 n_features_in_ : int
1094 Number of features seen during :term:`fit`. Only defined if the
1095 underlying estimator exposes such an attribute when fit.
1096
1097 .. versionadded:: 0.24
1098
1099 feature_names_in_ : ndarray of shape (`n_features_in_`,)
1100 Names of features seen during :term:`fit`. Only defined if the

Callers 6

test_ecoc_exceptionsFunction · 0.90
test_ecoc_fit_predictFunction · 0.90
test_ecoc_gridsearchFunction · 0.90
test_ecoc_float_yFunction · 0.90

Calls 2

HasMethodsClass · 0.90
IntervalClass · 0.90

Tested by 5

test_ecoc_exceptionsFunction · 0.72
test_ecoc_fit_predictFunction · 0.72
test_ecoc_gridsearchFunction · 0.72
test_ecoc_float_yFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…