update
Browse files
app.py
CHANGED
|
@@ -12,14 +12,13 @@ app = FastAPI()
|
|
| 12 |
# Define the input schema for predictions
|
| 13 |
class PredictionInput(BaseModel):
|
| 14 |
feature1: float
|
| 15 |
-
feature2: float
|
| 16 |
|
| 17 |
# Define the prediction endpoint
|
| 18 |
@app.post("/predict")
|
| 19 |
def predict(input_data: PredictionInput):
|
| 20 |
try:
|
| 21 |
# Convert input into model-compatible format (as a 2D array)
|
| 22 |
-
input_features = np.array([[input_data.feature1
|
| 23 |
prediction = model.predict(input_features)
|
| 24 |
return {"prediction": prediction.tolist()} # Return prediction as a list
|
| 25 |
except Exception as e:
|
|
|
|
| 12 |
# Define the input schema for predictions
|
| 13 |
class PredictionInput(BaseModel):
|
| 14 |
feature1: float
|
|
|
|
| 15 |
|
| 16 |
# Define the prediction endpoint
|
| 17 |
@app.post("/predict")
|
| 18 |
def predict(input_data: PredictionInput):
|
| 19 |
try:
|
| 20 |
# Convert input into model-compatible format (as a 2D array)
|
| 21 |
+
input_features = np.array([[input_data.feature1]])
|
| 22 |
prediction = model.predict(input_features)
|
| 23 |
return {"prediction": prediction.tolist()} # Return prediction as a list
|
| 24 |
except Exception as e:
|