Spaces:
Sleeping
Sleeping
| from flask import Flask, render_template, request | |
| import joblib | |
| import numpy as np | |
| app = Flask(__name__) | |
| # Load trained model | |
| model = joblib.load("ipl_model.pkl") | |
| def home(): | |
| return render_template("index.html") | |
| def predict(): | |
| if request.method == 'POST': | |
| try: | |
| unnamed_col = float(request.form['unnamed']) | |
| price_cr = float(request.form['price']) | |
| # Prepare input | |
| sample_input = np.array([[unnamed_col, price_cr]]) | |
| # Predict | |
| prediction = model.predict(sample_input)[0] | |
| return render_template("index.html", | |
| prediction_text=f"Predicted Player/Team: {prediction}") | |
| except Exception as e: | |
| return render_template("index.html", prediction_text=f"Error: {e}") | |
| if __name__ == "__main__": | |
| app.run(debug=True) | |