Skip to main content
Glama

rescale_forecast

Convert normalized forecast predictions (0-1 range) to specific min-max values required for practical applications, adjusting units when necessary.

Instructions

A tool that rescales the prediction data (values between 0 and 1) from the NormalizedForecaster agent to scale required for a use case

When to use this tool:

  • Use this tool when there is enough information from the user or use cases to determine a reasonable min and max for the forecast predictions

  • Do not attempt to rescale or denormalize the predictions on your own without using this tool.

  • Also, if the best min and max for the use case is 0 and 1, then no rescaling is needed since that is already the scale of the predictions.

  • If a user requests to convert from probabilities to a unit in levels, be sure to caveat your use of this tool by noting that probabilities do not always scale uniformly to levels. Rescaling can be used as a rough first-pass estimate. But for best results, it would be better to start a new Chronulus forecasting use case predicting in levels from the start.

How to use this tool:

  • To use this tool present prediction_id from the normalized prediction and the min and max as floats

  • If the user is also changing units, consider if the units will be inverted and set the inverse scale to True if needed.

  • When plotting the rescaled predictions, use a Rechart time series plot with the appropriate axes labeled and include the chronulus prediction explanation as a caption below the plot.

  • If you would like to add additional notes about the scaled series, put these below the original prediction explanation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prediction_idYesThe prediction_id from a prediction result
y_minYesThe expected smallest value for the use case. E.g., for product sales, 0 would be the least possible value for sales.
y_maxYesThe expected largest value for the use case. E.g., for product sales, 0 would be the largest possible value would be given by the user or determined from this history of sales for the product in question or a similar product.
invert_scaleNoSet this flag to true if the scale of the new units will run in the opposite direction from the inputs.

Implementation Reference

  • The primary handler function that executes the rescale_forecast tool. It takes a prediction_id, scaling parameters (y_min, y_max, invert_scale), retrieves the normalized forecast, rescales it using RescaledForecast, and returns the rescaled data rows.
    async def rescale_forecast( prediction_id: Annotated[str, Field(description="The prediction_id from a prediction result")], y_min: Annotated[float, Field(description="The expected smallest value for the use case. E.g., for product sales, 0 would be the least possible value for sales.")], y_max: Annotated[float, Field(description="The expected largest value for the use case. E.g., for product sales, 0 would be the largest possible value would be given by the user or determined from this history of sales for the product in question or a similar product.")], invert_scale: Annotated[bool, Field(description="Set this flag to true if the scale of the new units will run in the opposite direction from the inputs.", default=False)], ) -> List[dict]: """Rescales prediction data from the NormalizedForecaster agent Args: prediction_id (str) : The prediction_id for the prediction you would like to rescale as returned by the forecasting agent y_min (float) : The expected smallest value for the use case. E.g., for product sales, 0 would be the least possible value for sales. y_max (float) : The expected largest value for the use case. E.g., for product sales, 0 would be the largest possible value would be given by the user or determined from this history of sales for the product in question or a similar product. invert_scale (bool): Set this flag to true if the scale of the new units will run in the opposite direction from the inputs. Returns: List[dict] : The prediction data rescaled to suit the use case """ normalized_forecast = NormalizedForecaster.get_prediction_static(prediction_id) rescaled_forecast = RescaledForecast.from_forecast( forecast=normalized_forecast, y_min=y_min, y_max=y_max, invert_scale=invert_scale ) return [DataRow(dt=row.get('date',row.get('datetime')), y_hat=row.get('y_hat')).model_dump() for row in rescaled_forecast.to_json(orient='rows')]
  • Registers the rescale_forecast function as an MCP tool with its description.
    mcp.add_tool(rescale_forecast, description=RESCALE_PREDICTIONS_DESCRIPTION)
  • Imports the rescale_forecast function for use in the MCP server.
    from chronulus_mcp.agent.forecaster import create_forecasting_agent_and_get_forecast, reuse_forecasting_agent_and_get_forecast, rescale_forecast

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/ChronulusAI/chronulus-mcp'

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