Skip to main content
Glama

rescale_forecast

Rescale prediction data from the NormalizedForecaster agent to a specific min and max range required for your use case. Use this tool when converting normalized values (0 to 1) into meaningful units or levels, ensuring accuracy in forecasting outputs.

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
invert_scaleNoSet this flag to true if the scale of the new units will run in the opposite direction from the inputs.
prediction_idYesThe prediction_id from a prediction result
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.
y_minYesThe expected smallest value for the use case. E.g., for product sales, 0 would be the least possible value for sales.

Implementation Reference

  • The main handler function implementing the rescale_forecast tool. It rescales normalized forecast predictions to user-specified scale using min/max values and optional inversion.
    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 tool with the MCP server, associating it with a detailed description.
    mcp.add_tool(rescale_forecast, description=RESCALE_PREDICTIONS_DESCRIPTION)
  • Imports the rescale_forecast function from forecaster.py for use in tool registration.
    from chronulus_mcp.agent.forecaster import create_forecasting_agent_and_get_forecast, reuse_forecasting_agent_and_get_forecast, rescale_forecast
  • Defines the description string used for the tool registration, providing usage instructions and parameter guidance.
    RESCALE_PREDICTIONS_DESCRIPTION = """ 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. """

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