{
  "$id": "https://schema.rtemis.org/preprocessor/v1/schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "rtemis PreprocessorConfig",
  "description": "Language-independent config for rtemis preprocessing. The same config drives rtemis (R), rtemis CLI/shell, and rtemislive to identical output.",
  "type": "object",
  "properties": {
    "$schema": {
      "description": "JSON Schema URI for this config instance.",
      "type": "string",
      "const": "https://schema.rtemis.org/preprocessor/v1/schema.json"
    },
    "complete_cases": {
      "description": "Retain only complete cases.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "remove_features_thres": {
      "description": "Remove features missing in >= this fraction of cases.",
      "type": ["number", "null"],
      "maximum": 1,
      "exclusiveMinimum": 0,
      "x-rtemis": {
        "type": "number"
      }
    },
    "remove_cases_thres": {
      "description": "Remove cases missing >= this fraction of features.",
      "type": ["number", "null"],
      "maximum": 1,
      "exclusiveMinimum": 0,
      "x-rtemis": {
        "type": "number"
      }
    },
    "missingness": {
      "description": "Add a boolean missingness indicator per feature with NAs.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "impute": {
      "description": "Impute missing values.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "impute_type": {
      "description": "Imputation method.",
      "type": "string",
      "enum": ["missRanger", "micePMM", "meanMode"],
      "x-rtemis": {
        "type": "string"
      }
    },
    "impute_missRanger_params": {
      "description": "Parameters passed to missRanger (e.g. pmm.k, maxiter, num.trees).",
      "type": "object",
      "x-rtemis": {
        "type": "object"
      }
    },
    "impute_discrete": {
      "description": "Function name to impute discrete features.",
      "type": "string",
      "x-rtemis": {
        "type": "string"
      }
    },
    "impute_continuous": {
      "description": "Function name to impute continuous features.",
      "type": "string",
      "x-rtemis": {
        "type": "string"
      }
    },
    "integer2factor": {
      "description": "Convert integers to factors.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "integer2numeric": {
      "description": "Convert integers to numeric.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "logical2factor": {
      "description": "Convert logicals to factors.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "logical2numeric": {
      "description": "Convert logicals to numeric.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "numeric2factor": {
      "description": "Convert numeric to factors.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "numeric2factor_levels": {
      "description": "Factor levels for numeric2factor.",
      "type": ["array", "null"],
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "x-rtemis": {
        "type": "string",
        "container": "array"
      }
    },
    "numeric_cut_n": {
      "description": "Cut numeric features into this many bins (0 = off).",
      "type": "integer",
      "minimum": 0,
      "x-rtemis": {
        "type": "integer"
      }
    },
    "numeric_cut_labels": {
      "description": "Use labels for numeric_cut bins.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "numeric_quant_n": {
      "description": "Cut numeric features into this many quantile bins (0 = off).",
      "type": "integer",
      "minimum": 0,
      "x-rtemis": {
        "type": "integer"
      }
    },
    "numeric_quant_NAonly": {
      "description": "Quantile-cut only features with NAs.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "unique_len2factor": {
      "description": "Convert features with <= this many unique values to factors (0 = off).",
      "type": "integer",
      "minimum": 0,
      "x-rtemis": {
        "type": "integer"
      }
    },
    "character2factor": {
      "description": "Convert character features to factors.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "factorNA2missing": {
      "description": "Convert factor NAs to a 'missing' level.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "factorNA2missing_level": {
      "description": "Level name for factorNA2missing.",
      "type": "string",
      "x-rtemis": {
        "type": "string"
      }
    },
    "factor2integer": {
      "description": "Convert factors to integers.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "factor2integer_startat0": {
      "description": "factor2integer starts at 0.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "factor2integer_levels": {
      "description": "Per-feature factor2integer levels, keyed by feature name.",
      "type": ["object", "null"],
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "minItems": 1,
        "x-rtemis": {
          "type": "string",
          "container": "array"
        }
      },
      "x-rtemis": {
        "type": "string",
        "container": "map",
        "data_dependent": true
      },
      "$comment": "Data-dependent: one entry per feature, keyed by feature name, so it cannot be filled in without the data."
    },
    "scale": {
      "description": "Scale features.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "center": {
      "description": "Center features.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "scale_centers": {
      "description": "Per-feature centering values, keyed by feature name.",
      "type": ["object", "null"],
      "additionalProperties": {
        "type": "number",
        "x-rtemis": {
          "type": "number"
        }
      },
      "x-rtemis": {
        "type": "number",
        "container": "map",
        "data_dependent": true
      },
      "$comment": "Data-dependent: one entry per feature, keyed by feature name, so it cannot be filled in without the data."
    },
    "scale_coefficients": {
      "description": "Per-feature scaling values, keyed by feature name.",
      "type": ["object", "null"],
      "additionalProperties": {
        "type": "number",
        "x-rtemis": {
          "type": "number"
        }
      },
      "x-rtemis": {
        "type": "number",
        "container": "map",
        "data_dependent": true
      },
      "$comment": "Data-dependent: one entry per feature, keyed by feature name, so it cannot be filled in without the data."
    },
    "remove_constants": {
      "description": "Remove constant features.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "remove_constants_skip_missing": {
      "description": "Ignore missing values when detecting constants.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "remove_duplicates": {
      "description": "Remove duplicate cases.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "remove_features": {
      "description": "Names of features to remove.",
      "type": ["array", "null"],
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "x-rtemis": {
        "type": "string",
        "container": "array"
      }
    },
    "one_hot": {
      "description": "One-hot encode factors.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "one_hot_levels": {
      "description": "Per-feature one-hot levels, keyed by feature name.",
      "type": ["object", "null"],
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "minItems": 1,
        "x-rtemis": {
          "type": "string",
          "container": "array"
        }
      },
      "x-rtemis": {
        "type": "string",
        "container": "map",
        "data_dependent": true
      },
      "$comment": "Data-dependent: one entry per feature, keyed by feature name, so it cannot be filled in without the data."
    },
    "add_date_features": {
      "description": "Add date-derived features.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "date_features": {
      "description": "Date features to add.",
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["weekday", "month", "year"]
      },
      "minItems": 1,
      "x-rtemis": {
        "type": "string",
        "container": "array"
      }
    },
    "add_holidays": {
      "description": "Add a holiday indicator feature.",
      "type": "boolean",
      "x-rtemis": {
        "type": "boolean"
      }
    },
    "holidays": {
      "description": "Holidays to flag, named as timeDate holiday functions.",
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "uniqueItems": true,
      "x-rtemis": {
        "type": "string",
        "container": "array"
      }
    },
    "exclude": {
      "description": "Column indices to exclude from preprocessing.",
      "type": ["array", "null"],
      "items": {
        "type": "integer"
      },
      "minItems": 1,
      "x-rtemis": {
        "type": "integer",
        "container": "array"
      }
    }
  },
  "additionalProperties": false
}
