Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from flask import Flask, render_template, request | |
| import joblib | |
| import numpy as np | |
| import pickle | |
| app = Flask(__name__) | |
| # Load models | |
| regressor = joblib.load('model/regressor_model.pkl') | |
| classifier = joblib.load('model/classifier_model.pkl') | |
| def home(): | |
| return render_template('index.html') | |
| def regression(): | |
| return render_template('regression.html') | |
| def classification(): | |
| return render_template('classification.html') | |
| def predict_regression(): | |
| try: | |
| input_data = [float(x) for x in request.form.values()] | |
| features = np.array([input_data]) | |
| prediction = regressor.predict(features)[0] | |
| return render_template('regression.html', prediction_text=f'π Predicted Value: {prediction:.2f}') | |
| except Exception as e: | |
| return render_template('regression.html', prediction_text=f"β οΈ Error: {str(e)}") | |
| def predict_classification(): | |
| try: | |
| input_data = [float(x) for x in request.form.values()] | |
| features = np.array([input_data]) | |
| prediction = classifier.predict(features)[0] | |
| return render_template('classification.html', prediction_text=f'π― Predicted Class: {int(prediction)}') | |
| except Exception as e: | |
| return render_template('classification.html', prediction_text=f"β οΈ Error: {str(e)}") | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |