Evaluate Model
Measure machine learning model performance using appropriate metrics for the task (classification, regression, etc.).
When to Use
- Comparing different model architectures
- Assessing performance on test/validation datasets
- Detecting overfitting or underfitting
- Reporting model accuracy for papers and documentation
Quick Reference
# Mojo model evaluation pattern
struct ModelEvaluator:
fn evaluate_classification(
mut self,
predictions: ExTensor,
ground_truth: ExTensor
) -> Tuple[Float32, Float32, Float32]:
# Returns accuracy, precision, recall
...
fn evaluate_regression(
mut self,
predictions: ExTensor,
ground_truth: ExTensor
) -> Tuple[Float32, Float32]:
# Returns MSE, MAE
...
Workflow
- Load test data: Prepare test/validation dataset
- Generate predictions: Run model inference on test set
- Select metrics: Choose appropriate metrics (accuracy, precision, recall, F1, AUC, MSE, etc.)
- Calculate metrics: Compute performance metrics
- Analyze results: Compare to baseline and identify strengths/weaknesses
Output Format
Evaluation report:
- Task type (classification, regression, etc.)
- Metrics (accuracy, precision, recall, F1, AUC, etc.)
- Per-class breakdown (if applicable)
- Comparison to baseline model
- Confusion matrix (classification)
- Error analysis
References
- See CLAUDE.md > Language Preference (Mojo for ML models)
- See
train-model skill for model training
- See
/notes/review/mojo-ml-patterns.md for Mojo tensor operations
1---2name: evaluate-model-23description: Measure model performance on test datasets. Use when assessing accuracy, precision, recall, and other metrics.4---56# Evaluate Model78Measure machine learning model performance using appropriate metrics for the task (classification, regression, etc.).910## When to Use1112- Comparing different model architectures13- Assessing performance on test/validation datasets14- Detecting overfitting or underfitting15- Reporting model accuracy for papers and documentation1617## Quick Reference1819```mojo20# Mojo model evaluation pattern21struct ModelEvaluator:22 fn evaluate_classification(23 mut self,24 predictions: ExTensor,25 ground_truth: ExTensor26 ) -> Tuple[Float32, Float32, Float32]:27 # Returns accuracy, precision, recall28 ...2930 fn evaluate_regression(31 mut self,32 predictions: ExTensor,33 ground_truth: ExTensor34 ) -> Tuple[Float32, Float32]:35 # Returns MSE, MAE36 ...37```3839## Workflow40411. **Load test data**: Prepare test/validation dataset422. **Generate predictions**: Run model inference on test set433. **Select metrics**: Choose appropriate metrics (accuracy, precision, recall, F1, AUC, MSE, etc.)444. **Calculate metrics**: Compute performance metrics455. **Analyze results**: Compare to baseline and identify strengths/weaknesses4647## Output Format4849Evaluation report:5051- Task type (classification, regression, etc.)52- Metrics (accuracy, precision, recall, F1, AUC, etc.)53- Per-class breakdown (if applicable)54- Comparison to baseline model55- Confusion matrix (classification)56- Error analysis5758## References5960- See CLAUDE.md > Language Preference (Mojo for ML models)61- See `train-model` skill for model training62- See `/notes/review/mojo-ml-patterns.md` for Mojo tensor operations