45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
|
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);
|
|||
|
private static PredictionEngine<ModelInput, ModelOutput> PredictionEngine;
|
|||
|
|
|||
|
public static void CreateModel()
|
|||
|
{
|
|||
|
Model.CreateModel();
|
|||
|
}
|
|||
|
|
|||
|
public static void init()
|
|||
|
{
|
|||
|
PredictionEngine = MLModel.CreateEngine();
|
|||
|
}
|
|||
|
|
|||
|
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
|
|||
|
};
|
|||
|
|
|||
|
return PredictionEngine.Predict(modelInput).Prediction;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|