Loading
Loading
MLOps (Machine Learning Operations) is the set of practices that bridges the gap between developing ML models and running them in production.
Without MLOps, this happens frequently:
from dataclasses import dataclass, field
from typing import List, Tuple
# āāā MLOps Maturity Model āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
@dataclass
class MLProject:
name: str
model_type: str
version: str = "1.0.0"
accuracy: float = 0.0
is_deployed: bool = False
tracking_enabled: bool = False
ci_cd_enabled: bool = False
monitoring_enabled: bool = False
def mlops_score(self) -> int:
return sum([
25 if self.tracking_enabled else 0,
25 if self.is_deployed else 0,
25 if self.ci_cd_enabled else 0,
25 if self.monitoring_enabled else 0,
])
def maturity_level(self) -> str:
s = self.mlops_score()
if s == 0: return "Level 0 ā Manual (ŁŲ§ Ų£ŲŖŁ
ŲŖŲ©)"
if s <= 25: return "Level 1 ā Tracking"
if s <= 50: return "Level 2 ā Deployed"
if s <= 75: return "Level 3 ā CI/CD"
return "Level 4 ā Full MLOps āØ"
def report(self):
score = self.mlops_score()
level = self.maturity_level()
print(f"\nš {self.name} (v{self.version})")
print(f" Ų§ŁŁŁŲ¹ : {self.model_type}")
print(f" Accuracy : {self.accuracy:.1%}")
print(f" Score : {score}/100 ā {level}")
checks: List[Tuple[str, bool]] = [
("Experiment Tracking", self.tracking_enabled),
("Deployed to Prod", self.is_deployed),
("CI/CD Automated", self.ci_cd_enabled),
("Monitoring Active", self.monitoring_enabled),
]
for label, ok in checks:
icon = "ā
" if ok else "ā"
print(f" {icon} {label}")
# āāā ŁŲØŁ MLOps āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
print("š¬ Ų§ŁŁŲ¶Ų¹ ŲØŲÆŁŁ MLOps:")
print("-" * 50)
proto = MLProject(
name="sentiment-model", model_type="Text Classifier",
version="1.0.0", accuracy=0.89,
)
proto.report()
# āāā ŲØŲ¹ŲÆ MLOps āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
print(f"\nš Ų§ŁŁŲ¶Ų¹ ŲØŲ¹ŲÆ ŲŖŲ·ŲØŁŁ MLOps:")
print("-" * 50)
prod = MLProject(
name="sentiment-model", model_type="Text Classifier",
version="2.3.1", accuracy=0.94,
is_deployed=True, tracking_enabled=True,
ci_cd_enabled=True, monitoring_enabled=True,
)
prod.report()
# āāā Ł
ŁŁŁŲ§ŲŖ MLOps āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
print(f"\n\nš§± Ł
ŁŁŁŲ§ŲŖ MLOps Ų§ŁŲ±Ų¦ŁŲ³ŁŲ©:")
components = [
("Data Management", "DVC, Delta Lake", "Ų„ŲÆŲ§Ų±Ų© ŁŲ„ŲµŲÆŲ§Ų± Ų§ŁŲØŁŲ§ŁŲ§ŲŖ"),
("Experiment Track", "MLflow, W&B", "ŲŖŲŖŲØŲ¹ Ų§ŁŲŖŲ¬Ų§Ų±ŲØ ŁŲ§ŁŁ
Ų¹Ų§Ł
ŁŲ§ŲŖ"),
("Model Registry", "MLflow, HuggingFace Hub", "ŲŖŲ®Ų²ŁŁ ŁŲ„ŲµŲÆŲ§Ų± Ų§ŁŁŁ
Ų§Ų°Ų¬"),
("CI/CD", "GitHub Actions, Jenkins", "Ų£ŲŖŁ
ŲŖŲ© Ų§ŁŲ§Ų®ŲŖŲØŲ§Ų± ŁŲ§ŁŁŲ“Ų±"),
("Serving", "FastAPI, TorchServe", "Ų®ŲÆŁ
Ų© Ų§ŁŁŁ
ŁŲ°Ų¬ ŁŁŲ„ŁŲŖŲ§Ų¬"),
("Monitoring", "Evidently, Grafana", "Ł
Ų±Ų§ŁŲØŲ© Ų§ŁŲ¬ŁŲÆŲ© ŁŲ§ŁŲ§ŁŲ¬Ų±Ų§Ł"),
]
for comp, tools, desc in components:
print(f" š¦ {comp:<20} ā {desc}")
print(f" Ų£ŲÆŁŲ§ŲŖ: {tools}")
print()