File size: 2,910 Bytes
5e6746d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""Data entity classes for the MLOps platform."""
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, List, Optional


@dataclass
class DataIngestionConfig:
    """Configuration for data ingestion."""
    source_path: Path
    raw_data_path: Path
    processed_data_path: Path
    test_size: float = 0.2
    random_state: int = 42


@dataclass
class DataValidationConfig:
    """Configuration for data validation."""
    schema_path: Path
    report_path: Path
    drift_threshold: float = 0.05


@dataclass
class DataTransformationConfig:
    """Configuration for data transformation."""
    preprocessor_path: Path
    target_column: str = "target"
    numeric_imputer: str = "median"
    categorical_imputer: str = "most_frequent"
    scaler: str = "standard"
    encoder: str = "onehot"


@dataclass
class ModelTrainerConfig:
    """Configuration for model training."""
    model_dir: Path
    experiment_name: str
    test_size: float = 0.2
    cv_folds: int = 5
    random_state: int = 42
    n_jobs: int = -1


@dataclass
class ModelEvaluationConfig:
    """Configuration for model evaluation."""
    metrics_path: Path
    plots_path: Path
    threshold: float = 0.5


@dataclass
class ModelRegistryConfig:
    """Configuration for model registry."""
    tracking_uri: str
    experiment_name: str
    model_name: str


@dataclass
class DatasetInfo:
    """Information about a loaded dataset."""
    name: str
    rows: int
    columns: int
    missing_values: int
    duplicates: int
    numeric_features: List[str]
    categorical_features: List[str]
    target_column: Optional[str]
    task_type: Optional[str]  # "regression" or "classification"
    feature_dtypes: Dict[str, str] = field(default_factory=dict)
    missing_per_column: Dict[str, int] = field(default_factory=dict)
    created_at: datetime = field(default_factory=datetime.now)


@dataclass
class TrainingResult:
    """Result from a single model training run."""
    model_name: str
    run_id: str
    metrics: Dict[str, float]
    params: Dict[str, Any]
    training_time: float
    model_path: str
    feature_importances: Optional[Dict[str, float]] = None
    cv_scores: Optional[List[float]] = None
    is_best: bool = False


@dataclass
class PredictionResult:
    """Result from a prediction request."""
    predictions: List[Any]
    probabilities: Optional[List[List[float]]]
    model_name: str
    model_version: str
    inference_time: float
    confidence_scores: Optional[List[float]] = None
    explanations: Optional[Dict[str, Any]] = None


@dataclass
class ModelInfo:
    """Model information for registry."""
    name: str
    version: str
    stage: str
    metrics: Dict[str, float]
    params: Dict[str, Any]
    tags: Dict[str, str]
    created_at: datetime
    run_id: str
    artifact_uri: str
    description: Optional[str] = None