{
  "slug": "target-mean-encoder",
  "name": "gizza-ai/target-mean-encoder",
  "version": "0.1.0",
  "title": "Target Mean Encoder — Encode CSV Categories by Target Mean — gizza.ai",
  "description": "Replace a CSV categorical column with the per-category mean of a numeric target. Supports smoothing, leave-one-out, replace or append output, and unknown handling.",
  "tags": [
    "target encoding",
    "mean encoding",
    "impact encoding",
    "categorical encoding",
    "feature engineering",
    "csv encoder",
    "machine learning preprocessing"
  ],
  "category": "encoding",
  "urls": {
    "page": "https://gizza.ai/tools/target-mean-encoder/",
    "markdown": "https://gizza.ai/tools/target-mean-encoder/index.md",
    "descriptor": "https://gizza.ai/tools/target-mean-encoder/tool.json",
    "deep_link_example": "https://gizza.ai/tools/target-mean-encoder/?data=city%2Cchurn%0AA%2C1%0AB%2C1%0AA%2C0%0AB%2C1%0AC%2C1%0AB%2C0&category=city&target=churn&smoothing=0&leave_one_out=true&output=replace&unknown=global-mean&decimals=4&has_header=true&delimiter=comma"
  },
  "cli": "gizza tool target-mean-encoder \"city,churn\nA,1\nB,1\nA,0\nB,1\nC,1\nB,0\" 'category=city' 'target=churn'",
  "tool": {
    "description": "Replace a categorical CSV column with the mean of a numeric target per category, turning it into a single model-ready numeric feature (target / mean / impact encoding). Supports m-estimate smoothing toward the global mean for rare categories, leave-one-out to reduce target leakage, replace-in-place or append-new-column output, configurable handling of unknown/blank categories, decimal rounding, header or 1-based index column selection, and comma/tab/semicolon/pipe delimiters.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "category": {
          "description": "Categorical column to encode: a header name, or a 1-based column number when there is no header.",
          "type": "string"
        },
        "data": {
          "description": "CSV text to encode. The category column is replaced (or a new column appended) with the target mean per category.",
          "type": "string"
        },
        "decimals": {
          "default": 4,
          "description": "Number of decimal places for the encoded values.",
          "maximum": 15,
          "minimum": 0,
          "type": "integer"
        },
        "delimiter": {
          "default": "comma",
          "description": "CSV delimiter used to read and write the data.",
          "enum": [
            "comma",
            "tab",
            "semicolon",
            "pipe"
          ],
          "type": "string"
        },
        "has_header": {
          "default": true,
          "description": "Treat the first CSV row as headers. Turn off to select columns by 1-based number.",
          "type": "boolean"
        },
        "leave_one_out": {
          "default": false,
          "description": "Exclude each row's own target from its category statistics. Reduces target leakage when encoding a training set in place.",
          "type": "boolean"
        },
        "output": {
          "default": "replace",
          "description": "Replace the category column in place, or append a new <name>_target_enc column and keep the original.",
          "enum": [
            "replace",
            "append"
          ],
          "type": "string"
        },
        "smoothing": {
          "default": 0.0,
          "description": "m-estimate smoothing weight (m ≥ 0). Blends each category mean toward the global mean as (sum + m·prior) / (count + m). 0 means the raw category mean; higher values pull rare categories toward the overall mean.",
          "maximum": 100,
          "minimum": 0,
          "type": "number"
        },
        "target": {
          "description": "Numeric target column whose per-category mean drives the encoding: a header name, or a 1-based column number.",
          "type": "string"
        },
        "unknown": {
          "default": "global-mean",
          "description": "Value for rows whose category cell is blank or has no usable statistics: the global mean, NaN, or zero.",
          "enum": [
            "global-mean",
            "nan",
            "zero"
          ],
          "type": "string"
        }
      },
      "required": [
        "data",
        "category",
        "target"
      ],
      "type": "object"
    }
  }
}