Skip to main content
Glama
HeetVekariya

Linear Regression MCP

by HeetVekariya

label_encode_categorical_columns

Convert categorical columns into numerical labels for machine learning model training. Simplifies data preprocessing within the Linear Regression MCP pipeline, ensuring compatibility with regression algorithms.

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

  • The handler function for the 'label_encode_categorical_columns' tool. It identifies categorical columns in the global data context, applies LabelEncoder to each, transforming them into numerical labels, and confirms success.
    @mcp.tool() 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."

Other Tools

Related Tools

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