Fetching metadata from the HF Docker repository...
-
Add Streamlit config to fix permissions
Sasidharan
-
Add Bagging model file
Sasidharan
-
Update app.py
-
Update Dockerfile
-
Update requirements.txt
-
Add Random Forest model file
Sasidharan
-
Update app.py
-
Create Dockerfile
-
Update app.py
-
Flask
from flask import Flask, request, jsonify
import joblib
import pandas as pd
# Load model
model = joblib.load('xgb_best_model.pkl')
# Create Flask app
app = Flask(__name__)
# Home route
@app.route('/')
def home():
return "Sales Forecast Model API is up and running!"
# Predict route
@app.route('/predict', methods=['POST'])
def predict():
try:
# Get JSON input
data = request.get_json(force=True)
input_df = pd.DataFrame(data)
# Predict
prediction = model.predict(input_df)
# Return result
return jsonify({'predictions': prediction.tolist()})
except Exception as e:
return jsonify({'error': str(e)})
# Run the app
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000) -
Create app.py
-
Create requirements.txt
-
initial commit