File size: 2,969 Bytes
520d797
 
 
 
25f0c7c
 
 
 
 
 
 
520d797
2700457
520d797
 
 
 
 
 
 
25f0c7c
 
 
520d797
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2700457
543ca25
 
 
 
 
 
 
25f0c7c
 
 
 
 
 
543ca25
 
 
 
 
 
 
 
 
 
 
 
 
25f0c7c
 
 
 
 
 
543ca25
25f0c7c
543ca25
 
 
 
fd1c827
543ca25
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import gradio as gr
import pandas as pd
from pycaret.classification import setup, compare_models, pull

def get_columns(dosya):
    if dosya is None:
        return gr.update(choices=[]), gr.update(choices=[]), gr.update(choices=[])
    data = pd.read_csv(dosya.name)
    kolonlar = data.columns.tolist()
    return gr.update(choices=kolonlar), gr.update(choices=kolonlar), gr.update(choices=kolonlar)

def otoml_islemi(dosya, hedef_sutun, sayisal_sutunlar, kategorik_sutunlar,
                 sayisal_imputasyon, kategorik_imputasyon, normalize, remove_outliers, ignore_sutunlar):
    # Veri setini yükleyin
    data = pd.read_csv(dosya.name)
    
    # PyCaret kurulumunu başlatın
    s = setup(
        data,
        target=hedef_sutun,
        numeric_features=sayisal_sutunlar if sayisal_sutunlar else None,
        categorical_features=kategorik_sutunlar if kategorik_sutunlar else None,
        ignore_features=ignore_sutunlar if ignore_sutunlar else None,
        numeric_imputation=sayisal_imputasyon,
        categorical_imputation=kategorik_imputasyon,
        normalize=normalize,
        remove_outliers=remove_outliers,
        silent=True,
        verbose=False
    )
    
    # Modelleri karşılaştırın ve en iyisini seçin
    en_iyi_model = compare_models()
    
    # Model değerlendirme sonuçlarını alın
    degerlendirme = pull()
    
    return degerlendirme

# Gradio arayüzü
with gr.Blocks() as demo:
    gr.Markdown("# PyCaret ile AutoML Arayüzü")
    
    with gr.Row():
        dosya = gr.File(label="Veri Seti (CSV)")
    
    with gr.Row():
        hedef_sutun = gr.Dropdown(label="Hedef Sütun Adı", choices=[])
    
    with gr.Row():
        sayisal_sutunlar = gr.CheckboxGroup(label="Sayısal Sütunlar", choices=[])
        kategorik_sutunlar = gr.CheckboxGroup(label="Kategorik Sütunlar", choices=[])
        ignore_sutunlar = gr.CheckboxGroup(label="Görmezden Gelinecek Sütunlar", choices=[])
    
    with gr.Row():
        sayisal_imputasyon = gr.Dropdown(choices=['mean', 'median', 'zero'], label="Sayısal İmputasyon Yöntemi", value='mean')
        kategorik_imputasyon = gr.Dropdown(choices=['mode', 'constant'], label="Kategorik İmputasyon Yöntemi", value='mode')
    
    with gr.Row():
        normalize = gr.Checkbox(label="Normalize Et", value=False)
        remove_outliers = gr.Checkbox(label="Aykırı Değerleri Kaldır", value=False)
    
    buton = gr.Button("Otomatik Modelleme Başlat")
    
    output = gr.Dataframe(label="Model Değerlendirme Sonuçları")
    
    dosya.change(
        fn=get_columns,
        inputs=dosya,
        outputs=[hedef_sutun, sayisal_sutunlar, kategorik_sutunlar, ignore_sutunlar]
    )
    
    buton.click(
        fn=otoml_islemi,
        inputs=[dosya, hedef_sutun, sayisal_sutunlar, kategorik_sutunlar,
                sayisal_imputasyon, kategorik_imputasyon, normalize, remove_outliers, ignore_sutunlar],
        outputs=output
    )

demo.launch()