MCP线性回归
一个MCP服务器,它通过简单的上传CSV文件,使克劳德能够训练线性回归模型,处理从数据预处理到模型评估的整个机器学习管道。
可用工具 (5 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
upload_file 1 个参数 需填 1 项
This function read the csv data and stores it in the class variable. Args: Absolute path to the .csv file. Returns: String which shows the shape of the data.
必填参数:path
get_columns_info
This function gives information about columns. Returns: String which contains column names.
该工具无需必填参数,直接调用即可
check_category_columns
This function check if data has categorical columns. Returns: String which contains list of categorical columns.
该工具无需必填参数,直接调用即可
label_encode_categorical_columns
This function label encodes all the categorical columns. Returns: String which confirms success of encoding process.
该工具无需必填参数,直接调用即可
train_linear_regression_model 1 个参数 需填 1 项
This function trains linear regression model. Args: Takes input for output column name. Returns: String which contains the RMSE value.
必填参数:output_column
服务介绍
线性回归 MCP
欢迎来到 线性回归 MCP!该项目展示了使用 Claude 和模型上下文协议(MCP)的端到端机器学习工作流程。
Claude 可以完全自行训练一个 线性回归模型,只需上传包含数据集的 CSV 文件即可。系统将经历整个 ML 模型训练生命周期,处理数据预处理、训练和评估(RMSE 计算)。
设置与安装
1. 克隆仓库:
首先,将仓库克隆到本地机器上:
git clone https://github.com/HeetVekariya/Linear-Regression-MCP
cd Linear-Regression-MCP
2. 安装 uv:
uv 是一个极其快速的 Python 包和项目管理器,用 Rust 编写。它对于管理此项目中的服务器和依赖项至关重要。
- 从 这里 下载并安装
uv。
3. 安装依赖项:
安装好 uv 后,运行以下命令来安装所有必要的依赖项:
uv sync
4. 配置 Claude Desktop:
要将服务器与 Claude Desktop 集成,您需要修改 Claude 配置文件。请按照您的操作系统说明进行操作:
- 对于 macOS 或 Linux:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
- 对于 Windows:
code $env:AppData\Claude\claude_desktop_config.json
- 在配置文件中,找到
mcpServers部分,并将占位符路径替换为uv安装和线性回归项目目录的绝对路径。它应该看起来像这样:
{
"mcpServers":
{
"linear-regression":
{
"command": "ABSOLUTE/PATH/TO/.local/bin/uv",
"args":
[
"--directory",
"ABSOLUTE/PATH/TO/YOUR-LINEAR-REGRESSION-REPO",
"run",
"server.py"
]
}
}
}
- 保存文件后,重启 Claude Desktop 以链接到 MCP 服务器。
可用工具
该项目中提供了以下工具,帮助您处理数据集并训练模型:
| 工具 | 描述 | 参数 |
|---|---|---|
upload_file(path) |
上传 CSV 文件并存储以供处理。 | path: CSV 文件的绝对路径。 |
get_columns_info() |
检索上传数据集中的列名。 | 无参数。 |
check_category_columns() |
检查数据集中是否存在任何分类列。 | 无参数。 |
label_encode_categorical_columns() |
将分类列标签编码为数值。 | 无参数。 |
train_linear_regression_model(output_column) |
训练线性回归模型并计算 RMSE。 | output_column: 目标列的名称。 |
开放贡献
我欢迎对这个项目做出贡献!无论是修复错误、添加新功能还是改进文档,都请随时 fork 仓库并提交 pull 请求。
如果你有任何建议或功能请求,请提出 issue,我很乐意讨论!