Documentation / @openassistant/geoda / standardizeVariable
Variable: standardizeVariable
conststandardizeVariable:OpenAssistantTool<StandardizeVariableToolArgs,StandardizeVariableToolLlmResult,StandardizeVariableToolAdditionalData,StandardizeVariableToolContext>
Defined in: src/variable/tool.ts:98
standardizeVariable Tool
This tool standardizes a variable using various statistical methods. Standardization transforms data to have a mean of 0 and standard deviation of 1, making different variables comparable.
Standardization Methods
The tool supports various standardization methods:
- deviationFromMean: Standardizes to mean=0, std=1 (most common)
- standardizeMAD: Uses median and MAD instead of mean and std
- rangeAdjust: Scales to range [0,1]
- rangeStandardize: Scales using interquartile range
- standardize: Z-score standardization
Parameters
datasetName: Name of the dataset containing the variablevariableName: Name of the variable to standardizestandardizationMethod: Standardization method to use (see above)saveData: Whether to save the standardized values (optional)
Example user prompts:
- "Standardize the population variable using z-score method"
- "Normalize the income data using min-max scaling"
- "Apply robust standardization to the housing prices"
Example
typescript
import { standardizeVariable } from "@openassistant/geoda";
import { convertToVercelAiTool } from "@openassistant/utils";
const standardizeTool = {
...standardizeVariable,
context: {
getValues: async (datasetName: string, variableName: string) => {
// Implementation to retrieve values from your data source
return [100, 200, 150, 300, 250, 180, 220, 190, 280, 210];
},
},
};
const result = await generateText({
model: openai('gpt-4.1', { apiKey: key }),
prompt: 'Standardize the population variable using z-score method',
tools: { standardizeVariable: convertToVercelAiTool(standardizeTool) },
});