feat(trainer): run on net5 and accept csv path
Hopefully will use this to automate model deployment.
This commit is contained in:
parent
65558fa199
commit
6c9dd9164b
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>net48;net5</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
|
||||
<TargetFrameworks>net5;net48</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -28,12 +28,19 @@ namespace NoSoliciting.Trainer {
|
|||
|
||||
private static void Main(string[] args) {
|
||||
var full = args[0] == "create";
|
||||
var path = "../../../data.csv";
|
||||
|
||||
if (args.Length > 1) {
|
||||
path = args[1];
|
||||
}
|
||||
|
||||
var parentDir = Directory.GetParent(path);
|
||||
|
||||
var ctx = new MLContext(1);
|
||||
|
||||
List<Data> records;
|
||||
|
||||
using (var fileStream = new FileStream("../../../data.csv", FileMode.Open)) {
|
||||
using (var fileStream = new FileStream(path, FileMode.Open)) {
|
||||
using var stream = new StreamReader(fileStream);
|
||||
using var csv = new CsvReader(stream, new CsvConfiguration(CultureInfo.InvariantCulture) {
|
||||
HeaderValidated = null,
|
||||
|
@ -119,7 +126,8 @@ namespace NoSoliciting.Trainer {
|
|||
var model = pipeline.Fit(train);
|
||||
|
||||
if (full) {
|
||||
ctx.Model.Save(model, train.Schema, @"../../../model.zip");
|
||||
var savePath = Path.Join(parentDir.FullName, "model.zip");
|
||||
ctx.Model.Save(model, train.Schema, savePath);
|
||||
}
|
||||
|
||||
var testPredictions = model.Transform(ttd.TestSet);
|
||||
|
|
Loading…
Reference in New Issue