BaşlayınÜcretsiz başlayın

Create a Pydantic model for ML input

You're developing a FastAPI application to deploy a machine learning model that predicts the quality score of coffee based on attributes including aroma, flavor, and altitude.

The first step is to create a Pydantic model to validate the input request data for your ML model and ensure that only valid data flows through the model for successful model prediction.

Bu egzersiz, kursun bir parçasıdır

Deploying AI into Production with FastAPI

Kursa Göz Atın

Egzersiz talimatları

  • Import the base validation class from Pydantic to create a data model.
  • Define a class named CoffeeQualityInput that inherits from the Pydantic base class.
  • Add three attributes to the class: aroma (float), flavor (float), and altitude (int).

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Import the base class from pydantic
from pydantic import ____ 

class CoffeeQualityInput(____):
    # Use apt data type for each attribute of coffee quality
    aroma: ____  
    flavor: ____  
    altitude: ____  
Kodu Düzenle ve Çalıştır