commited on
Commit
45c88e9
·
verified ·
1 Parent(s): b4bab6d

Upload 6 files

Browse files
Files changed (6) hide show
  1. README.md +31 -3
  2. app.py +24 -0
  3. kmeans_model.pkl +3 -0
  4. requirements.txt +6 -0
  5. sample_input.json +5 -0
  6. scaler.pkl +3 -0
README.md CHANGED
@@ -1,3 +1,31 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ online-retail-segmentasyon/
2
+ ├── kmeans_model.pkl
3
+ ├── scaler.pkl
4
+ ├── README.md
5
+ ├── sample_input.json ← Örnek: {"Recency": 20, "Frequency": 5, "Monetary": 1000}
6
+
7
+
8
+
9
+ # 🧠 Online Retail Müşteri Segmentasyon Modeli (K-Means)
10
+
11
+ Bu model, RFM (Recency, Frequency, Monetary) bilgilerine göre müşterileri segmentlere ayırır. Eğitilmiş bir K-Means modelidir.
12
+
13
+ ## 🔢 Girdi
14
+ ```json
15
+ {
16
+ "Recency": 20,
17
+ "Frequency": 5,
18
+ "Monetary": 1000
19
+ }
20
+
21
+
22
+ 🛠️ Nasıl Kullanılır?
23
+ import joblib
24
+ import numpy as np
25
+
26
+ model = joblib.load("kmeans_model.pkl")
27
+ scaler = joblib.load("scaler.pkl")
28
+
29
+ data = scaler.transform([[20, 5, 1000]])
30
+ segment = model.predict(data)[0]
31
+ print("Segment:", segment)
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
+ import numpy as np
5
+ import joblib
6
+
7
+ # Model ve scaler yükle
8
+ kmeans = joblib.load("kmeans_model.pkl")
9
+ scaler = joblib.load("scaler.pkl")
10
+
11
+ st.title("🛍️ Online Retail Müşteri Segmentasyonu")
12
+
13
+ st.markdown("Müşterinin Recency, Frequency, Monetary bilgilerini girin:")
14
+
15
+ # Kullanıcı girişi
16
+ recency = st.number_input("Recency (Son alışveriş gün farkı)", min_value=0)
17
+ frequency = st.number_input("Frequency (Sipariş sayısı)", min_value=0)
18
+ monetary = st.number_input("Monetary (Toplam harcama)", min_value=0)
19
+
20
+ if st.button("Segmenti Tahmin Et"):
21
+ input_data = np.array([[recency, frequency, monetary]])
22
+ input_scaled = scaler.transform(input_data)
23
+ cluster = kmeans.predict(input_scaled)[0]
24
+ st.success(f"🧠 Bu müşteri Segment {cluster} grubuna aittir.")
kmeans_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d9278499823dc9ce92269be5f28871c40c472771ffa4a361a16f6fa35cbdf68
3
+ size 18191
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ streamlit
2
+ scikit-learn
3
+ pandas
4
+ numpy
5
+ joblib
6
+ openpyxl
sample_input.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "Recency": 20,
3
+ "Frequency": 5,
4
+ "Monetary": 1000
5
+ }
scaler.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f36879a99ffed17fac8a9008db6805218a60a78b63704cf090339875119cb23
3
+ size 1007