bambadij commited on
Commit
83d5030
·
verified ·
1 Parent(s): ee77a09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import numpy as np
6
  # Initialize FastAPI app
7
  app = FastAPI()
8
 
 
9
  # Load the trained Gradient Boosting model
10
  model = joblib.load('gradient_boosting_model.pkl')
11
  print('model',model)
@@ -63,7 +64,29 @@ def preprocess_input(data: PredictionInput):
63
  categorical_mapping['poutcome'].index(data.poutcome),
64
  ]
65
  return np.array([features])
66
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  # Define a POST endpoint for predictions
68
  @app.post("/predict")
69
  async def predict(data: PredictionInput):
 
6
  # Initialize FastAPI app
7
  app = FastAPI()
8
 
9
+
10
  # Load the trained Gradient Boosting model
11
  model = joblib.load('gradient_boosting_model.pkl')
12
  print('model',model)
 
64
  categorical_mapping['poutcome'].index(data.poutcome),
65
  ]
66
  return np.array([features])
67
+ # Define the GET endpoint to show the structure
68
+ @app.get("/structure")
69
+ async def get_structure():
70
+ # Example data to return
71
+ example_data = {
72
+ "age": 0,
73
+ "job": "admin",
74
+ "marital": "married",
75
+ "education": "secondary",
76
+ "default": "no",
77
+ "balance": 0,
78
+ "housing": "no",
79
+ "loan": "no",
80
+ "contact": "telephone",
81
+ "day": 0,
82
+ "month": "jan",
83
+ "duration": 0,
84
+ "campaign": 0,
85
+ "pdays": 0,
86
+ "previous": 0,
87
+ "poutcome": "success"
88
+ }
89
+ return example_data
90
  # Define a POST endpoint for predictions
91
  @app.post("/predict")
92
  async def predict(data: PredictionInput):