summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerghei Cebotari <serghei@cebotari.ru>2023-12-29 00:05:17 +0300
committerSerghei Cebotari <serghei@cebotari.ru>2023-12-29 00:05:17 +0300
commit3be0df94c032b945af803d5056fb01df7af417f3 (patch)
tree32f163fffa86afd02df3c93fe62a041038513464
parenta3cc89ce049a09aeebf068e6013a7e9b142e695f (diff)
Remove RhSolutions.Console
-rw-r--r--RhSolutions.ML.Builder/Program.cs11
-rw-r--r--RhSolutions.ML.Builder/RhSolutions.ML.Builder.csproj14
-rw-r--r--RhSolutions.ML.Lib/RhSolutionsMLBuilder.cs7
-rw-r--r--RhSolutions.ML.Tests/RhSolutionsTests.cs12
-rw-r--r--RhSolutions.ML.sln6
5 files changed, 13 insertions, 37 deletions
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 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <ItemGroup>
- <ProjectReference Include="..\RhSolutions.ML.Lib\RhSolutions.ML.Lib.csproj" />
- </ItemGroup>
-
- <PropertyGroup>
- <OutputType>Exe</OutputType>
- <TargetFramework>net7.0</TargetFramework>
- <ImplicitUsings>enable</ImplicitUsings>
- <Nullable>enable</Nullable>
- </PropertyGroup>
-
-</Project>
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<Product, TypePrediction> _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<Product, TypePrediction>(loadedNodel);
+ _predEngine = _mlContext.Model.CreatePredictionEngine<Product, TypePrediction>(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