Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,11 +10,13 @@ df = pd.read_csv('dataset_actualizado.csv')
|
|
| 10 |
|
| 11 |
# Escalar datos
|
| 12 |
scaler = StandardScaler()
|
| 13 |
-
X =
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Entrenar modelo KMeans
|
| 16 |
kmeans = KMeans(n_clusters=3, random_state=42)
|
| 17 |
-
kmeans.fit(
|
| 18 |
|
| 19 |
# Funci贸n para predecir segmento
|
| 20 |
def predecir_segmento(frecuencia_compra, monto_promedio, edad, ingreso):
|
|
@@ -64,3 +66,4 @@ iface = gr.Interface(
|
|
| 64 |
if __name__ == "__main__":
|
| 65 |
iface.launch()
|
| 66 |
|
|
|
|
|
|
| 10 |
|
| 11 |
# Escalar datos
|
| 12 |
scaler = StandardScaler()
|
| 13 |
+
X = df[['frecuencia_compra', 'monto_promedio', 'edad', 'ingreso']]
|
| 14 |
+
scaler = StandardScaler()
|
| 15 |
+
X_scaled = scaler.fit_transform(X)
|
| 16 |
|
| 17 |
# Entrenar modelo KMeans
|
| 18 |
kmeans = KMeans(n_clusters=3, random_state=42)
|
| 19 |
+
kmeans.fit(X_scaled)
|
| 20 |
|
| 21 |
# Funci贸n para predecir segmento
|
| 22 |
def predecir_segmento(frecuencia_compra, monto_promedio, edad, ingreso):
|
|
|
|
| 66 |
if __name__ == "__main__":
|
| 67 |
iface.launch()
|
| 68 |
|
| 69 |
+
|