← Machine Learning Academy

Machine Learning Academy · 5 / 5

Add a training-data quality gate

Consolidate the model and leave publication for a reviewed training result.

YOUR TASK

Make this happen

3 steps
  1. Add a second normalization stage named nonnegative-quantity loading scripts/quality.lua. Drop nil or negative quantity, return input otherwise. Keep autoPublish false and all earlier stages for platform evaluation.

  2. Keep the working capabilities from the previous lesson and connect the new pieces to the same solution.

  3. Check the complete solution, then inspect any unmet requirements.

This step starts with the earlier solution and one new challenge. Each lesson keeps its own draft.

Read the starter files

main.cococo

ml_model_document "main" {
  format = "1"
  name = "job-quantity"
  backend = "xgboost"
  spec = {
    tabular = ml_model_tabular.quantity
  }
  dataQuerySQL = file("queries/training.sql")
}

model.cococo

ml_model_tabular "quantity" {
  task = "REGRESSION"
  targetColumn = "quantity"
  featureColumns = [ml_model_feature.priority]
  normalizationStages = [ml_model_normalization_stage.clean]
  hyperparameters = ml_model_hyperparameters.baseline
}

features.cococo

ml_model_feature "priority" {
  column = "priority"
}

queries/training.sql

SELECT quantity, priority FROM jobs WHERE quantity IS NOT NULL LIMIT 1000

normalize.cococo

ml_model_normalization_stage "clean" {
  name = "require-priority"
  source = file("scripts/normalize.lua")
}

scripts/normalize.lua

if input.priority == nil then return nil end
return { quantity = input.quantity, priority = input.priority }

tuning.cococo

ml_model_hyperparameters "baseline" {
  maxDepth = 3
  eta = 0.1
  rounds = 100
  evalMetric = "rmse"
}

quality.cococo

ml_model_normalization_stage "valid_quantity" {
  name = "nonnegative-quantity"
  # Source file supplied for this field: scripts/quality.lua
  # TODO: attach it with source = file(...).
}

scripts/quality.lua

-- input is the row from the previous normalization stage.
-- TODO: reject missing or negative quantity before returning accepted rows.
return input
Supplied supporting files

Reference: machine-learning · authoring