This guide explains how to extend the ML Systems Evaluation Framework with custom components.
The framework is designed to be extensible, allowing you to create custom components that integrate with the existing system. All custom components follow a consistent interface pattern.
- Collectors: For gathering data from new sources
- Evaluators: For analyzing data with custom logic
- Reports: For generating custom output formats
- Import the base class from the appropriate module
- Extend the base class and implement required methods
- Add your custom logic in the implementation methods
- Handle errors appropriately and add logging
- Create a configuration that references your component type
- Import your component in your application
- The framework will automatically discover and instantiate your component
- Write unit tests for your component
- Test with sample data to ensure it works correctly
- Validate integration with the framework
Here's a step-by-step example of creating a custom database collector:
# my_collectors.py
from ml_eval.collectors.base import BaseCollector
from ml_eval.core.config import MetricData
from typing import Dict, Any
from datetime import datetime
class DatabaseCollector(BaseCollector):
"""Custom collector for database metrics."""
def collect(self) -> Dict[str, list[MetricData]]:
"""Collect metrics from database."""
# Your custom collection logic here
metric = MetricData(
timestamp=datetime.now(),
value=0.95, # Your metric value
metadata={'source': 'database'}
)
return {'custom_metric': [metric]}
def health_check(self) -> bool:
"""Check if data source is healthy."""
return True # Your health check logic# config.yaml
system:
name: "My System"
type: "custom"
collectors:
- name: "database_collector"
type: "custom"# main.py
import my_collectors # Import your custom component
from ml_eval.core.framework import EvaluationFramework
framework = EvaluationFramework(config)
result = framework.evaluate()Collectors are responsible for gathering data from various sources. You can create custom collectors to handle specific data sources or collection methods.
See ml_eval/collectors/base.py for the actual BaseCollector interface.
See these real collector implementations for reference:
ml_eval/collectors/online.py- Real-time data collectionml_eval/collectors/offline.py- Historical data collectionml_eval/collectors/environmental.py- Environmental monitoringml_eval/collectors/regulatory.py- Compliance monitoring
Evaluators analyze collected data and produce evaluation results. You can create custom evaluators for specific analysis needs.
See ml_eval/evaluators/base.py for the actual BaseEvaluator interface.
See these real evaluator implementations for reference:
ml_eval/evaluators/reliability.py- Reliability evaluationml_eval/evaluators/safety.py- Safety-critical evaluationml_eval/evaluators/performance.py- Performance metricsml_eval/evaluators/compliance.py- Regulatory complianceml_eval/evaluators/drift.py- Data drift detection
Reports generate output from evaluation results. You can create custom reports for specific stakeholder needs.
See ml_eval/reports/base.py for the actual BaseReport interface.
See these real report implementations for reference:
ml_eval/reports/reliability.py- Reliability reportsml_eval/reports/safety.py- Safety reportsml_eval/reports/compliance.py- Compliance reportsml_eval/reports/business.py- Business impact reports
Templates provide pre-configured setups for different use cases. You can create custom templates for your specific industry or requirements.
# custom_template.yaml
system:
name: "Custom System"
type: "custom"
collectors:
- name: "custom_collector"
type: "custom"
evaluators:
- name: "custom_evaluator"
type: "custom"
reports:
- name: "custom_report"
type: "custom"See ml_eval/templates/factory.py for how templates are implemented and ml_eval/examples/registry.py for example patterns.
Once you've created your custom components, you can use them in your configurations by setting the type field to "custom":
# config.yaml
collectors:
- name: "my_collector"
type: "custom"
evaluators:
- name: "my_evaluator"
type: "custom"import your_custom_components # Import your custom components
# The framework will automatically discover and use themThis guide provides a practical approach to extending the ML Systems Evaluation Framework with custom components, enabling you to adapt the framework to your specific needs while maintaining compatibility with the existing system.