Implementations
Classes:
Name | Description |
---|---|
SelectiveRegression |
Selective regression-based decision-making. |
SelectiveClassification |
Selective classification-based decision-making. |
BestClassDecision |
Best classification-based decision-making. |
MultiLabelDecision |
Standard multi-label classification-based decision-making. |
BinaryDecision |
Binary classification-based decision-making. |
SelectiveRegression
Bases: AdvancedRegressionDecision
Selective regression-based decision-making.
- Predict the estimated prediction and residual using two separate estimators.
- If the residual is less than or equal to the threshold, return the prediction; otherwise, NaN.
When using this class?
- When the prediction and residual are estimated separately.
- When the decision is based on the residual.
- When you want to select predictions with low residuals.
- When you want to deleguate the decision to a human operator when the confidence is low.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
estimator
|
BaseEstimator
|
The estimator used to predict the output values. |
required |
residual
|
BaseEstimator
|
The estimator used to predict the residuals. |
required |
threshold
|
float
|
The threshold for the residual. If the residual is less than or equal to the threshold, the prediction is returned; otherwise, NaN. The default is 0.0. |
required |
Attributes:
Name | Type | Description |
---|---|---|
estimator |
BaseEstimator
|
The estimator used to predict the output values. |
residual |
BaseEstimator
|
The estimator used to predict the residuals. |
threshold |
float
|
The threshold for the residual. |
Methods:
Name | Description |
---|---|
make_decision |
Predict the decision for the input data based on the output values |
make_decision
make_decision(y_output)
Predict the decision for the input data based on the output values and residuals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_output
|
Tuple[ndarray, ndarray]
|
The output values and residuals for the input data. The first element is the output values, and the second element is the residuals |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The predicted decision for the input data. The decision is made based on the output values and residuals. If the residual is less than or equal to the threshold, the decision is the output value; otherwise, the decision is NaN. |
Source code in risk_control/decision/decision.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
SelectiveClassification
Bases: BaseClassificationDecision
Selective classification-based decision-making.
- Predict the estimated probability or score using the estimator.
- If the probability or score of the top-1 class is greater than or equal to the threshold, return the top-1 class; otherwise, return _ABS.
When using this class?
- When you want to select the top-1 class with high confidence.
- When you want to control the false discovery rate.
- When you want to deleguate the decision to a human operator when the confidence is low. So, there is abstention when the confidence is low.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
estimator
|
BaseEstimator
|
The estimator object used for making predictions. |
required |
threshold
|
float
|
The threshold value used for decision-making. |
required |
predict_mode
|
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
required |
Attributes:
Name | Type | Description |
---|---|---|
estimator |
BaseEstimator
|
The estimator object used for making predictions. |
threshold |
float
|
The threshold value used for decision-making. |
predict_mode |
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
Methods:
Name | Description |
---|---|
make_decision |
Predict the decision for the input data based on the output values. |
make_decision
make_decision(y_output)
Predict the decision for the input data based on the output values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_output
|
ndarray
|
The output values predicted by the estimator. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The predicted decisions based on the output values and threshold. |
Source code in risk_control/decision/decision.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
BestClassDecision
Bases: BaseClassificationDecision
Best classification-based decision-making.
- Predict the estimated probability or score using the estimator.
- If the probability or score of the top-1 class is greater than or equal to the threshold, return the top-1 class; otherwise, return empty set.
When using this class?
- When you want to select the top-1 class with high confidence.
- When you want to control the false discovery rate.
- When you want to return empty set when the confidence is low. There is no abstension in this case.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
estimator
|
BaseEstimator
|
The estimator object used for making predictions. |
required |
threshold
|
float
|
The threshold value used for decision-making. |
required |
predict_mode
|
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
required |
Attributes:
Name | Type | Description |
---|---|---|
estimator |
BaseEstimator
|
The estimator object used for making predictions. |
threshold |
float
|
The threshold value used for decision-making. |
predict_mode |
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
Methods:
Name | Description |
---|---|
make_decision |
Predict the decision for the input data based on the output values. |
make_decision
make_decision(y_output)
Predict the decision for the input data based on the output values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_output
|
ndarray
|
The output values predicted by the estimator. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The predicted decisions based on the output values and threshold. |
Source code in risk_control/decision/decision.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
MultiLabelDecision
MultiLabelDecision(
estimator, *, predict_output="set", **kwargs
)
Bases: BaseClassificationDecision
Standard multi-label classification-based decision-making.
- Predict the estimated probability or score using the estimator.
- If the probability or score of any class is greater than or equal to the threshold, return True; otherwise, return False.
When using this class?
- When you want to select best candidates with high confidence.
- When you want to control the false discovery rate.
- When you want to return empty set when the confidence is low. There is no abstension in this case.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
estimator
|
BaseEstimator
|
The estimator object used for making predictions. |
required |
threshold
|
float
|
The threshold value used for decision-making. |
required |
predict_mode
|
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
required |
predict_output
|
str
|
The output type of the prediction. Can be 'class' or 'set'. |
'set'
|
Attributes:
Name | Type | Description |
---|---|---|
estimator |
BaseEstimator
|
The estimator object used for making predictions. |
threshold |
float
|
The threshold value used for decision-making. |
predict_mode |
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
predict_output |
str
|
The output type of the prediction. Can be 'class' or 'set'. |
Methods:
Name | Description |
---|---|
make_decision |
Predict the decision for the input data based on the output values. |
Source code in risk_control/decision/decision.py
230 231 232 233 234 |
|
predict_output
instance-attribute
predict_output = predict_output
make_decision
make_decision(y_output)
Predict the decision for the input data based on the output values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_output
|
ndarray
|
The output values predicted by the estimator. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The predicted decisions based on the output values and threshold. |
Source code in risk_control/decision/decision.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
BinaryDecision
BinaryDecision(
estimator, *, predict_output="class", **kwargs
)
Bases: BaseClassificationDecision
Binary classification-based decision-making.
- Predict the estimated probability or score using the estimator.
- If the probability or score is greater than or equal to the threshold, return True; otherwise, return False.
When using this class?
- When you want to control the precision-recall trade-off.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
estimator
|
BaseEstimator
|
The estimator object used for making predictions. |
required |
threshold
|
float
|
The threshold value used for decision-making. |
required |
predict_mode
|
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
required |
predict_output
|
str
|
The output type of the prediction. Can be 'class' or 'set'. |
'class'
|
Attributes:
Name | Type | Description |
---|---|---|
estimator |
BaseEstimator
|
The estimator object used for making predictions. |
threshold |
float
|
The threshold value used for decision-making. |
predict_mode |
str
|
The mode to use for prediction. Can be 'proba' or 'score'. |
predict_output |
str
|
The output type of the prediction. Can be 'class' or 'set'. |
Methods:
Name | Description |
---|---|
make_decision |
Predict the decision for the input data based on the output values. |
Source code in risk_control/decision/decision.py
294 295 296 297 298 299 300 301 302 |
|
predict_output
instance-attribute
predict_output = predict_output
make_decision
make_decision(y_output)
Predict the decision for the input data based on the output values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_output
|
ndarray
|
The output values predicted by the estimator. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The predicted decisions based on the output values and threshold. |
Source code in risk_control/decision/decision.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|