sid22669 commited on
Commit
3d61956
·
1 Parent(s): 5a709f3

Added Files

Browse files
Files changed (4) hide show
  1. Dockerfile +18 -0
  2. app.py +34 -0
  3. random_forest_model.joblib +3 -0
  4. requirements.txt +5 -0
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image
2
+ FROM python:3.9-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /app
8
+ COPY . /app
9
+
10
+ # Install any needed dependencies specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Make port 8000 available to the world outside this container
14
+ EXPOSE 8000
15
+
16
+ # Run app.py when the container launches
17
+ CMD ["python", "app.py"]
18
+
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ import joblib
4
+ import numpy as np
5
+
6
+ app = FastAPI()
7
+
8
+ class InputData(BaseModel):
9
+ input1 : bool
10
+ input2 : float
11
+ input3 : float
12
+ input4 : float
13
+ input5 : float
14
+ input6 : float
15
+ input7 : float
16
+
17
+ try:
18
+ model = joblib.load('random_forest_model.joblib')
19
+ status = 'Loaded'
20
+ except:
21
+ status = "not loaded"
22
+
23
+ @app.get('/')
24
+ def health_check():
25
+ return {'status' : f'{status}'}
26
+
27
+ @app.post('/predict')
28
+ def predict(input : InputData):
29
+ data = np.array([[input.input1, input.input2,
30
+ input.input3, input.input4,
31
+ input.input5, input.input6,
32
+ input.input7]])
33
+ prediction = model.predict(data).tolist()
34
+ return {'prediction' : f'prediction'}
random_forest_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:659ff6618b8604bafb159401806901f91d9ca0fc62311fa8b5785982a15ed76a
3
+ size 6781057
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ uvicorn
2
+ fastapi
3
+ pydantic
4
+ joblib
5
+ numpy