ilaydabeyhan commited on
Commit
95f73c2
·
verified ·
1 Parent(s): 29f514e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import pandas as pd
4
+ import xgboost as xgb
5
+
6
+ # XGBoost JSON modelini yükle
7
+ model = xgb.Booster()
8
+ model.load_model("xgb_model.json")
9
+
10
+ # Scaler'ı joblib ile yükle
11
+ scaler = joblib.load("scaler.pkl")
12
+
13
+ def predict_quality(pressure, temp_x_pressure, fusion_metric):
14
+ # Girdi verisini DataFrame olarak hazırla
15
+ input_df = pd.DataFrame([[pressure, temp_x_pressure, fusion_metric]],
16
+ columns=["Pressure (kPa)", "Temperature x Pressure", "Material Fusion Metric"])
17
+ # Ölçeklendirme uygula
18
+ scaled = scaler.transform(input_df)
19
+ # Tahmin için DMatrix oluştur
20
+ dmatrix = xgb.DMatrix(scaled)
21
+ prediction = model.predict(dmatrix)[0] # Liste döner, ilk elemanı al
22
+ return float(prediction)
23
+
24
+ iface = gr.Interface(
25
+ fn=predict_quality,
26
+ inputs=[
27
+ gr.Number(label="Pressure (kPa)"),
28
+ gr.Number(label="Temperature x Pressure"),
29
+ gr.Number(label="Material Fusion Metric")
30
+ ],
31
+ outputs=gr.Number(label="Kalite Skoru"),
32
+ title="Kalite Skoru Tahmin Modeli",
33
+ description="Pressure, Temperature x Pressure ve Material Fusion Metric değerlerini giriniz, kalite skorunu tahmin eder."
34
+ )
35
+
36
+ if __name__ == "__main__":
37
+ iface.launch(server_name="0.0.0.0", server_port=7860)
38
+
39
+