AxModelFitter_calculate_r_squared
Calculate R-squared to assess model fit using mean squared error and original data.
Instructions
Calculate R-squared to measure how well your model fits the data.
SIMPLE USAGE:
- mse: The MSE value from your optimization result
- data_file: Path to your original data file
- output_data: Which columns contain your measured values
WHAT R² MEANS:
- R² = 1.0: Perfect fit (model explains 100% of variance)
- R² = 0.8: Good fit (model explains 80% of variance)
- R² = 0.0: Poor fit (model no better than just using the mean)
- R² < 0.0: Very poor fit (model worse than just using the mean)
WORKS WITH:
- Single output: output_data = {"columns": ["voltage"], "name": "v", "unit": "volt"}
- Multiple outputs: output_data = {"columns": ["x", "y"], "name": "position", "unit": "meter"}
Use this to quickly assess if your optimization produced a good fit.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mse | Yes | Mean squared error from the optimization | |
| data_file | Yes | Path to data file (CSV, Excel, JSON, Parquet). All data must be provided via file. | |
| file_format | No | File format: 'csv', 'excel', 'json', 'parquet' (auto-detect if None) | |
| output_data | Yes | Output column mapping: {'columns': ['y'], 'name': 'y', 'unit': 'volt'} or {'columns': ['y1', 'y2'], 'name': 'y', 'unit': 'volt'} |