-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
40 lines (29 loc) · 1.06 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import Flask, render_template, request
import numpy as np
import joblib
app = Flask(__name__)
# Load the pre-trained model
model = joblib.load("house_prediction_model.pkl")
# Define the route for the home page
@app.route("/")
def home():
return render_template("index.html")
# Define the route for the prediction page
@app.route("/predict", methods=["POST"])
def predict():
# Get input values from user
bed = int(request.form["bedrooms"])
bath = int(request.form["bathrooms"])
loc = int(request.form["location"])
size = int(request.form["size"])
status = int(request.form["status"])
face = int(request.form["facing"])
Type = int(request.form["type"])
# Create input data array
input_data = np.array([[bed, bath, loc, size, status, face, Type]])
# Predict the price using the pre-trained model
predicted_price = model.predict(input_data)[0]
# Render the result page with predicted price
return render_template("index.html", predicted_price=predicted_price)
if __name__ == "__main__":
app.run(debug=True)