Ashexperiments commited on
Commit
205ca7f
·
verified ·
1 Parent(s): 3155608

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +17 -0
  2. app.py +33 -0
  3. requirements.txt +4 -0
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent 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 packages specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Make port 5000 available to the world outside this container
14
+ EXPOSE 5000
15
+
16
+ # Run app.py when the container launches
17
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import flask
3
+ import joblib
4
+ import pandas as pd
5
+
6
+ # Load the trained model
7
+ model = joblib.load('tuned_random_forest_model.pkl') # Replace with the actual model filename
8
+
9
+ app = flask.Flask(__name__)
10
+
11
+ @app.route('/')
12
+ def home():
13
+ return "Lead Conversion Prediction Backend"
14
+
15
+ @app.route('/predict', methods=['POST'])
16
+ def predict():
17
+ try:
18
+ # Get the data from the request
19
+ data = flask.request.get_json(force=True)
20
+ df_predict = pd.DataFrame(data)
21
+
22
+ # Make predictions
23
+ predictions = model.predict(df_predict)
24
+
25
+ # Return the predictions as JSON
26
+ return flask.jsonify(predictions.tolist())
27
+
28
+ except Exception as e:
29
+ return flask.jsonify({'error': str(e)})
30
+
31
+ if __name__ == '__main__':
32
+ # Run the Flask app
33
+ app.run(host='0.0.0.0', port=5000)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ flask==3.0.3
2
+ joblib==1.4.2
3
+ pandas==2.2.2
4
+ scikit-learn==1.6.1