Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from pycaret.classification import setup, compare_models, pull
|
| 4 |
+
|
| 5 |
+
def get_columns(dosya):
|
| 6 |
+
if dosya is None:
|
| 7 |
+
return gr.update(choices=[]), gr.update(choices=[]), gr.update(choices=[])
|
| 8 |
+
data = pd.read_csv(dosya.name)
|
| 9 |
+
kolonlar = data.columns.tolist()
|
| 10 |
+
return gr.update(choices=kolonlar), gr.update(choices=kolonlar), gr.update(choices=kolonlar)
|
| 11 |
+
|
| 12 |
+
def otoml_islemi(dosya, hedef_sutun, sayisal_sutunlar, kategorik_sutunlar,
|
| 13 |
+
sayisal_imputasyon, kategorik_imputasyon, normalize, remove_outliers):
|
| 14 |
+
# Veri setini yükleyin
|
| 15 |
+
data = pd.read_csv(dosya.name)
|
| 16 |
+
|
| 17 |
+
# PyCaret kurulumunu başlatın
|
| 18 |
+
s = setup(
|
| 19 |
+
data,
|
| 20 |
+
target=hedef_sutun,
|
| 21 |
+
numeric_features=sayisal_sutunlar if sayisal_sutunlar else None,
|
| 22 |
+
categorical_features=kategorik_sutunlar if kategorik_sutunlar else None,
|
| 23 |
+
numeric_imputation=sayisal_imputasyon,
|
| 24 |
+
categorical_imputation=kategorik_imputasyon,
|
| 25 |
+
normalize=normalize,
|
| 26 |
+
remove_outliers=remove_outliers,
|
| 27 |
+
silent=True,
|
| 28 |
+
verbose=False
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# Modelleri karşılaştırın ve en iyisini seçin
|
| 32 |
+
en_iyi_model = compare_models()
|
| 33 |
+
|
| 34 |
+
# Model değerlendirme sonuçlarını alın
|
| 35 |
+
degerlendirme = pull()
|
| 36 |
+
|
| 37 |
+
return degerlendirme
|
| 38 |
+
|
| 39 |
+
with gr.Blocks() as demo:
|
| 40 |
+
dosya = gr.File(label="Veri Seti (CSV)")
|
| 41 |
+
hedef_sutun = gr.Dropdown(label="Hedef Sütun Adı", choices=[])
|
| 42 |
+
sayisal_sutunlar = gr.CheckboxGroup(label="Sayısal Sütunlar", choices=[])
|
| 43 |
+
kategorik_sutunlar = gr.CheckboxGroup(label="Kategorik Sütunlar", choices=[])
|
| 44 |
+
sayisal_imputasyon = gr.Dropdown(label="Sayısal İmputasyon Yöntemi", choices=['mean', 'median', 'zero'], value='mean')
|
| 45 |
+
kategorik_imputasyon = gr.Dropdown(label="Kategorik İmputasyon Yöntemi", choices=['mode', 'constant'], value='mode')
|
| 46 |
+
normalize = gr.Checkbox(label="Normalize Et")
|
| 47 |
+
remove_outliers = gr.Checkbox(label="Aykırı Değerleri Kaldır")
|
| 48 |
+
buton = gr.Button("Modeli Oluştur")
|
| 49 |
+
cikti = gr.Dataframe(label="Model Değerlendirme Sonuçları")
|
| 50 |
+
|
| 51 |
+
dosya.change(
|
| 52 |
+
fn=get_columns,
|
| 53 |
+
inputs=dosya,
|
| 54 |
+
outputs=[hedef_sutun, sayisal_sutunlar, kategorik_sutunlar]
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
buton.click(
|
| 58 |
+
fn=otoml_islemi,
|
| 59 |
+
inputs=[dosya, hedef_sutun, sayisal_sutunlar, kategorik_sutunlar,
|
| 60 |
+
sayisal_imputasyon, kategorik_imputasyon, normalize, remove_outliers],
|
| 61 |
+
outputs=cikti
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
demo.launch()
|