Skip to main content
Glama

feature_importance

Rank predictor contributions with permutation or impurity-based importance from a random forest, using a target column to identify key drivers in classification or regression.

Instructions

feature_importance —— 建模组 · 特征重要性(工具 16,核心实现)。

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

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json) target (str): 目标列(<=20 类 -> 分类随机森林 class_weight=balanced;连续 -> 回归森林) method (str, "permutation"): permutation(打乱验证集特征,验证集思想)/ impurity(训练集内基尼/方差减少;两者都输出,默认 permutation) n_estimators (int, 200): 森林树数 >=10 random_state (int, 42): 森林与划分固定种子 n_repeats (int, 10): permutation 专用,打乱次数 >=1

硬性门槛: n < 50 拒绝(规格);特征重要性排序 + "重要性≠因果"尾注。

第 4.1 条实现(确定性): train_test_split(0.25, random_state) 划分;模型在训练集拟合;impurity 取 feature_importances_;permutation 在测试集上打乱(sklearn.inspection.permutation_importance)。

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNopermutation
targetNo
file_pathNo
n_repeatsNo
inline_dataNo
n_estimatorsNo
random_stateNo

Schema Changelog

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

  1. First observedv1.2.0

TDQS

A3.9/5.0
Behavior4/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 is substantially transparent: it discloses train_test_split(0.25, random_state), fitting on the training set, permutation on the test set, impurity via feature_importances_, balanced class weights, fixed seeds, and the 'importance≠causality' footer. It does not explicitly state whether the tool has side effects or auth requirements, but the detailed computational behavior makes its functioning clear.

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 well structured into parameter documentation, hard threshold, implementation details, example, and inline-data guidance. It is long but most sentences carry useful information; only the maintenance note and external SPEC.md pointer add limited direct invocation value.

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

Completeness3/5

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

The description is rich and includes an example, thresholds, and algorithm details, but it leaves some important gaps: the schema marks all parameters optional yet the description never explicitly states that file_path or inline_data and target are required. With no output schema, the return format is only vaguely described as a ranking plus footnote, and some constraints are deferred to an external SPEC.md that an MCP agent may not access.

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 thoroughly: every parameter has type, default, and semantic constraints, e.g., n_estimators>=10, n_repeats>=1, method choices, and inline_data forms including mutual exclusivity with file_path. This is far more than the schema provides.

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 clearly identifies the tool as computing feature importance via random forest, with explicit classification vs regression behavior and an output of feature-importance ranking plus a causality footnote. It is specific about the resource and operation, though it does not explicitly distinguish itself from sibling modeling tools such as linear_regression or pca_analysis.

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 is implied by the name and description, and the tool gives internal guidance such as choosing permutation vs impurity and treating targets with <=20 classes as classification and continuous targets as regression. However, it does not explicitly say when to choose this tool over sibling alternatives, nor does it state when not to use it apart from the n<50 rejection threshold.

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