GetTranslation - сделал публичной
MLExceptions - новый модуль
This commit is contained in:
parent
028e219091
commit
d09da0213e
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "11";
|
||||
public const string Build = "1";
|
||||
public const string Revision = "3753";
|
||||
public const string Revision = "3756";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=11
|
||||
%REVISION%=3753
|
||||
%COREVERSION%=1
|
||||
%REVISION%=3756
|
||||
%MINOR%=11
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.11.1.3753
|
||||
3.11.1.3756
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.11.1.3753'
|
||||
!define VERSION '3.11.1.3756'
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ uses
|
|||
TasksArr, TasksMatr, TasksStr, Tasks1Begin, Tasks1BoolIfCase, Tasks1Loops, Tasks1Arr,
|
||||
WPF,
|
||||
DataFrameABC, DataFrameABCCore, LinearAlgebraML, PreprocessorABC,
|
||||
MetricsABC, MLABC, MLCoreABC, MLModelsABC, ValidationML
|
||||
MetricsABC, MLABC, MLCoreABC, MLModelsABC, ValidationML, MLExceptions
|
||||
;
|
||||
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
Collections, Arrays, Core, ClientServer, Countries,
|
||||
ABCDatabases,
|
||||
School, SF, TurtleABC,
|
||||
DataFrameABC, DataFrameABCCore, LinearAlgebraML, PreprocessorABC
|
||||
DataFrameABC, DataFrameABCCore, LinearAlgebraML, PreprocessorABC,
|
||||
MetricsABC, MLABC, MLCoreABC, MLModelsABC, ValidationML, MLExceptions
|
||||
;
|
||||
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -188,6 +188,8 @@
|
|||
File ..\bin\Lib\MLCoreABC.pcu
|
||||
File ..\bin\Lib\MLModelsABC.pcu
|
||||
File ..\bin\Lib\ValidationML.pcu
|
||||
File ..\bin\Lib\MLExceptions.pcu
|
||||
|
||||
|
||||
File ..\bin\Lib\PABCRtl.dll
|
||||
File ..\bin\Lib\HelixToolkit.Wpf.dll
|
||||
|
|
@ -290,6 +292,7 @@
|
|||
${AddFile} "MLCoreABC.pcu"
|
||||
${AddFile} "MLModelsABC.pcu"
|
||||
${AddFile} "ValidationML.pcu"
|
||||
${AddFile} "MLExceptions.pcu"
|
||||
|
||||
|
||||
${AddFile} "turtle.png"
|
||||
|
|
@ -429,7 +432,7 @@
|
|||
File ..\bin\Lib\MLCoreABC.pas
|
||||
File ..\bin\Lib\MLModelsABC.pas
|
||||
File ..\bin\Lib\ValidationML.pas
|
||||
|
||||
File ..\bin\Lib\MLExceptions.pas
|
||||
|
||||
File ..\bin\Lib\__RedirectIOMode.vb
|
||||
File ..\bin\Lib\VBSystem.vb
|
||||
|
|
@ -519,6 +522,7 @@
|
|||
${AddFile} "MLCoreABC.pas"
|
||||
${AddFile} "MLModelsABC.pas"
|
||||
${AddFile} "ValidationML.pas"
|
||||
${AddFile} "MLExceptions.pas"
|
||||
|
||||
${AddFile} "__RedirectIOMode.vb"
|
||||
${AddFile} "VBSystem.vb"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ uses ValidationML;
|
|||
uses MLModelsABC;
|
||||
uses MetricsABC;
|
||||
uses PreprocessorABC;
|
||||
USES DataFrameABC;
|
||||
uses DataFrameABC;
|
||||
uses MLExceptions;
|
||||
|
||||
type
|
||||
Vector = LinearAlgebraML.Vector;
|
||||
|
|
@ -42,6 +43,11 @@ type
|
|||
ElasticNet = MLModelsABC.ElasticNet;
|
||||
MulticlassLogisticRegression = MLModelsABC.MulticlassLogisticRegression;
|
||||
|
||||
MLException = MLExceptions.MLException;
|
||||
MLArgumentException = MLExceptions.MLArgumentException;
|
||||
MLNotFittedException = MLExceptions.MLNotFittedException;
|
||||
MLDimensionException = MLExceptions.MLDimensionException;
|
||||
|
||||
implementation
|
||||
|
||||
function ToMatrix(Self: DataFrame; colNames: array of string): Matrix; extensionmethod;
|
||||
|
|
|
|||
55
bin/Lib/MLExceptions.pas
Normal file
55
bin/Lib/MLExceptions.pas
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
unit MLExceptions;
|
||||
|
||||
interface
|
||||
|
||||
type
|
||||
/// Базовое исключение ML-библиотеки
|
||||
MLException = class(Exception);
|
||||
|
||||
/// Ошибка аргументов ML-методов
|
||||
MLArgumentException = class(System.ArgumentException);
|
||||
|
||||
/// Попытка использования необученной модели/пайплайна
|
||||
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);
|
||||
|
||||
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 MLArgumentException(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;
|
||||
|
||||
end.
|
||||
|
|
@ -3139,48 +3139,6 @@ type
|
|||
end;
|
||||
|
||||
|
||||
{type
|
||||
///--
|
||||
__TypeclassRestrictedFunctionAttribute = class(Attribute)
|
||||
public
|
||||
constructor;
|
||||
begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
///--
|
||||
__TypeclassGenericParameterAttribute = class(Attribute)
|
||||
public
|
||||
constructor(instanceName: string);
|
||||
begin
|
||||
end;
|
||||
end;
|
||||
|
||||
///--
|
||||
__TypeclassAttribute = class(Attribute)
|
||||
public
|
||||
constructor(typeclassName: string);
|
||||
begin
|
||||
end;
|
||||
end;
|
||||
|
||||
///--
|
||||
__TypeclassMemberAttribute = class(Attribute)
|
||||
public
|
||||
constructor;
|
||||
begin
|
||||
end;
|
||||
end;
|
||||
|
||||
///--
|
||||
__TypeclassInstanceAttribute = class(Attribute)
|
||||
public
|
||||
constructor(instanceName: string);
|
||||
begin
|
||||
end;
|
||||
end;}
|
||||
|
||||
type
|
||||
// Смысл полей Num, Width и Fmt соответствует
|
||||
// атрибутам форматирования {Num,Width:Fmt}.
|
||||
|
|
@ -3237,6 +3195,8 @@ type
|
|||
constructor Create;
|
||||
end;
|
||||
|
||||
/// Функция для перевода сообщений об ошибках
|
||||
function GetTranslation(message: string): string;
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Internal procedures for PABCRTL.dll
|
||||
|
|
@ -3330,6 +3290,7 @@ begin
|
|||
Result := 'ru';
|
||||
end;
|
||||
|
||||
// Делаю публичной
|
||||
function GetTranslation(message: string): string;
|
||||
begin
|
||||
var cur_locale := GetCurrentLocale();
|
||||
|
|
|
|||
|
|
@ -70,7 +70,12 @@ type
|
|||
|
||||
implementation
|
||||
|
||||
uses System;
|
||||
uses MLExceptions;
|
||||
|
||||
const
|
||||
ER_DIM_MISMATCH_TRAIN_TEST =
|
||||
'Несоответствие размерностей в TrainTestSplit: X.RowCount={0}, y.Length={1}!!' +
|
||||
'Dimension mismatch in TrainTestSplit: X.RowCount={0}, y.Length={1}';
|
||||
|
||||
//-----------------------------
|
||||
// Validation
|
||||
|
|
@ -80,7 +85,7 @@ static function Validation.TrainTestSplit(X: Matrix; y: Vector;
|
|||
testRatio: real; seed: integer): (Matrix, Matrix, Vector, Vector);
|
||||
begin
|
||||
if X.RowCount <> y.Length then
|
||||
raise new Exception('Dimension mismatch in TrainTestSplit');
|
||||
DimensionError(ER_DIM_MISMATCH_TRAIN_TEST, X.RowCount, y.Length);
|
||||
|
||||
if (testRatio <= 0) or (testRatio >= 1) then
|
||||
raise new Exception('testRatio must be in (0,1)');
|
||||
|
|
@ -309,7 +314,7 @@ class function GridSearch.Search<T>(
|
|||
): (real, real, T); where T: IModel;
|
||||
begin
|
||||
if paramValues.Length = 0 then
|
||||
raise new ArgumentException('paramValues is empty');
|
||||
raise new System.ArgumentException('paramValues is empty');
|
||||
|
||||
var bestParam := paramValues[0];
|
||||
var bestScore := -1e308;
|
||||
|
|
|
|||
Loading…
Reference in a new issue