Skip to main content
Glama

Lasso Regression

lasso_regression

Train an L1-regularized linear regression on a numeric split to shrink weak coefficients to zero and perform feature selection while returning metrics, top features, and warnings.

Instructions

Train a Lasso (L1-regularised) linear regression. It can shrink weak coefficients to exactly zero, so it also acts as feature selection. The split must have only numerical, complete features. Args: split_id (str): ID of a split made by train_test_split. alpha (float): Regularisation strength, greater than 0. Default is 1.0. If the target has a large scale (e.g. prices in the millions) a value of 1 may be too small to have any effect. fit_intercept (bool): Learn an intercept. Default is True. max_iter (int): Maximum solver iterations. Default is 10000. scale (bool): Standardise the features first. Strongly recommended. Default is True. Returns: dict: model_id, train/test metrics (R2, MAE, MSE, RMSE, MAPE), top features and warnings.

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": {
      "split_id": "<split_id>"
    },
    "name": "lasso_regression"
  }
}

Input Schema

NameRequiredDescriptionDefault
alphaNo
scaleNo
max_iterNo
split_idYes
fit_interceptNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/5

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

No annotations are supplied, so the description carries the full burden and mostly meets it: it discloses the data-type/completeness precondition, notes that scaling is strongly recommended, warns that alpha=1 may be ineffective on large-scale targets, and lists what the return dict contains including warnings. It does not say whether the fitted model is persisted or how the call mutates workspace state, which is the main remaining behavioral gap.

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

Conciseness4/5

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

Purpose and the feature-selection consequence are front-loaded, then a prerequisite, then a clean Args/Returns block — every section has a job. The Args enumeration is somewhat mechanical given the schema repeats types and defaults, but it is compensated by the caveats attached to alpha and scale.

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

Completeness4/5

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

For a five-parameter training tool with no annotations and no output schema, the definition covers the important surfaces: input data requirements, all parameters, and the return keys including metrics and warnings. It is only slightly incomplete on side effects (model persistence, overwrite behavior) and failure modes.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must carry all five parameters, and it does: split_id's provenance, alpha's meaning plus its scale-dependence caveat, fit_intercept, max_iter, and scale with a strong recommendation. The alpha-scale warning is genuine added meaning that the bare schema (default 1) cannot convey.

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

Purpose5/5

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

States a specific verb and resource ("Train a Lasso (L1-regularised) linear regression") and immediately adds the distinguishing trait: coefficients shrink to exactly zero, so it doubles as feature selection. That intrinsic L1 framing lets an agent separate it from linear_regression and ridge_regression without opening any schema.

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

Usage Guidelines4/5

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

Gives a concrete precondition ("The split must have only numerical, complete features") and ties split_id to a split made by train_test_split, which is real when-to-use context. It stops short of stating exclusions or naming when to prefer ridge_regression or plain linear_regression instead, so it is clear but not fully selective.

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

Deploy Server

Other Tools