Spaces:
Sleeping
Sleeping
| 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): | |
| # 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, | |
| 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 | |
| with gr.Blocks() as demo: | |
| dosya = gr.File(label="Veri Seti (CSV)") | |
| hedef_sutun = gr.Dropdown(label="Hedef Sütun Adı", choices=[]) | |
| sayisal_sutunlar = gr.CheckboxGroup(label="Sayısal Sütunlar", choices=[]) | |
| kategorik_sutunlar = gr.CheckboxGroup(label="Kategorik Sütunlar", choices=[]) | |
| sayisal_imputasyon = gr.Dropdown(label="Sayısal İmputasyon Yöntemi", choices=['mean', 'median', 'zero'], value='mean') | |
| kategorik_imputasyon = gr.Dropdown(label="Kategorik İmputasyon Yöntemi", choices=['mode', 'constant'], value='mode') | |
| normalize = gr.Checkbox(label="Normalize Et") | |
| remove_outliers = gr.Checkbox(label="Aykırı Değerleri Kaldır") | |
| buton = gr.Button("Modeli Oluştur") | |
| cikti = gr.Dataframe(label="Model Değerlendirme Sonuçları") | |
| dosya.change( | |
| fn=get_columns, | |
| inputs=dosya, | |
| outputs=[hedef_sutun, sayisal_sutunlar, kategorik_sutunlar] | |
| ) | |
| buton.click( | |
| fn=otoml_islemi, | |
| inputs=[dosya, hedef_sutun, sayisal_sutunlar, kategorik_sutunlar, | |
| sayisal_imputasyon, kategorik_imputasyon, normalize, remove_outliers], | |
| outputs=cikti | |
| ) | |
| demo.launch() | |