Skip to content

Commit af02002

Browse files
committed
[ml] 가격예측추가
1 parent 4b96ce0 commit af02002

4 files changed

Lines changed: 367 additions & 29 deletions

File tree

ActorLib/ActorLib.csproj

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<AkkaVersion>1.5.40</AkkaVersion>
7-
<AkkaPersistenceVersion>1.5.37</AkkaPersistenceVersion>
8-
<AkkaMinVersion>1.5.13</AkkaMinVersion>
9-
<Nullable>enable</Nullable>
10-
</PropertyGroup>
11-
12-
<ItemGroup>
13-
<PackageReference Include="Akka" Version="$(AkkaVersion)" />
14-
<PackageReference Include="Akka.Remote" Version="$(AkkaVersion)" />
15-
<PackageReference Include="Akka.Streams" Version="$(AkkaVersion)" />
16-
<PackageReference Include="Akka.DependencyInjection" Version="$(AkkaVersion)" />
17-
<PackageReference Include="Akka.Logger.NLog" Version="$(AkkaMinVersion)" />
18-
<PackageReference Include="Akka.Persistence.RavenDB" Version="$(AkkaPersistenceVersion)" />
19-
<PackageReference Include="Akka.Persistence.RavenDB.Hosting" Version="$(AkkaPersistenceVersion)" />
20-
<PackageReference Include="Flurl.Http" Version="4.0.2" />
21-
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.9" />
22-
<PackageReference Include="NLog" Version="5.4.0" />
23-
<PackageReference Include="RavenDB.Client" Version="7.0.1" />
24-
</ItemGroup>
25-
26-
<ItemGroup>
27-
<Folder Include="MCP\" />
28-
</ItemGroup>
29-
30-
</Project>
2+
<PropertyGroup>
3+
<TargetFramework>net9.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<AkkaVersion>1.5.40</AkkaVersion>
6+
<AkkaPersistenceVersion>1.5.37</AkkaPersistenceVersion>
7+
<AkkaMinVersion>1.5.13</AkkaMinVersion>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<PackageReference Include="Akka" Version="$(AkkaVersion)" />
12+
<PackageReference Include="Akka.Remote" Version="$(AkkaVersion)" />
13+
<PackageReference Include="Akka.Streams" Version="$(AkkaVersion)" />
14+
<PackageReference Include="Akka.DependencyInjection" Version="$(AkkaVersion)" />
15+
<PackageReference Include="Akka.Logger.NLog" Version="$(AkkaMinVersion)" />
16+
<PackageReference Include="Akka.Persistence.RavenDB" Version="$(AkkaPersistenceVersion)" />
17+
<PackageReference Include="Akka.Persistence.RavenDB.Hosting" Version="$(AkkaPersistenceVersion)" />
18+
<PackageReference Include="Flurl.Http" Version="4.0.2" />
19+
<PackageReference Include="Microsoft.ML.TimeSeries" Version="3.0.1" />
20+
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.9" />
21+
<PackageReference Include="NLog" Version="5.4.0" />
22+
<PackageReference Include="RavenDB.Client" Version="7.0.1" />
23+
</ItemGroup>
24+
<ItemGroup>
25+
<Folder Include="MCP\" />
26+
</ItemGroup>
27+
<ItemGroup Label="MLPricePredictionModel">
28+
<None Include="MLPricePredictionModel.mlnet">
29+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
30+
</None>
31+
</ItemGroup>
32+
</Project>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// This file was auto-generated by ML.NET Model Builder.
2+
3+
using Microsoft.ML;
4+
using Microsoft.ML.Data;
5+
using System;
6+
using System.Linq;
7+
using System.IO;
8+
using System.Collections.Generic;
9+
using Microsoft.ML.Transforms.TimeSeries;
10+
11+
namespace ActorLib
12+
{
13+
public partial class MLPricePredictionModel
14+
{
15+
/// <summary>
16+
/// model input class for MLPricePredictionModel.
17+
/// </summary>
18+
#region model input class
19+
public class ModelInput
20+
{
21+
[LoadColumn(1)]
22+
[ColumnName(@"Price")]
23+
public float Price { get; set; }
24+
25+
}
26+
27+
#endregion
28+
29+
/// <summary>
30+
/// model output class for MLPricePredictionModel.
31+
/// </summary>
32+
#region model output class
33+
public class ModelOutput
34+
{
35+
[ColumnName(@"Price")]
36+
public float[] Price { get; set; }
37+
38+
[ColumnName(@"Price_LB")]
39+
public float[] Price_LB { get; set; }
40+
41+
[ColumnName(@"Price_UB")]
42+
public float[] Price_UB { get; set; }
43+
44+
}
45+
46+
#endregion
47+
48+
private static string MLNetModelPath = Path.GetFullPath(@"D:\Code\Webnori\NetCoreLabs\ActorLib\MLPricePredictionModel.mlnet");
49+
50+
public static readonly Lazy<TimeSeriesPredictionEngine<ModelInput, ModelOutput>> PredictEngine = new Lazy<TimeSeriesPredictionEngine<ModelInput, ModelOutput>>(() => CreatePredictEngine(), true);
51+
52+
/// <summary>
53+
/// Use this method to predict on <see cref="ModelInput"/>.
54+
/// </summary>
55+
/// <param name="input">model input.</param>
56+
/// <returns><seealso cref=" ModelOutput"/></returns>
57+
public static ModelOutput Predict(ModelInput? input = null, int? horizon = null)
58+
{
59+
var predEngine = PredictEngine.Value;
60+
return predEngine.Predict(input, horizon);
61+
}
62+
63+
private static TimeSeriesPredictionEngine<ModelInput, ModelOutput> CreatePredictEngine()
64+
{
65+
var mlContext = new MLContext();
66+
ITransformer mlModel = mlContext.Model.Load(MLNetModelPath, out var schema);
67+
return mlModel.CreateTimeSeriesEngine<ModelInput, ModelOutput>(mlContext);
68+
}
69+
}
70+
}
71+
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
"Scenario": "Forecasting",
3+
"DataSource": {
4+
"Version": 3,
5+
"EscapeCharacter": "\"",
6+
"ReadMultiLines": false,
7+
"KeepDiacritics": false,
8+
"KeepPunctuations": false,
9+
"AllowQuoting": false,
10+
"Type": "TabularFile",
11+
"FilePath": "D:\\BI\\가격예측\\전체월별매출.CSV",
12+
"Delimiter": ",",
13+
"DecimalMarker": ".",
14+
"HasHeader": true,
15+
"ColumnProperties": [
16+
{
17+
"ColumnName": "Date",
18+
"ColumnPurpose": "Feature",
19+
"ColumnDataFormat": "String",
20+
"IsCategorical": false,
21+
"Type": "Column",
22+
"Version": 5
23+
},
24+
{
25+
"ColumnName": "Price",
26+
"ColumnPurpose": "Feature",
27+
"ColumnDataFormat": "Single",
28+
"IsCategorical": false,
29+
"Type": "Column",
30+
"Version": 5
31+
}
32+
]
33+
},
34+
"Environment": {
35+
"Type": "LocalCPU",
36+
"Version": 1
37+
},
38+
"RunHistory": {
39+
"Version": 3,
40+
"Type": "Result",
41+
"Trials": [
42+
{
43+
"Version": 1,
44+
"Type": "Trial",
45+
"TrainerName": "ForecastBySsa",
46+
"Score": 13626.667831355951,
47+
"RuntimeInSeconds": 0.056,
48+
"Parameter": {
49+
"_SCHEMA_": "e0",
50+
"e0": {
51+
"WindowSize": 2,
52+
"SeriesLength": 10,
53+
"TrainSize": 17,
54+
"Horizon": 20,
55+
"OutputColumnName": "Price",
56+
"InputColumnName": "Price",
57+
"ConfidenceLowerBoundColumn": "Price_LB",
58+
"ConfidenceUpperBoundColumn": "Price_UB"
59+
}
60+
}
61+
},
62+
{
63+
"Version": 1,
64+
"Type": "Trial",
65+
"TrainerName": "ForecastBySsa",
66+
"Score": 13626.667831355951,
67+
"RuntimeInSeconds": 0.002,
68+
"Parameter": {
69+
"_SCHEMA_": "e0",
70+
"e0": {
71+
"WindowSize": 2,
72+
"SeriesLength": 2712,
73+
"TrainSize": 17,
74+
"Horizon": 20,
75+
"OutputColumnName": "Price",
76+
"InputColumnName": "Price",
77+
"ConfidenceLowerBoundColumn": "Price_LB",
78+
"ConfidenceUpperBoundColumn": "Price_UB"
79+
}
80+
}
81+
},
82+
{
83+
"Version": 1,
84+
"Type": "Trial",
85+
"TrainerName": "ForecastBySsa",
86+
"Score": 13626.667831355951,
87+
"RuntimeInSeconds": 0.003,
88+
"Parameter": {
89+
"_SCHEMA_": "e0",
90+
"e0": {
91+
"WindowSize": 2,
92+
"SeriesLength": 978,
93+
"TrainSize": 17,
94+
"Horizon": 20,
95+
"OutputColumnName": "Price",
96+
"InputColumnName": "Price",
97+
"ConfidenceLowerBoundColumn": "Price_LB",
98+
"ConfidenceUpperBoundColumn": "Price_UB"
99+
}
100+
}
101+
},
102+
{
103+
"Version": 1,
104+
"Type": "Trial",
105+
"TrainerName": "ForecastBySsa",
106+
"Score": 13626.667831355951,
107+
"RuntimeInSeconds": 0.002,
108+
"Parameter": {
109+
"_SCHEMA_": "e0",
110+
"e0": {
111+
"WindowSize": 2,
112+
"SeriesLength": 437,
113+
"TrainSize": 17,
114+
"Horizon": 20,
115+
"OutputColumnName": "Price",
116+
"InputColumnName": "Price",
117+
"ConfidenceLowerBoundColumn": "Price_LB",
118+
"ConfidenceUpperBoundColumn": "Price_UB"
119+
}
120+
}
121+
},
122+
{
123+
"Version": 1,
124+
"Type": "Trial",
125+
"TrainerName": "ForecastBySsa",
126+
"Score": 13626.667831355951,
127+
"RuntimeInSeconds": 0.002,
128+
"Parameter": {
129+
"_SCHEMA_": "e0",
130+
"e0": {
131+
"WindowSize": 2,
132+
"SeriesLength": 31,
133+
"TrainSize": 17,
134+
"Horizon": 20,
135+
"OutputColumnName": "Price",
136+
"InputColumnName": "Price",
137+
"ConfidenceLowerBoundColumn": "Price_LB",
138+
"ConfidenceUpperBoundColumn": "Price_UB"
139+
}
140+
}
141+
}
142+
],
143+
"Estimators": {
144+
"e0": "ForecastBySsa"
145+
},
146+
"Schema": "e0",
147+
"MetricName": "RMSE",
148+
"ModelFilePath": "D:\\Code\\Webnori\\NetCoreLabs\\ActorLib\\MLPricePredictionModel.mlnet"
149+
},
150+
"Type": "TrainingConfig",
151+
"Version": 5,
152+
"TrainingOption": {
153+
"Version": 3,
154+
"OptimizeMetric": "RMSE",
155+
"Subsampling": false,
156+
"Tuner": "eci-cfo",
157+
"Type": "ForecastingTrainingOption",
158+
"TrainingTime": 10,
159+
"UseCrossValidation": false,
160+
"Horizon": 20,
161+
"TimeColumn": "Date",
162+
"LabelColumn": "Price",
163+
"UseDefaultIndex": false,
164+
"ValidationOption": {
165+
"Version": 0,
166+
"Type": "CrossValidationValidationOption",
167+
"NumberOfFolds": 5
168+
}
169+
}
170+
}

0 commit comments

Comments
 (0)