Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ from sklearn.cluster import KMeans
|
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
from sklearn.decomposition import PCA
|
| 7 |
import re
|
|
|
|
| 8 |
|
| 9 |
def preprocess_data(df):
|
| 10 |
#Keep rows with "user" in the "sender" column
|
|
@@ -160,8 +161,10 @@ def visualize_clusters(df):
|
|
| 160 |
plt.ylabel('PCA Component 2')
|
| 161 |
plt.show()
|
| 162 |
|
|
|
|
| 163 |
def main(file, num_clusters):
|
| 164 |
-
|
|
|
|
| 165 |
df = preprocess_data(df)
|
| 166 |
df = cluster_data(df, num_clusters)
|
| 167 |
visualize_clusters(df)
|
|
|
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
from sklearn.decomposition import PCA
|
| 7 |
import re
|
| 8 |
+
from io import BytesIO
|
| 9 |
|
| 10 |
def preprocess_data(df):
|
| 11 |
#Keep rows with "user" in the "sender" column
|
|
|
|
| 161 |
plt.ylabel('PCA Component 2')
|
| 162 |
plt.show()
|
| 163 |
|
| 164 |
+
|
| 165 |
def main(file, num_clusters):
|
| 166 |
+
file_data = file.read()
|
| 167 |
+
df = pd.read_excel(BytesIO(file_data))
|
| 168 |
df = preprocess_data(df)
|
| 169 |
df = cluster_data(df, num_clusters)
|
| 170 |
visualize_clusters(df)
|