-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
34 lines (24 loc) · 884 Bytes
/
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
from flask import Flask, render_template, request
import joblib # Untuk memuat model
import numpy as np
app = Flask(__name__)
# Load model
model = joblib.load("model.pkl") # Sesuaikan dengan nama dan lokasi file model Anda
@app.route("/")
def home():
return render_template("index.html")
@app.route("/predict", methods=["POST"])
def predict():
if request.method == "POST":
# Ambil nilai input dari form
input_data = [float(x) for x in request.form.values()]
input_array = np.array(input_data).reshape(1, -1)
# Lakukan prediksi menggunakan model
prediction = model.predict(input_array)
return render_template(
"index.html",
features_text=f"{input_data}",
prediction_text=f"Prediksi Harga Rumah: $ {prediction[0]:,.2f}",
)
if __name__ == "__main__":
app.run(debug=True)