예제 #1
0
        public Insert2 GetModelStatus(ProjectModelId projectModelId)
        {
            var     getRequest = PredictionService.Trainedmodels.Get(projectModelId.ProjectNumber, projectModelId.ModelId);
            Insert2 response   = getRequest.Execute();

            return(response);
        }
예제 #2
0
        public void Run()
        {
            Insert2 trainingStatus = m_predictionFramework.GetModelStatus(ProjectModelId);

            Console.WriteLine("Training status: {0}", trainingStatus.TrainingStatus);
            ToConsole(trainingStatus.ModelInfo);
        }
예제 #3
0
 private static void ToConsole(Insert2.ModelInfoData modelInfoData)
 {
     if (modelInfoData != null)
     {
         Console.WriteLine("ModelType: {0}", modelInfoData.ModelType);
         Console.WriteLine("NumberInstances: {0}", modelInfoData.NumberInstances);
         Console.WriteLine("MeanSquaredError: {0}", modelInfoData.MeanSquaredError);
     }
 }
예제 #4
0
        public Insert2 TrainRegressionModel(ProjectModelId projectModelId, string csvDataPathInStorage)
        {
            Insert insertBody = new Insert
            {
                StorageDataLocation = csvDataPathInStorage,
                Id        = projectModelId.ModelId,
                ModelType = "REGRESSION",
            };

            TrainedmodelsResource.InsertRequest insertRequest = PredictionService.Trainedmodels.Insert(insertBody, projectModelId.ProjectNumber);
            Insert2 insertResponse = insertRequest.Execute();

            return(insertResponse);
        }
예제 #5
0
        public void Run()
        {
            Console.WriteLine("Model '{0}' deleted with response '{1}'.", ProjectModelId.ModelId, m_predictionFramework.DeleteTrainedModel(ProjectModelId));
            Insert2 insertResponse = m_predictionFramework.TrainRegressionModel(ProjectModelId, m_storageData);

            Console.WriteLine("Inserted the training data for the model.");

            // Wait until the training is complete
            bool trainingRunning = true;

            while (trainingRunning)
            {
                Console.WriteLine("Getting a new training progress status...");
                var getResponse = m_predictionFramework.GetModelStatus(ProjectModelId);
                Console.WriteLine("Got a new training progress status: {0}", getResponse.TrainingStatus);

                switch (getResponse.TrainingStatus)
                {
                case "RUNNING":
                    Console.WriteLine("The model training is still in progress, let us wait for {0} ms.", PROGRESS_WAITING_TIME);
                    Thread.Sleep(PROGRESS_WAITING_TIME);
                    break;

                case "DONE":
                    Console.WriteLine("The model has been trained successfully.");
                    ToConsole(getResponse.ModelInfo);
                    trainingRunning = false;
                    break;

                case "ERROR: TRAINING JOB NOT FOUND":
                    throw new Exception("the training job was not found.");

                case "ERROR: TOO FEW INSTANCES IN DATASET":
                    throw new Exception("there are too few instances in the dataset.");

                default:
                    throw new ArgumentException("Unknown status (error): " + getResponse.TrainingStatus);
                }
            }
        }