Esempio n. 1
0
        static async void LogRun(int experimentId, ExperimentResult <MulticlassClassificationMetrics> experimentResults)
        {
            // Define run
            var runObject = new CreateRunRequest();

            runObject.ExperimentId = experimentId;
            runObject.StartTime    = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds();
            runObject.UserId       = Environment.UserName;
            runObject.SourceType   = SourceType.LOCAL;

            // Create new run in MLFlow
            var runRequest = await _mlFlowService.CreateRun(runObject);

            // Get information for best run
            var runDetails = experimentResults.BestRun;

            // Log trainer name
            await _mlFlowService.LogParameter(runRequest.Run.Info.RunUuid, nameof(runDetails.TrainerName), runDetails.TrainerName);

            // Log metrics
            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.RuntimeInSeconds), (float)runDetails.RuntimeInSeconds);

            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.ValidationMetrics.LogLoss), (float)runDetails.ValidationMetrics.LogLoss);

            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.ValidationMetrics.MacroAccuracy), (float)runDetails.ValidationMetrics.MacroAccuracy);

            await _mlFlowService.LogMetric(runRequest.Run.Info.RunUuid, nameof(runDetails.ValidationMetrics.MicroAccuracy), (float)runDetails.ValidationMetrics.MicroAccuracy);
        }
        public async Task LogTestResultAsync(ITestResult result)
        {
            var expId = configuration["MLFlow:ExperimentId"] ?? "default";
            // var expId = Guid.NewGuid().ToString();
            var userId = configuration["MLFlow:UserId"] ?? "defaultuser";

            if (result.Id == null)
            {
                throw new NullReferenceException("ResultId cannot be null");
            }

            var exp = await mlflowService.CreateExperiment(expId) ?? new CreateResponse
            {
                ExperimentId = 1
            };

            logger.Log($"Using experiment id: {exp.ExperimentId}");

            var run = await CreateRun(exp.ExperimentId, result.Id);

            if (run == null)
            {
                throw new Exception("Could not create run in MLFlow. Please make sure MLFlow is running.");
            }

            await mlflowService.LogMetric(run.Run.Info.RunUuid, "percentage_passed", (float)result.PercentagePassed);

            await mlflowService.LogMetric(run.Run.Info.RunUuid, "total_tested", (float)result.TotalTested);

            foreach (var p in result.Parameters)
            {
                await mlflowService.LogParameter(run.Run.Info.RunUuid, p.Key, p.Value);
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> Index()
        {
            var newExperiment = await this.flowService.GetOrCreateExperiment("New_Experiement");

            var experimentId = newExperiment.ExperimentId;

            var userId         = "azadeh khojandi";
            var runName        = "this is a run name";
            var sourceType     = SourceType.NOTEBOOK;
            var sourceName     = "String descriptor for the run’s source";
            var entryPointName = "Name of the project entry point associated with the current run, if any.";
            var startTime      = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds(); //unix timestamp



            RunTag[] tags = { new RunTag()
                              {
                                  Key = "testkey", Value = "testvalue"
                              } };

            var createRunRequest = new CreateRunRequest()
            {
                ExperimentId   = experimentId,
                UserId         = userId,
                Runname        = runName,
                SourceType     = sourceType,
                SourceName     = sourceName,
                EntryPointName = entryPointName,
                StartTime      = startTime,
                Tags           = tags
            };

            var runResult = await flowService.CreateRun(createRunRequest);

            var logResultMetric = await flowService
                                  .LogMetric(
                runResult.Run.Info.RunUuid,
                "Somekey", 1234);

            var logResultParam = await flowService
                                 .LogParameter(
                runResult.Run.Info.RunUuid,
                "Somekey", "some parameter");

            ViewData["ExperimentId"] = experimentId;
            ViewData["RunId"]        = runResult.Run.Info.RunUuid;

            return(View());
        }