Skip to main content
Glama
HeetVekariya

Linear Regression MCP

by HeetVekariya

label_encode_categorical_columns

Convert categorical data columns into numerical format for linear regression model training by applying label encoding to prepare datasets.

Instructions

This function label encodes all the categorical columns.

Returns: String which confirms success of encoding process.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • server.py:99-99 (registration)
    Registers the label_encode_categorical_columns function as an MCP tool using the FastMCP decorator.
    @mcp.tool()
  • The handler function implements the logic to identify categorical columns in the global data context and apply label encoding to each using LabelEncoder from scikit-learn.
    def label_encode_categorical_columns() -> str: """ This function label encodes all the categorical columns. Returns: String which confirms success of encoding process. """ categorical_columns = context.get_data().select_dtypes(include=["object", "category"]).columns if len(categorical_columns) == 0: return "No categorical columns found to encode." # Initialize the LabelEncoder encoder = LabelEncoder() # Iterate over each categorical column and apply label encoding for column in categorical_columns: context.get_data()[column] = encoder.fit_transform(context.get_data()[column]) return "All categorical columns have been label encoded successfully."

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/HeetVekariya/Linear-Regression-MCP'

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