pascalabcnet/bin/Lib/MLExceptions.pas
Mikhalkovich Stanislav d2fd6c21d6 ML - Metrics, Validation - Production уровень
PABCSystem - добавлен huffle с параметром rnd

RandomForest - добавление OOB

MLModels - сообщения об ошибках и доведение до Production
2026-03-03 14:14:59 +03:00

85 lines
2.8 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit MLExceptions;
interface
const
ER_DIM_MISMATCH =
'Несоответствие размерностей: {0} и {1}!!Dimension mismatch: {0} and {1}';
ER_PARAM_VALUES_EMPTY =
'Список paramValues пуст!!paramValues is empty';
ER_EMPTY_DATASET =
'Набор данных пуст!!Dataset is empty';
ER_LAMBDA_NEGATIVE =
'Параметр lambda должен быть >= 0!!Lambda parameter must be >= 0';
ER_FIT_NOT_CALLED =
'Метод Fit() не вызван!!Fit() must be called first';
ER_MODEL_NULL =
'Модель не может быть nil!!Model cannot be nil';
ER_SELECTKBEST_K_INVALID =
'Параметр k в SelectKBest должен быть >= 1. Передано: {0}.!!SelectKBest parameter k must be >= 1. Given: {0}.';
ER_ARG_NULL =
'Аргумент {0} равен nil!!Argument {0} is null';
ER_EMPTY_DATA =
'Пустой набор данных для {0}!!Empty dataset for {0}';
type
/// Базовое исключение ML-библиотеки
MLException = class(Exception);
/// Попытка использования необученной модели/пайплайна
MLNotFittedException = class(MLException);
/// Несоответствие размерностей
MLDimensionException = class(MLException);
procedure Error(msg: string; params args: array of object);
procedure ArgumentError(msg: string; params args: array of object);
procedure NotFittedError(msg: string; params args: array of object);
procedure DimensionError(msg: string; params args: array of object);
procedure ArgumentNullError(msg: string; params args: array of object);
procedure ArgumentOutOfRangeError(msg: string; params args: array of object);
implementation
function FormatSafe(msg: string; args: array of object): string;
begin
var text := GetTranslation(msg);
try
Result := Format(text, args);
except
Result := text; // если не совпали {0},{1} — оставляем как есть
end;
end;
procedure Error(msg: string; params args: array of object);
begin
raise new MLException(FormatSafe(msg, args));
end;
procedure ArgumentError(msg: string; params args: array of object);
begin
raise new System.ArgumentException(FormatSafe(msg, args));
end;
procedure NotFittedError(msg: string; params args: array of object);
begin
raise new MLNotFittedException(FormatSafe(msg, args));
end;
procedure DimensionError(msg: string; params args: array of object);
begin
raise new MLDimensionException(FormatSafe(msg, args));
end;
procedure ArgumentNullError(msg: string; params args: array of object);
begin
raise new System.ArgumentNullException(FormatSafe(msg, args));
end;
procedure ArgumentOutOfRangeError(msg: string; params args: array of object);
begin
raise new System.ArgumentOutOfRangeException(FormatSafe(msg, args));
end;
end.