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-model3description: Measure model performance on test datasets. Use when assessing accuracy, precision, recall, and other metrics.4---5
6# Evaluate Model
7
8Measure machine learning model performance using appropriate metrics for the task (classification, regression, etc.).
9
10## When to Use
11
12- Comparing different model architectures
13- Assessing performance on test/validation datasets
14- Detecting overfitting or underfitting
15- Reporting model accuracy for papers and documentation
16
17## Quick Reference
18
19```mojo
20# Mojo model evaluation pattern
21struct ModelEvaluator:
22 fn evaluate_classification(
23 mut self,
24 predictions: ExTensor,
25 ground_truth: ExTensor
26 ) -> Tuple[Float32, Float32, Float32]:
27 # Returns accuracy, precision, recall
28 ...
29
30 fn evaluate_regression(
31 mut self,
32 predictions: ExTensor,
33 ground_truth: ExTensor
34 ) -> Tuple[Float32, Float32]:
35 # Returns MSE, MAE
36 ...
37```
38
39## Workflow
40
411. **Load test data**: Prepare test/validation dataset
422. **Generate predictions**: Run model inference on test set
433. **Select metrics**: Choose appropriate metrics (accuracy, precision, recall, F1, AUC, MSE, etc.)
444. **Calculate metrics**: Compute performance metrics
455. **Analyze results**: Compare to baseline and identify strengths/weaknesses
46
47## Output Format
48
49Evaluation report:
50
51- Task type (classification, regression, etc.)
52- Metrics (accuracy, precision, recall, F1, AUC, etc.)
53- Per-class breakdown (if applicable)
54- Comparison to baseline model
55- Confusion matrix (classification)
56- Error analysis
57
58## References
59
60- See CLAUDE.md > Language Preference (Mojo for ML models)
61- See `train-model` skill for model training
62- See `/notes/review/mojo-ml-patterns.md` for Mojo tensor operations