1
0
forked from s425077/PotatoPlan
PotatoPlan/Game1/Sources/ML/Engine.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2020-05-10 01:38:08 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ML;
static class Engine
{
private static MLContext mlContext = new MLContext(seed: 1);
2020-05-10 12:55:13 +02:00
private static PredictionEngine<ModelInput, ModelOutput> PredictionEngine;
2020-06-14 18:01:51 +02:00
private static ModelOutput modelOutput;
2020-05-10 12:55:13 +02:00
public static void init()
{
PredictionEngine = MLModel.CreateEngine();
}
2020-05-10 01:38:08 +02:00
public static string PredictFertilizer(Crops crop, CropTypes cropTypes)
{
ModelInput modelInput = new ModelInput
{
Temperature = crop.getSoilProperties().Temperature,
Humidity = crop.getSoilProperties().Humidity,
Moisture = crop.getSoilProperties().Moisture,
Soil_Type = crop.getSoilProperties().soilType,
Crop_Type = cropTypes.CropName,
Nitrogen = crop.getSoilProperties().Nitrogen,
Potassium = crop.getSoilProperties().Potassium,
Phosporous = crop.getSoilProperties().Phosphorous
};
2020-06-14 18:01:51 +02:00
//ModelOutput modelOutput = new ModelOutput();
2020-05-25 11:07:58 +02:00
PredictionEngine.Predict(modelInput, ref modelOutput);
return modelOutput.Prediction;
2020-05-10 01:38:08 +02:00
}
}