Skip to main content
Glama

linear_regression

Fit a regression model to quantify how predictors influence a continuous outcome, with automatic categorical encoding, residual diagnostics, and significance testing.

Instructions

linear_regression —— 建模组 · 线性回归(工具 12,核心实现)。

docstring = agent 使用说明书,与 statlab_mcp/docs/design/05_modeling.md 同步维护。

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) target (str): 连续因变量(数值列) features (list[str]): 自变量(数值列直用;类别列自动 one-hot 并输出映射) add_constant (bool, True): 是否加截距(False 时 GOF 指标参考意义受限,注明) alpha (float, 0.05): 显著性阈值(报告用,∈(0,1))

口径: statsmodels OLS 矩阵接口(禁 formula);类别列 get_dummies(drop_first=False) + 映射; 零方差列自动剔除并报告;缺失 listwise dropna 并注明"已剔除 N 行"; n <= 设计矩阵列数+2 拒绝(无法稳定估计);VIF>10 标注强共线性; 残差 Shapiro + Durbin-Watson;残差诊断图(残差vs拟合 + 直方图,image 顶层)。

示例: linear_regression("samples/clean.csv", target="income", features=["age"]) linear_regression("samples/clean.csv", target="score", features=["age", "category"]) inline 数据: 本工具支持可选 inline_data 参数(v1.2.0 起):与 file_path 二选一, 支持 records 数组或 {"header": [...], "rows": [[...], ...]} 对象两种形态; 规模上限/类型域/data_source 来源标注见 statlab_mcp/docs/SPEC.md 第 12 节。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
alphaNo
targetNo
featuresNo
file_pathNo
inline_dataNo
add_constantNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.2.0

TDQS

A4.2/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden and does so thoroughly: it discloses statsmodels OLS matrix interface (no formula), one-hot encoding with drop_first=False plus mapping output, zero-variance column removal, listwise dropna with row-count reporting, rejection when n is too small, VIF>10 flagging, residual diagnostics, and top-level __image__ plots.

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?

The description is organized into clear labeled sections (参数, 口径, 示例, inline 数据) and is dense with useful information. Minor overhead exists in maintenance notes like 'docstring = agent 使用说明书...' and '工具 12,核心实现,' which do not help an agent invoke the tool.

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 complex modeling tool with no output schema and no annotations, the description is highly complete: parameter semantics, edge-case behavior, examples, and inline_data support are all covered. It does not define the full return-object shape, but it names key outputs (GOF, VIF, residual diagnostics, image placement) well enough for invocation.

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%, and the description compensates fully by documenting all six parameters: file formats for file_path, continuous-target constraint for target, one-hot behavior for features, add_constant consequence for GOF, alpha threshold semantics, and the inline_data record/header-rows shapes with a file_path/inline_data mutual-exclusion rule.

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 identifies the tool as '线性回归' using statsmodels OLS, with a continuous dependent variable (target) and feature list, which clearly conveys a model-fitting operation. It does not explicitly contrast itself with sibling logistic_regression, but the '连续因变量(数值列)' constraint implies the intended use case.

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

Usage Guidelines3/5

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

Usage context is implied through parameter semantics ('target (str): 连续因变量' and '类别列自动 one-hot'), and examples show typical calls. However, there is no explicit when-to-use/when-not-to-use guidance or mention of alternatives such as logistic_regression, leaving the agent to infer selection criteria.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/good-boy4069/statlab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server