-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.py
More file actions
34 lines (26 loc) · 825 Bytes
/
router.py
File metadata and controls
34 lines (26 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from fastapi import APIRouter
from models.Candidate import Candidate
import pickle
api_router = APIRouter()
model = pickle.load(open('./model/applicants_hireable.pkl', 'rb'))
# Setting up the home route
@api_router.get("/")
def read_root():
return {"data": "Welcome to online employee hireability prediction model"}
# Setting up the prediction route
@api_router.post("/prediction/")
async def get_predict(data: Candidate):
sample = [[
data.gender,
data.bachelor_score,
data.work_experience,
data.experience_test,
data.master_score
]]
hired = model.predict(sample).tolist()[0]
return {
"data": {
'prediction': hired,
'interpretation': 'Candidate can be hired.' if hired == 1 else 'Candidate can not be hired.'
}
}