PotatoPlan/Game1/Sources/ML_Joel/Engine.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2020-05-24 01:57:27 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ML;
namespace Game1.Sources.ML_Joel
{
static class Engine
{
private static MLContext mlContext = new MLContext(seed: 1);
2020-05-24 21:00:54 +02:00
private static PredictionEngine<Input, Output> PredictionEngine;
private static PredictionEngine<InputArea, OutputArea> PredictionEngineArea;
2020-05-24 01:57:27 +02:00
public static void CreateModel()
{
Model.CreateModel();
}
2020-05-24 21:00:54 +02:00
public static void CreateModelArea()
{
Model.CreateModelArea();
}
2020-05-24 01:57:27 +02:00
public static void init()
{
2020-05-24 21:00:54 +02:00
PredictionEngine = Model.CreateEngine();
}
public static void initArea()
{
PredictionEngineArea = Model.CreateEngineArea();
2020-05-24 01:57:27 +02:00
}
2020-05-24 21:00:54 +02:00
public static float PredictProductionwithRainfall(Crops crop, CropTypes cropTypes)
2020-05-24 01:57:27 +02:00
{
2020-05-24 21:00:54 +02:00
InputArea modelInput = new InputArea
2020-05-24 01:57:27 +02:00
{
2020-05-24 21:00:54 +02:00
//Season = ,
//Area = crop.getSoilProperties().Area,
Rainfall = crop.getSoilProperties().Humidity,
2020-05-24 01:57:27 +02:00
};
2020-05-24 21:00:54 +02:00
return PredictionEngineArea.Predict(modelInput).Score;
2020-05-24 01:57:27 +02:00
}
}
}