This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.post("/predict", response_model=PredictResponse) | |
def predict(input: PredictRequest): | |
return PredictResponse(data=[0.0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from fastapi import Depends | |
from .ml.model import get_model | |
@app.post("/predict", response_model=PredictResponse) | |
def predict(input: PredictRequest, model: Model = Depends(get_model)): | |
X = np.array(input.data) | |
y_pred = model.predict(X) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
from fastapi import FastAPI | |
from pydantic import BaseModel | |
class PredictRequest(BaseModel): | |
data: List[List[float]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model: | |
def train(self, X, y): | |
pass | |
def predict(self, X): | |
pass | |
def save(self): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import joblib | |
import numpy as np | |
from pathlib import Path | |
from sklearn.ensemble import RandomForestRegressor | |
from sklearn.datasets import load_boston | |
class Model: | |
def __init__(self, model_path: str = None): |
NewerOlder