yazodi commited on
Commit
2af271a
·
verified ·
1 Parent(s): 6381721

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +77 -20
  2. app.py +48 -0
  3. ion_switch_model.pkl +3 -0
  4. requirements.txt +5 -3
README.md CHANGED
@@ -1,20 +1,77 @@
1
- ---
2
- title: Ion Switching Predictor
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: Streamlit template space
12
- license: mit
13
- ---
14
-
15
- # Welcome to Streamlit!
16
-
17
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
18
-
19
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Ion Switching Predictor
3
+ emoji:
4
+ colorFrom: gray
5
+ colorTo: blue
6
+ sdk: streamlit
7
+ sdk_version: "1.32.2"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # ⚡ Ion Switching - Sinyal Tabanlı Kanal Tahmini
13
+
14
+ Bu proje, Liverpool Üniversitesi tarafından sunulan zaman serisi tabanlı Kaggle yarışmasına dayanmaktadır.
15
+ Amaç, sinyal verilerine dayanarak açık kanal sayısını (`open_channels`) tahmin etmektir.
16
+
17
+ ## 📦 Kullanılan Veri Seti
18
+
19
+ - Yarışma: [University of Liverpool - Ion Switching](https://www.kaggle.com/competitions/liverpool-ion-switching)
20
+ - Girdi Özellikleri:
21
+ - `time`: Zaman damgası
22
+ - `signal`: Sinyal değeri
23
+ - Hedef:
24
+ - `open_channels`: 0–10 arasında değişen kanal sınıfları
25
+
26
+ ## 🧠 Kullanılan Yöntemler
27
+
28
+ - Rolling window tabanlı özellik mühendisliği:
29
+ - Ortalama, standart sapma, min, max (pencere: 10, 50, 100)
30
+ - Makine öğrenmesi modeli:
31
+ - `LightGBMClassifier`
32
+ - Model değerlendirme:
33
+ - Accuracy: **%98**
34
+ - Macro F1-score: **0.94**
35
+ - Weighted F1-score: **0.99**
36
+
37
+ ## 🚀 Streamlit Uygulaması
38
+
39
+ Kullanıcıdan yüklenen CSV dosyasındaki `signal` verilerine göre `open_channels` tahmini yapılır.
40
+ Model, `.pkl` formatında yüklenir. Sonuçlar indirilebilir.
41
+
42
+ ## 🧪 Örnek Kullanım
43
+
44
+ 1. `signal` sütunu içeren CSV dosyanızı yükleyin
45
+ 2. Model, rolling özellikleri ekleyerek tahmin yapar
46
+ 3. `predicted_open_channels` sütunu ile sonuçları görebilir, indirilebilir CSV alabilirsiniz
47
+
48
+ ## 🧰 Gereksinimler
49
+
50
+ ```bash
51
+ pip install -r requirements.txt
52
+ ```
53
+
54
+ ## 🧾 Dosya Yapısı
55
+
56
+ ```
57
+ 📁 ion-switching-app/
58
+ ├── app.py
59
+ ├── ion_switch_model.pkl
60
+ ├── requirements.txt
61
+ └── README.md
62
+ ```
63
+
64
+ ## 🤗 Model Paylaşımı
65
+
66
+ > Hugging Face Spaces + GitHub üzerinden dağıtılmıştır.
67
+ > Model dosyası (`.pkl`) Hugging Face Model Hub'a yüklenebilir veya örnek JSON + açıklama ile paylaşılabilir.
68
+
69
+ ## 📌 Geliştirilebilir Özellikler
70
+
71
+ - LSTM/CNN ile zaman serisi derin öğrenme modeli
72
+ - Kapsamlı rolling feature grid search
73
+ - Sinyal segmentasyonu ile daha hassas blok modelleri
74
+
75
+ ## 📄 Lisans
76
+
77
+ MIT License
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import joblib
5
+
6
+ # Başlık
7
+ st.title("🔌 Ion Switching Tahmin Uygulaması")
8
+
9
+ # Modeli yükle
10
+ model = joblib.load("ion_switch_model.pkl")
11
+
12
+ # Rolling feature fonksiyonu
13
+ def add_rolling_features(df, window_sizes=[10, 50, 100]):
14
+ for window in window_sizes:
15
+ df[f'signal_mean_{window}'] = df['signal'].rolling(window=window, min_periods=1, center=True).mean()
16
+ df[f'signal_std_{window}'] = df['signal'].rolling(window=window, min_periods=1, center=True).std()
17
+ df[f'signal_min_{window}'] = df['signal'].rolling(window=window, min_periods=1, center=True).min()
18
+ df[f'signal_max_{window}'] = df['signal'].rolling(window=window, min_periods=1, center=True).max()
19
+ return df
20
+
21
+ # CSV yükleme
22
+ uploaded_file = st.file_uploader("📤 Lütfen sinyal içeren CSV dosyasını yükleyin (signal sütunu olmalı)", type=["csv"])
23
+
24
+ if uploaded_file is not None:
25
+ data = pd.read_csv(uploaded_file)
26
+ st.write("📄 İlk 5 satır:")
27
+ st.write(data.head())
28
+
29
+ if 'signal' in data.columns:
30
+ # Özellikleri ekle
31
+ data_feat = add_rolling_features(data.copy())
32
+
33
+ # Tahmin
34
+ feature_cols = [col for col in data_feat.columns if 'signal_' in col]
35
+ X_input = data_feat[feature_cols].fillna(0)
36
+ preds = model.predict(X_input)
37
+
38
+ # Sonuç göster
39
+ data['predicted_open_channels'] = preds
40
+ st.success("✅ Tahminler tamamlandı!")
41
+ st.write(data[['signal', 'predicted_open_channels']].head())
42
+
43
+ # İndirilebilir hale getir
44
+ csv = data.to_csv(index=False).encode('utf-8')
45
+ st.download_button("📥 Tahmin Sonuçlarını İndir", csv, "ion_switch_predictions.csv", "text/csv")
46
+
47
+ else:
48
+ st.warning("❗ 'signal' sütunu bulunamadı.")
ion_switch_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fa5a651d9fea77e5421d649ec217ea15f4e4397f2a4511ea0be37cafcf1ad20
3
+ size 347652
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
1
+ streamlit
2
+ pandas
3
+ numpy
4
+ scikit-learn
5
+ joblib