From 3be0df94c032b945af803d5056fb01df7af417f3 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Fri, 29 Dec 2023 00:05:17 +0300 Subject: [PATCH] Remove RhSolutions.Console --- RhSolutions.ML.Builder/Program.cs | 11 ----------- .../RhSolutions.ML.Builder.csproj | 14 -------------- RhSolutions.ML.Lib/RhSolutionsMLBuilder.cs | 7 ++++++- RhSolutions.ML.Tests/RhSolutionsTests.cs | 12 +++++++----- RhSolutions.ML.sln | 6 ------ 5 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 RhSolutions.ML.Builder/Program.cs delete mode 100644 RhSolutions.ML.Builder/RhSolutions.ML.Builder.csproj diff --git a/RhSolutions.ML.Builder/Program.cs b/RhSolutions.ML.Builder/Program.cs deleted file mode 100644 index 3f89f06..0000000 --- a/RhSolutions.ML.Builder/Program.cs +++ /dev/null @@ -1,11 +0,0 @@ -using RhSolutions.ML.Lib; - -try -{ - RhSolutionsMLBuilder.RebuildModel(); - Console.WriteLine("Complete"); -} -catch (Exception ex) -{ - Console.WriteLine(ex.Message); -} \ No newline at end of file diff --git a/RhSolutions.ML.Builder/RhSolutions.ML.Builder.csproj b/RhSolutions.ML.Builder/RhSolutions.ML.Builder.csproj deleted file mode 100644 index e034a8f..0000000 --- a/RhSolutions.ML.Builder/RhSolutions.ML.Builder.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - Exe - net7.0 - enable - enable - - - diff --git a/RhSolutions.ML.Lib/RhSolutionsMLBuilder.cs b/RhSolutions.ML.Lib/RhSolutionsMLBuilder.cs index be2e2a6..7030cf5 100644 --- a/RhSolutions.ML.Lib/RhSolutionsMLBuilder.cs +++ b/RhSolutions.ML.Lib/RhSolutionsMLBuilder.cs @@ -36,7 +36,12 @@ public class RhSolutionsMLBuilder private static void SaveModelAsFile(MLContext mlContext, DataViewSchema trainingDataViewSchema, ITransformer model) { + string path = Path.Combine(_appPath, "..", "..", "..", "..", "Models"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } mlContext.Model.Save(model, trainingDataViewSchema, - Path.Combine(_appPath, "..", "..", "..", "..", "Models", "model.zip")); + Path.Combine(path, "model.zip")); } } diff --git a/RhSolutions.ML.Tests/RhSolutionsTests.cs b/RhSolutions.ML.Tests/RhSolutionsTests.cs index e1ec8f4..4e91342 100644 --- a/RhSolutions.ML.Tests/RhSolutionsTests.cs +++ b/RhSolutions.ML.Tests/RhSolutionsTests.cs @@ -1,3 +1,5 @@ +using RhSolutions.ML.Lib; + namespace RhSolutions.ML.Tests; public abstract class RhSolutionsTests @@ -6,13 +8,13 @@ public abstract class RhSolutionsTests protected static string _dataPath = Path.Combine(_appPath, "..", "..", "..", "..", "Models", "model.zip"); protected MLContext _mlContext; protected PredictionEngine _predEngine; - - [SetUp] - public void Setup() + + public RhSolutionsTests() { + RhSolutionsMLBuilder.RebuildModel(); _mlContext = new MLContext(seed: 0); ITransformer loadedNodel = _mlContext.Model.Load(_dataPath, out var _); - _predEngine = _mlContext.Model.CreatePredictionEngine(loadedNodel); + _predEngine = _mlContext.Model.CreatePredictionEngine(loadedNodel); } public void Execute(string name, string expectedGroup) @@ -23,5 +25,5 @@ public abstract class RhSolutionsTests }; var prediction = _predEngine.Predict(p); Assert.That(prediction.Type, Is.EqualTo(expectedGroup)); - } + } } \ No newline at end of file diff --git a/RhSolutions.ML.sln b/RhSolutions.ML.sln index 95b927c..429c881 100644 --- a/RhSolutions.ML.sln +++ b/RhSolutions.ML.sln @@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.ML.Tests", "RhS EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.ML.Lib", "RhSolutions.ML.Lib\RhSolutions.ML.Lib.csproj", "{36239F13-0F62-4AD7-B0AF-FA24E8101FA7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.ML.Builder", "RhSolutions.ML.Builder\RhSolutions.ML.Builder.csproj", "{13C69C4E-6A1A-4646-8F2B-9C058E1B0FAD}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,10 +21,6 @@ Global {36239F13-0F62-4AD7-B0AF-FA24E8101FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU {36239F13-0F62-4AD7-B0AF-FA24E8101FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU {36239F13-0F62-4AD7-B0AF-FA24E8101FA7}.Release|Any CPU.Build.0 = Release|Any CPU - {13C69C4E-6A1A-4646-8F2B-9C058E1B0FAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {13C69C4E-6A1A-4646-8F2B-9C058E1B0FAD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {13C69C4E-6A1A-4646-8F2B-9C058E1B0FAD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {13C69C4E-6A1A-4646-8F2B-9C058E1B0FAD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE