Skip to main content
Glama
PyMC Marketing MCP

PyMC Marketing MCP

by funnelscript

Fit Purchase Model

fit_purchase_model

Fit Bayesian BG/NBD or shifted beta-geometric purchase-frequency models to RFM data, with automatic column normalization for customer transaction analysis.

Instructions

Fit a Bayesian purchase/transaction frequency model (BG/NBD or Shifted Beta-Geometric). Normalizes user column names to canonical RFM attributes.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "config": "<config>"
    },
    "name": "fit_purchase_model"
  }
}

Input Schema

NameRequiredDescriptionDefault
configYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changed
    • removedInput schema / $defs
      Removed value: -{
      -  "FitPurchaseModelInput": {
      -    "properties": {
      -      "T_col": {
      -        "default": "T",
      -        "description": "Column with total observation period length",
      -        "title": "T Col",
      -        "type": "string"
      -      },
      -      "cohort_col": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Column with customer cohort (required for sBG)",
      -        "title": "Cohort Col"
      -      },
      -      "customer_id_col": {
      -        "default": "customer_id",
      -        "description": "Column containing unique customer identifiers",
      -        "title": "Customer Id Col",
      -        "type": "string"
      -      },
      -      "dataset_id": {
      -        "description": "Registered dataset ID containing RFM data",
      -        "title": "Dataset Id",
      -        "type": "string"
      -      },
      -      "frequency_col": {
      -        "default": "frequency",
      -        "description": "Column with repeat purchase count",
      -        "title": "Frequency Col",
      -        "type": "string"
      -      },
      -      "model_type": {
      -        "default": "bg_nbd",
      -        "description": "Purchase model type: 'bg_nbd' (continuous) or 'shifted_beta_geo' (contractual subscription)",
      -        "enum": [
      -          "bg_nbd",
      -          "shifted_beta_geo"
      -        ],
      -        "title": "Model Type",
      -        "type": "string"
      -      },
      -      "recency_col": {
      -        "default": "recency",
      -        "description": "Column with recency (time since last purchase)",
      -        "title": "Recency Col",
      -        "type": "string"
      -      },
      -      "sampler": {
      -        "$ref": "#/$defs/SamplerConfig"
      -      }
      -    },
      -    "required": [
      -      "dataset_id"
      -    ],
      -    "title": "FitPurchaseModelInput",
      -    "type": "object"
      -  },
      -  "SamplerConfig": {
      -    "properties": {
      -      "chains": {
      -        "default": 4,
      -        "description": "Number of MCMC chains",
      -        "maximum": 8,
      -        "minimum": 2,
      -        "title": "Chains",
      -        "type": "integer"
      -      },
      -      "draws": {
      -        "default": 1000,
      -        "description": "Posterior draws per chain",
      -        "maximum": 20000,
      -        "minimum": 50,
      -        "title": "Draws",
      -        "type": "integer"
      -      },
      -      "random_seed": {
      -        "default": 42,
      -        "description": "Deterministic random seed",
      -        "title": "Random Seed",
      -        "type": "integer"
      -      },
      -      "target_accept": {
      -        "default": 0.9,
      -        "description": "Target acceptance rate for NUTS",
      -        "maximum": 0.999,
      -        "minimum": 0.8,
      -        "title": "Target Accept",
      -        "type": "number"
      -      },
      -      "tune": {
      -        "default": 1000,
      -        "description": "Tuning/warmup iterations per chain",
      -        "maximum": 20000,
      -        "minimum": 50,
      -        "title": "Tune",
      -        "type": "integer"
      -      }
      -    },
      -    "title": "SamplerConfig",
      -    "type": "object"
      -  }
      -}
    • addedInput schema / additionalProperties
      Added value: +false
    • removedInput schema / properties / config / $ref
      Removed value: -"#/$defs/FitPurchaseModelInput"
    • addedInput schema / properties / config / properties
      Added value: +{
      +  "T_col": {
      +    "default": "T",
      +    "description": "Column with total observation period length",
      +    "title": "T Col",
      +    "type": "string"
      +  },
      +  "cohort_col": {
      +    "default": null,
      +    "description": "Column with customer cohort (required for sBG)",
      +    "title": "Cohort Col",
      +    "type": "string"
      +  },
      +  "customer_id_col": {
      +    "default": "customer_id",
      +    "description": "Column containing unique customer identifiers",
      +    "title": "Customer Id Col",
      +    "type": "string"
      +  },
      +  "dataset_id": {
      +    "description": "Registered dataset ID containing RFM data",
      +    "title": "Dataset Id",
      +    "type": "string"
      +  },
      +  "frequency_col": {
      +    "default": "frequency",
      +    "description": "Column with repeat purchase count",
      +    "title": "Frequency Col",
      +    "type": "string"
      +  },
      +  "model_type": {
      +    "default": "bg_nbd",
      +    "description": "Purchase model type: 'bg_nbd' (continuous) or 'shifted_beta_geo' (contractual subscription)",
      +    "enum": [
      +      "bg_nbd",
      +      "shifted_beta_geo"
      +    ],
      +    "title": "Model Type",
      +    "type": "string"
      +  },
      +  "recency_col": {
      +    "default": "recency",
      +    "description": "Column with recency (time since last purchase)",
      +    "title": "Recency Col",
      +    "type": "string"
      +  },
      +  "sampler": {
      +    "properties": {
      +      "chains": {
      +        "default": 4,
      +        "description": "Number of MCMC chains",
      +        "maximum": 8,
      +        "minimum": 2,
      +        "title": "Chains",
      +        "type": "integer"
      +      },
      +      "draws": {
      +        "default": 1000,
      +        "description": "Posterior draws per chain",
      +        "maximum": 20000,
      +        "minimum": 50,
      +        "title": "Draws",
      +        "type": "integer"
      +      },
      +      "random_seed": {
      +        "default": 42,
      +        "description": "Deterministic random seed",
      +        "title": "Random Seed",
      +        "type": "integer"
      +      },
      +      "target_accept": {
      +        "default": 0.9,
      +        "description": "Target acceptance rate for NUTS",
      +        "maximum": 0.999,
      +        "minimum": 0.8,
      +        "title": "Target Accept",
      +        "type": "number"
      +      },
      +      "tune": {
      +        "default": 1000,
      +        "description": "Tuning/warmup iterations per chain",
      +        "maximum": 20000,
      +        "minimum": 50,
      +        "title": "Tune",
      +        "type": "integer"
      +      }
      +    },
      +    "title": "SamplerConfig",
      +    "type": "object"
      +  }
      +}
    • addedInput schema / properties / config / required
      Added value: +[
      +  "dataset_id"
      +]
    • addedInput schema / properties / config / title
      Added value: +"FitPurchaseModelInput"
    • addedInput schema / properties / config / type
      Added value: +"object"
  2. First observedv0.4.0

TDQS

B3.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=false, idempotentHint=false, and destructiveHint=false, so the agent knows this creates artifacts without destroying data. The description adds one genuinely useful behavioral detail beyond that: it normalizes user column names to canonical RFM attributes, implying arbitrary input column names are acceptable. It omits important traits: MCMC fitting is likely long-running, and it does not say whether the call blocks or returns a job/model handle, nor whether a fitted model artifact is persisted.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two front-loaded sentences with no filler: the modeling action comes first, the column-normalization side effect second. Nothing is redundant or padded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool this heavy (nested sampler config with chains/draws/tune, two model families, one required but undescribed config object) the description is thin: no return value, no indication of synchronous versus job-based execution despite siblings like get_model_status and submit_fit_mmm_job, and no runtime expectations. The rich nested schema offsets some of this, but the absence of an output schema leaves the agent guessing at what a successful fit yields.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Top-level coverage is 0% (the single 'config' parameter is undocumented), though the nested properties carry their own descriptions including the model_type enum meanings. The sentence about normalizing user column names adds real meaning for the *_col parameters, telling the agent custom column names are remapped rather than rejected. It says nothing about dataset_id, the sampler settings, or cohort_col being required for sBG.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource ('Fit a Bayesian purchase/transaction frequency model') and names the two concrete model families (BG/NBD, Shifted Beta-Geometric), which distinguishes it from value/CLV/Bass-fitting siblings by resource type. It stops short of explicitly contrasting itself with fit_bass_model or fit_clv_model, so an agent must still infer the boundary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no when-to-use or when-not-to-use guidance: nothing says what data must be prepared, when to prefer this over fit_clv_model or fit_value_model, or when to pick BG/NBD versus sBG (that distinction only appears in the schema's model_type description). The agent gets what the tool does but not the conditions that select it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.