Skip to main content
Glama

logistic_regression

Fit and evaluate a binary classifier using stratified train/test split and balanced class handling, outputting ROC-AUC, confusion matrix, and odds ratios with p-values.

Instructions

logistic_regression —— 建模组 · 逻辑回归(工具 13,核心实现)。

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

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) target (str): 二分类目标列(恰好 2 类;类名映射为 0/1 输出 label_mapping) features (list[str]): 数值特征(本工具不做 one-hot,规格未要求;非数值报错) test_size (float, 0.3): train/test 分层划分比例 ∈(0,1) random_state (int, 42): 划分与复制的固定随机种子 class_weight (str, "balanced"): balanced 用少数类确定性复制实现(statsmodels Logit 无内置类权重,如实披露;复制样本 w=n/(2*n_class) 于训练集内,seed 固定)

固定五项输出(规格硬性): 类别分布 / accuracy(仅对照,受类别不平衡影响)/ 混淆矩阵 / ROC-AUC+95%CI (Hanley-McNeil 正态近似)/ 特征 OR 与 p 值(statsmodels Logit 矩阵接口, OR=exp(beta))。ConvergenceWarning(完美可分)-> convergence_warning 注明系数不稳定。

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetNo
featuresNo
file_pathNo
test_sizeNo
inline_dataNo
class_weightNobalanced
random_stateNo

Schema Changelog

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

  1. First observedv1.2.0

TDQS

A4.4/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden and handles it well. It discloses deterministic duplication for class_weight='balanced', the absence of built-in statsmodels weights, fixed random seeds, stratified split behavior, convergence warnings on perfectly separable data, and the caveat that accuracy is affected by class imbalance.

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 long but well-structured with clear sections for parameters, outputs, examples, and inline data. The maintenance note 'docstring = agent 使用说明书...' is meta and not directly actionable, but the remaining content is dense and relevant. It is appropriately sized for a 7-parameter tool with nontrivial behavior.

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?

The description covers inputs, defaults, outputs, error behavior, class-weight implementation, and convergence warnings, which is strong given no output schema exists. It lists the five required outputs but does not specify their exact JSON structure or types, and some inline-data limits are deferred to an external SPEC document.

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 compensate for all 7 parameters. It does: file_path, target, features, test_size, random_state, class_weight, and inline_data are each explained with types, defaults, constraints, and special behaviors. This far exceeds the bare schema and gives an agent enough to construct valid calls.

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 '建模组 · 逻辑回归' and details its binary classification role, target/feature requirements, and fixed outputs. It clearly distinguishes it from sibling modeling tools like linear_regression by focusing on binomial targets and OR/p-values, though it never states an explicit verb phrase like 'fits a logistic regression model'.

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?

The description gives concrete usage constraints: target must be exactly 2 classes, features must be numeric, one-hot encoding is not performed, and non-numeric features raise errors. It also explains the inline_data vs file_path choice. It does not explicitly name alternative tools for other scenarios, but the binary-classification framing makes the intended use clear.

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