Build points of FNR curve. Parameters ---------- model : catboost.CatBoost The trained model. data : catboost.Pool or list of catboost.Pool A set of samples to build ROC curve with. curve : tuple of three arrays (fpr, tpr, thresholds) ROC curve poi
(model=None, data=None, curve=None, thread_count=-1, plot=False)
| 443 | |
| 444 | |
| 445 | def get_fnr_curve(model=None, data=None, curve=None, thread_count=-1, plot=False): |
| 446 | """ |
| 447 | Build points of FNR curve. |
| 448 | |
| 449 | Parameters |
| 450 | ---------- |
| 451 | model : catboost.CatBoost |
| 452 | The trained model. |
| 453 | |
| 454 | data : catboost.Pool or list of catboost.Pool |
| 455 | A set of samples to build ROC curve with. |
| 456 | |
| 457 | curve : tuple of three arrays (fpr, tpr, thresholds) |
| 458 | ROC curve points in format of get_roc_curve returned value. |
| 459 | If set, data parameter must not be set. |
| 460 | |
| 461 | thread_count : int (default=-1) |
| 462 | Number of threads to work with. |
| 463 | If -1, then the number of threads is set to the number of CPU cores. |
| 464 | |
| 465 | plot : bool, optional (default=False) |
| 466 | If True, draw curve. |
| 467 | |
| 468 | Returns |
| 469 | ------- |
| 470 | curve points : tuple of two arrays (thresholds, fnr) |
| 471 | """ |
| 472 | if curve is not None: |
| 473 | if data is not None: |
| 474 | raise CatBoostError('Only one of the parameters data and curve should be set.') |
| 475 | if not (isinstance(curve, list) or isinstance(curve, tuple)) or len(curve) != 3: |
| 476 | raise CatBoostError('curve must be list or tuple of three arrays (fpr, tpr, thresholds).') |
| 477 | tpr, thresholds = curve[1], curve[2][:] |
| 478 | else: |
| 479 | if model is None or data is None: |
| 480 | raise CatBoostError('model and data parameters should be set when curve parameter is None.') |
| 481 | _, tpr, thresholds = get_roc_curve(model, data, thread_count) |
| 482 | fnr = np.array([1 - x for x in tpr]) |
| 483 | |
| 484 | if plot: |
| 485 | with _import_matplotlib() as plt: |
| 486 | _draw(plt, thresholds, fnr, 'Thresholds', 'False Negative Rate', 'FNR Curve') |
| 487 | |
| 488 | return thresholds, fnr |
| 489 | |
| 490 | |
| 491 | def select_threshold(model=None, data=None, curve=None, FPR=None, FNR=None, thread_count=-1): |
no test coverage detected