Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -41,23 +41,6 @@ def predict_sales():
|
|
| 41 |
# Return the prediction as a JSON response
|
| 42 |
return jsonify({'Prediction': prediction})
|
| 43 |
|
| 44 |
-
# Define an endpoint to predict churn for a batch of customers
|
| 45 |
-
@sales_predictor_api.post('/v1/productstorebatch')
|
| 46 |
-
def predict_churn_batch():
|
| 47 |
-
# Get the uploaded CSV file from the request
|
| 48 |
-
file = request.files['file']
|
| 49 |
-
|
| 50 |
-
# Read the file into a DataFrame
|
| 51 |
-
input_data = pd.read_csv(file)
|
| 52 |
-
|
| 53 |
-
# Make predictions for the batch data and convert raw predictions into a readable format
|
| 54 |
-
predictions = [model.predict(input_data.drop(["Product_Id","Store_Id"],axis=1)).tolist()]
|
| 55 |
-
|
| 56 |
-
prod_id_list = input_data.Product_Id.values.tolist()
|
| 57 |
-
output_dict = dict(zip(prod_id_list, predictions))
|
| 58 |
-
|
| 59 |
-
return output_dict
|
| 60 |
-
|
| 61 |
# Run the Flask app in debug mode
|
| 62 |
app = Flask(__name__)
|
| 63 |
if __name__ == '__main__':
|
|
|
|
| 41 |
# Return the prediction as a JSON response
|
| 42 |
return jsonify({'Prediction': prediction})
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# Run the Flask app in debug mode
|
| 45 |
app = Flask(__name__)
|
| 46 |
if __name__ == '__main__':
|