Özel Bir Tahminleyici Yazın
Kendi ön işleme ve model kodunuzu sisteme ekleyin.
Özel Bir Tahminleyici Yazın, CoddyKit'te ücretsiz bir MLOps Academy dersidir. Bu, 4 dersinin 3. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, MLOps Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. MLOps Academy kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
When Built-ins Fall Short
The built-in runtimes cover sklearn, PyTorch, and friends. But when your model needs special logic, you write your own. A custom predictor gives you full control. 🛠️
It Is Just a Container
A custom predictor is your own container image that speaks the KServe protocol. You package your code, model, and dependencies into one image and hand it to KServe.
The KServe Python SDK
The kserve Python package gives you a base class to extend. You subclass kserve.Model and fill in how your model loads and predicts.
import kserve
class MyModel(kserve.Model):
def __init__(self, name):
super().__init__(name)
self.ready = FalseImplement load()
The load method reads your model from disk into memory once at startup. When it finishes, you set ready to True so KServe knows it can serve.
def load(self):
self.model = joblib.load("/mnt/models/model.joblib")
self.ready = TrueImplement predict()
The predict method takes the request payload, runs your model, and returns the result as a dict. This is where your real inference logic lives.
def predict(self, payload, headers=None):
rows = payload["instances"]
preds = self.model.predict(rows)
return {"predictions": preds.tolist()}Custom Preprocessing Fits Here
Need to reshape inputs or apply business rules before inference? Put that logic right inside predict or in a preprocess step. The runtime never had to know about it.
Start the Model Server
You wire your class into a ModelServer and start it. KServe's server handles HTTP, health, and the protocol so you only write model code. ModelServer runs the loop.
if __name__ == "__main__":
model = MyModel("custom-model")
model.load()
kserve.ModelServer().start([model])Package It in a Dockerfile
You build a container that installs kserve, copies your code, and runs the server. This Dockerfile produces the image KServe will launch.
FROM python:3.11-slim
RUN pip install kserve joblib scikit-learn
COPY model.py /app/model.py
CMD ["python", "/app/model.py"]Point the Spec at Your Image
In the InferenceService, the predictor uses a plain containers block instead of a model format. You name your image and KServe runs it.
spec:
predictor:
containers:
- name: kserve-container
image: my-registry/custom-model:latestMounting Your Model
You can still set a storageUri, and KServe mounts the downloaded model at a known path your code reads. The container and the storageUri work together.
Same Protocol, Your Logic
Because you implement the standard endpoints, clients call your custom predictor exactly like a built-in one. The protocol stays identical, only the internals are yours.
Quick Check
You subclass kserve.Model for a custom predictor. Which method loads the model into memory?
Recap
You built a custom predictor by subclassing kserve.Model, filling in load and predict, and shipping it as a container. Same protocol, your own logic. Awesome work! 🎉
Sıkça Sorulan Sorular
“Özel Bir Tahminleyici Yazın” dersi ücretsiz mi?
Evet — “Özel Bir Tahminleyici Yazın” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve MLOps Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. MLOps Academy kursu toplamda 4 dersten oluşur.
“Özel Bir Tahminleyici Yazın” dersinde ne öğreneceğim?
Kendi ön işleme ve model kodunuzu sisteme ekleyin. MLOps Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
MLOps Academy öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te MLOps Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 3. dersidir.
“Özel Bir Tahminleyici Yazın” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu MLOps Academy dersinde kod yazıp çalıştırabilir miyim?
Evet. Her MLOps Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- InferenceService Kaynağı
- Sıfıra ve Yeniden Ölçeklendirin
- Özel Bir Tahminleyici Yazın
- KServe ve Seldon Core Karşılaştırması