yusra21 commited on
Commit
2cb4433
·
verified ·
1 Parent(s): 5a8584d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -56,7 +56,7 @@ def predict_price(make, model, trim, mileage, car_type, cylinder, liter, doors,
56
  except Exception as e:
57
  return f"Tahmin sırasında hata oluştu: {e}"
58
 
59
- # Dinamik seçimler
60
  def update_models(selected_make):
61
  if pd.isna(selected_make) or not selected_make:
62
  return gr.Dropdown(choices=[], label="🚘 Model", interactive=True)
@@ -72,14 +72,14 @@ def update_trims(selected_make, selected_model):
72
  def update_types(selected_make, selected_model, selected_trim):
73
  if not selected_make or not selected_model or not selected_trim:
74
  return gr.Dropdown(choices=[], label="🚗 Araç Tipi", interactive=True)
75
- types = sorted(df[(df['Make'] == selected_make) &
76
  (df['Model'] == selected_model) &
77
  (df['Trim'] == selected_trim)]['Type'].dropna().unique().tolist())
78
  return gr.Dropdown(choices=types, label="🚗 Araç Tipi", interactive=True, value=types[0] if types else None)
79
 
80
- # Gradio arayüzü
81
- with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
82
- gr.Markdown("<h1 style='text-align:center; color:#2F80ED;'>🚗 <b>Araba Fiyat Tahmin Uygulaması</b></h1>")
83
  gr.Markdown("<p style='text-align:center; font-size:16px;'>🧠 Makine Öğrenmesi tabanlı fiyat tahmini yapmak için bilgileri doldurun.</p>")
84
 
85
  with gr.Accordion("📋 Tahmin Girdileri", open=True):
@@ -103,10 +103,11 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
103
  leather_rb = gr.Radio(choices=[True, False], label="🛋️ Deri Koltuk", value=False, type="value")
104
 
105
  with gr.Row():
106
- predict_button = gr.Button("💰 Fiyat Tahmini Yap")
 
107
  output_text = gr.Textbox(label="📈 Tahmini Sonuç", lines=1)
108
 
109
- # Olay bağlantıları
110
  make_dd.change(fn=update_models, inputs=make_dd, outputs=model_dd)
111
  make_dd.change(fn=lambda: (gr.Dropdown(choices=[], value=None), gr.Dropdown(choices=[], value=None)), outputs=[trim_dd, type_dd])
112
  model_dd.change(fn=update_trims, inputs=[make_dd, model_dd], outputs=trim_dd)
@@ -121,7 +122,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
121
 
122
  gr.Markdown("<hr>")
123
  gr.Markdown("""
124
- <div style='background-color:#f0f4ff; padding:15px; border-radius:10px; font-size:15px'>
125
  <h3>📌 <b>Kullanım Notları</b></h3>
126
  <ul>
127
  <li>✅ Tüm alanları eksiksiz ve doğru doldurun.</li>
@@ -131,7 +132,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
131
  </div>
132
  """)
133
 
134
- # Uygulamayı başlat
135
  if __name__ == '__main__':
136
  if pipe is None or df.empty:
137
  print("Model veya veri yüklenemedi. Uygulama başlatılamıyor.")
 
56
  except Exception as e:
57
  return f"Tahmin sırasında hata oluştu: {e}"
58
 
59
+ # Dinamik dropdown güncellemeleri
60
  def update_models(selected_make):
61
  if pd.isna(selected_make) or not selected_make:
62
  return gr.Dropdown(choices=[], label="🚘 Model", interactive=True)
 
72
  def update_types(selected_make, selected_model, selected_trim):
73
  if not selected_make or not selected_model or not selected_trim:
74
  return gr.Dropdown(choices=[], label="🚗 Araç Tipi", interactive=True)
75
+ types = sorted(df[(df['Make'] == selected_make) &
76
  (df['Model'] == selected_model) &
77
  (df['Trim'] == selected_trim)]['Type'].dropna().unique().tolist())
78
  return gr.Dropdown(choices=types, label="🚗 Araç Tipi", interactive=True, value=types[0] if types else None)
79
 
80
+ # Gradio arayüzü (tema: mor)
81
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
82
+ gr.Markdown("<h1 style='text-align:center; color:#9b59b6;'>🚗 <b>Araba Fiyat Tahmin Uygulaması</b></h1>")
83
  gr.Markdown("<p style='text-align:center; font-size:16px;'>🧠 Makine Öğrenmesi tabanlı fiyat tahmini yapmak için bilgileri doldurun.</p>")
84
 
85
  with gr.Accordion("📋 Tahmin Girdileri", open=True):
 
103
  leather_rb = gr.Radio(choices=[True, False], label="🛋️ Deri Koltuk", value=False, type="value")
104
 
105
  with gr.Row():
106
+ predict_button = gr.Button("💸 Fiyat Tahmini Yap", variant="primary")
107
+ with gr.Row():
108
  output_text = gr.Textbox(label="📈 Tahmini Sonuç", lines=1)
109
 
110
+ # Dropdown güncellemeleri
111
  make_dd.change(fn=update_models, inputs=make_dd, outputs=model_dd)
112
  make_dd.change(fn=lambda: (gr.Dropdown(choices=[], value=None), gr.Dropdown(choices=[], value=None)), outputs=[trim_dd, type_dd])
113
  model_dd.change(fn=update_trims, inputs=[make_dd, model_dd], outputs=trim_dd)
 
122
 
123
  gr.Markdown("<hr>")
124
  gr.Markdown("""
125
+ <div style='background-color:#f7f0ff; padding:15px; border-radius:10px; font-size:15px'>
126
  <h3>📌 <b>Kullanım Notları</b></h3>
127
  <ul>
128
  <li>✅ Tüm alanları eksiksiz ve doğru doldurun.</li>
 
132
  </div>
133
  """)
134
 
135
+ # Uygulama çalıştır
136
  if __name__ == '__main__':
137
  if pipe is None or df.empty:
138
  print("Model veya veri yüklenemedi. Uygulama başlatılamıyor.")