Spaces:
Runtime error
Runtime error
| import flask | |
| import joblib | |
| import pandas as pd | |
| # Load the trained model | |
| model = joblib.load('tuned_random_forest_model.pkl') # Replace with the actual model filename | |
| app = flask.Flask(__name__) | |
| def home(): | |
| return "Lead Conversion Prediction Backend" | |
| def predict(): | |
| try: | |
| # Get the data from the request | |
| data = flask.request.get_json(force=True) | |
| df_predict = pd.DataFrame(data) | |
| # Make predictions | |
| predictions = model.predict(df_predict) | |
| # Return the predictions as JSON | |
| return flask.jsonify(predictions.tolist()) | |
| except Exception as e: | |
| return flask.jsonify({'error': str(e)}) | |
| if __name__ == '__main__': | |
| # Run the Flask app | |
| app.run(host='0.0.0.0', port=5000) | |