Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse files- Dockerfile +2 -1
- app.py +9 -5
Dockerfile
CHANGED
|
@@ -2,4 +2,5 @@ FROM python:3.9-slim
|
|
| 2 |
WORKDIR /app
|
| 3 |
COPY . .
|
| 4 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 5 |
-
CMD
|
|
|
|
|
|
| 2 |
WORKDIR /app
|
| 3 |
COPY . .
|
| 4 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 5 |
+
# Update CMD to point to extraalearn_api instead of superkart_api
|
| 6 |
+
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:extraalearn_api"]
|
app.py
CHANGED
|
@@ -3,7 +3,10 @@ import joblib
|
|
| 3 |
import pandas as pd
|
| 4 |
from flask import Flask, request, jsonify
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
model = joblib.load('Extraalearn.joblib')
|
| 8 |
|
| 9 |
EXPECTED_FEATURES = [
|
|
@@ -16,11 +19,11 @@ EXPECTED_FEATURES = [
|
|
| 16 |
'educational_channels_Yes', 'referral_Yes'
|
| 17 |
]
|
| 18 |
|
| 19 |
-
@
|
| 20 |
def home():
|
| 21 |
-
return 'ExtraaLearn API is Running'
|
| 22 |
|
| 23 |
-
@
|
| 24 |
def predict():
|
| 25 |
try:
|
| 26 |
data = request.get_json()
|
|
@@ -41,6 +44,7 @@ def predict():
|
|
| 41 |
p['digital_media_Yes'] = 1 if data.get('digital_media') == 'Yes' else 0
|
| 42 |
p['educational_channels_Yes'] = 1 if data.get('educational_channels') == 'Yes' else 0
|
| 43 |
p['referral_Yes'] = 1 if data.get('referral') == 'Yes' else 0
|
|
|
|
| 44 |
df_final = pd.DataFrame([p])[EXPECTED_FEATURES]
|
| 45 |
prediction_proba = model.predict_proba(df_final)[:, 1].tolist()[0] # Use predict_proba
|
| 46 |
return jsonify({'Conversion_Probability': float(prediction_proba)}) # Changed key to Conversion_Probability
|
|
@@ -48,4 +52,4 @@ def predict():
|
|
| 48 |
return jsonify({'error': str(e)}), 400
|
| 49 |
|
| 50 |
if __name__ == '__main__':
|
| 51 |
-
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
from flask import Flask, request, jsonify
|
| 5 |
|
| 6 |
+
# Initialize Flask app for ExtraaLearn
|
| 7 |
+
extraalearn_api = Flask(__name__)
|
| 8 |
+
|
| 9 |
+
# Load the model
|
| 10 |
model = joblib.load('Extraalearn.joblib')
|
| 11 |
|
| 12 |
EXPECTED_FEATURES = [
|
|
|
|
| 19 |
'educational_channels_Yes', 'referral_Yes'
|
| 20 |
]
|
| 21 |
|
| 22 |
+
@extraalearn_api.get('/')
|
| 23 |
def home():
|
| 24 |
+
return 'ExtraaLearn Lead Conversion API is Running'
|
| 25 |
|
| 26 |
+
@extraalearn_api.post('/v1/predict')
|
| 27 |
def predict():
|
| 28 |
try:
|
| 29 |
data = request.get_json()
|
|
|
|
| 44 |
p['digital_media_Yes'] = 1 if data.get('digital_media') == 'Yes' else 0
|
| 45 |
p['educational_channels_Yes'] = 1 if data.get('educational_channels') == 'Yes' else 0
|
| 46 |
p['referral_Yes'] = 1 if data.get('referral') == 'Yes' else 0
|
| 47 |
+
|
| 48 |
df_final = pd.DataFrame([p])[EXPECTED_FEATURES]
|
| 49 |
prediction_proba = model.predict_proba(df_final)[:, 1].tolist()[0] # Use predict_proba
|
| 50 |
return jsonify({'Conversion_Probability': float(prediction_proba)}) # Changed key to Conversion_Probability
|
|
|
|
| 52 |
return jsonify({'error': str(e)}), 400
|
| 53 |
|
| 54 |
if __name__ == '__main__':
|
| 55 |
+
extraalearn_api.run(host='0.0.0.0', port=7860)
|