public FactStrategyPlanClusteringDTO TestModelKMeans(FactStrategyPlanClusteringDTO factStrategyPlanClusteringDTO) { _mlContext = new MLContext(); var sampleFactStrategyPlanClusteringData = new FactStrategyPlanClusteringData() { EntityKey = factStrategyPlanClusteringDTO.EntityKey, ScenarioKey = factStrategyPlanClusteringDTO.ScenarioKey, AccountKey = factStrategyPlanClusteringDTO.AccountKey, ProductCategoryKey = factStrategyPlanClusteringDTO.ProductCategoryKey }; ITransformer model = _mlContext.Model.Load(LoadingConfiguration.FactStrategyPlanClusteringModelPath, out var modelInputSchema); // Create prediction engine related to the loaded trained model var predEngine = _mlContext.Model.CreatePredictionEngine <FactStrategyPlanClusteringData, FactStrategyPlanClusteringPredict>(model); //Score var result = predEngine.Predict(sampleFactStrategyPlanClusteringData); factStrategyPlanClusteringDTO.AmountKeys = result.Amount; factStrategyPlanClusteringDTO.SelectedClusterId = result.SelectedClusterId; predEngine.Dispose(); return(factStrategyPlanClusteringDTO); }
public ClusteringService(ContosoRetailDWContext context) { _context = context; _factStrategyPlanClusteringDTO = new FactStrategyPlanClusteringDTO(); }