Gagan0141 commited on
Commit
fc208cf
·
verified ·
1 Parent(s): 5d24016

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -18,6 +18,7 @@ supabase = create_client(SUPABASE_URL, SUPABASE_KEY)
18
 
19
  # -------- Load ML model --------
20
  model = joblib.load("rf_house_price_model.joblib")
 
21
 
22
  # -------- Routes --------
23
  @app.route("/")
@@ -101,5 +102,26 @@ def predict():
101
 
102
  return render_template("predict.html", prediction=prediction)
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  if __name__ == "__main__":
105
  app.run(host="0.0.0.0", port=7860)
 
18
 
19
  # -------- Load ML model --------
20
  model = joblib.load("rf_house_price_model.joblib")
21
+ titanic_model = joblib.load("titanic_rf_model.joblib")
22
 
23
  # -------- Routes --------
24
  @app.route("/")
 
102
 
103
  return render_template("predict.html", prediction=prediction)
104
 
105
+ @app.route("/titanic", methods=["GET", "POST"])
106
+ def titanic_predict():
107
+ if "username" not in session:
108
+ return redirect(url_for("login"))
109
+
110
+ prediction = None
111
+ if request.method == "POST":
112
+ # Example Titanic features (adjust to your model)
113
+ features = [
114
+ float(request.form["pclass"]),
115
+ float(request.form["sex"]), # encode 0=male,1=female
116
+ float(request.form["age"]),
117
+ float(request.form["sibsp"]),
118
+ float(request.form["parch"]),
119
+ float(request.form["fare"])
120
+ ]
121
+ prediction = titanic_model.predict([features])[0]
122
+
123
+ return render_template("titanic.html", prediction=prediction)
124
+
125
+
126
  if __name__ == "__main__":
127
  app.run(host="0.0.0.0", port=7860)